move indent.ts over to paragraph and add a #indent method

This commit is contained in:
felipe
2017-03-09 09:18:17 +01:00
parent 77255c9d5e
commit 2684f16579
4 changed files with 26 additions and 3 deletions

View File

@ -0,0 +1,27 @@
import { XmlAttributeComponent, XmlComponent } from "../docx/xml-components";
interface IndentAttributesProperties {
left: number;
hanging: number;
}
class IndentAttributes extends XmlAttributeComponent {
constructor(properties: IndentAttributesProperties) {
super({
left: "w:left",
hanging: "w:hanging",
}, properties);
}
}
export class Indent extends XmlComponent {
constructor(left: number, hanging?: number) {
super("w:ind");
this.root.push(new IndentAttributes({
left: left,
hanging: hanging,
}));
}
}

View File

@ -1,7 +1,9 @@
import { Num } from "../../numbering/num";
import { TextRun } from "../run/text-run";
import { Attributes, XmlComponent } from "../xml-components";
import { ThematicBreak } from "./border";
import { Indent } from "./indent";
import { PageBreak } from "./page-break";
import { ParagraphProperties } from "./properties";
import { Style } from "./style";
@ -116,4 +118,9 @@ export class Paragraph extends XmlComponent {
this.properties.push(new NumberProperties(numbering.id, indentLevel));
return this;
}
public indent(start: number, hanging?: number): Paragraph {
this.properties.push(new Indent(start, hanging));
return this;
}
}