2022-10-29 03:10:29 +01:00
|
|
|
import { SpaceType } from "@file/shared";
|
2022-06-26 23:26:42 +01:00
|
|
|
import { XmlComponent } from "@file/xml-components";
|
2016-05-09 13:02:59 +01:00
|
|
|
|
2022-06-15 00:07:12 +01:00
|
|
|
import { TextAttributes } from "../text-attributes";
|
2016-05-09 13:02:59 +01:00
|
|
|
|
2022-12-06 22:04:30 +00:00
|
|
|
// <xsd:complexType name="CT_Text">
|
|
|
|
// <xsd:simpleContent>
|
|
|
|
// <xsd:extension base="s:ST_String">
|
|
|
|
// <xsd:attribute ref="xml:space" use="optional" />
|
|
|
|
// </xsd:extension>
|
|
|
|
// </xsd:simpleContent>
|
|
|
|
// </xsd:complexType>
|
|
|
|
|
|
|
|
interface ITextOptions {
|
|
|
|
readonly space?: SpaceType;
|
|
|
|
readonly text?: string;
|
|
|
|
}
|
|
|
|
|
2017-04-14 11:01:47 +02:00
|
|
|
export class Text extends XmlComponent {
|
2022-12-06 22:04:30 +00:00
|
|
|
public constructor(options: string | ITextOptions) {
|
2016-05-09 13:02:59 +01:00
|
|
|
super("w:t");
|
2019-11-21 01:02:46 +00:00
|
|
|
|
2022-12-06 22:04:30 +00:00
|
|
|
if (typeof options === "string") {
|
|
|
|
this.root.push(new TextAttributes({ space: SpaceType.PRESERVE }));
|
|
|
|
this.root.push(options);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
this.root.push(new TextAttributes({ space: options.space ?? SpaceType.DEFAULT }));
|
|
|
|
this.root.push(options.text);
|
|
|
|
return;
|
|
|
|
}
|
2016-05-09 13:02:59 +01:00
|
|
|
}
|
2017-03-08 21:49:41 +00:00
|
|
|
}
|