Add underline none

Add space options for Text
This commit is contained in:
Dolan
2022-12-06 22:04:30 +00:00
parent 62b4522c94
commit 1592aa7117
4 changed files with 58 additions and 5 deletions

View File

@ -3,11 +3,31 @@ import { XmlComponent } from "@file/xml-components";
import { TextAttributes } from "../text-attributes";
export class Text extends XmlComponent {
public constructor(text: string) {
super("w:t");
this.root.push(new TextAttributes({ space: SpaceType.PRESERVE }));
// <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>
this.root.push(text);
interface ITextOptions {
readonly space?: SpaceType;
readonly text?: string;
}
export class Text extends XmlComponent {
public constructor(options: string | ITextOptions) {
super("w:t");
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;
}
}
}