Make Paragraph declaritive
This commit is contained in:
@ -4,6 +4,6 @@ import { XmlComponent } from "file/xml-components";
|
||||
export class ParagraphPropertiesDefaults extends XmlComponent {
|
||||
constructor() {
|
||||
super("w:pPrDefault");
|
||||
this.root.push(new ParagraphProperties());
|
||||
this.root.push(new ParagraphProperties({}));
|
||||
}
|
||||
}
|
||||
|
@ -166,9 +166,9 @@ describe("ParagraphStyle", () => {
|
||||
"w:bottom": {
|
||||
_attr: {
|
||||
"w:color": "auto",
|
||||
"w:space": "1",
|
||||
"w:space": 1,
|
||||
"w:val": "single",
|
||||
"w:sz": "6",
|
||||
"w:sz": 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -231,12 +231,12 @@ describe("ParagraphStyle", () => {
|
||||
});
|
||||
|
||||
it("#outlineLevel", () => {
|
||||
const style = new ParagraphStyle("myStyleId").outlineLevel("1");
|
||||
const style = new ParagraphStyle("myStyleId").outlineLevel(1);
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [{ "w:outlineLvl": { _attr: { "w:val": "1" } } }] },
|
||||
{ "w:pPr": [{ "w:outlineLvl": { _attr: { "w:val": 1 } } }] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {
|
||||
Alignment,
|
||||
AlignmentOptions,
|
||||
AlignmentType,
|
||||
Indent,
|
||||
ISpacingProperties,
|
||||
KeepLines,
|
||||
@ -24,7 +24,7 @@ export class ParagraphStyle extends Style {
|
||||
|
||||
constructor(styleId: string, name?: string) {
|
||||
super({ type: "paragraph", styleId: styleId }, name);
|
||||
this.paragraphProperties = new ParagraphProperties();
|
||||
this.paragraphProperties = new ParagraphProperties({});
|
||||
this.runProperties = new RunProperties();
|
||||
this.root.push(this.paragraphProperties);
|
||||
this.root.push(this.runProperties);
|
||||
@ -35,7 +35,7 @@ export class ParagraphStyle extends Style {
|
||||
return this;
|
||||
}
|
||||
|
||||
public outlineLevel(level: string): ParagraphStyle {
|
||||
public outlineLevel(level: number): ParagraphStyle {
|
||||
this.paragraphProperties.push(new OutlineLevel(level));
|
||||
return this;
|
||||
}
|
||||
@ -117,19 +117,19 @@ export class ParagraphStyle extends Style {
|
||||
// --------------------- Paragraph formatting ------------------------ //
|
||||
|
||||
public center(): ParagraphStyle {
|
||||
return this.addParagraphProperty(new Alignment(AlignmentOptions.CENTER));
|
||||
return this.addParagraphProperty(new Alignment(AlignmentType.CENTER));
|
||||
}
|
||||
|
||||
public left(): ParagraphStyle {
|
||||
return this.addParagraphProperty(new Alignment(AlignmentOptions.LEFT));
|
||||
return this.addParagraphProperty(new Alignment(AlignmentType.LEFT));
|
||||
}
|
||||
|
||||
public right(): ParagraphStyle {
|
||||
return this.addParagraphProperty(new Alignment(AlignmentOptions.RIGHT));
|
||||
return this.addParagraphProperty(new Alignment(AlignmentType.RIGHT));
|
||||
}
|
||||
|
||||
public justified(): ParagraphStyle {
|
||||
return this.addParagraphProperty(new Alignment(AlignmentOptions.BOTH));
|
||||
return this.addParagraphProperty(new Alignment(AlignmentType.BOTH));
|
||||
}
|
||||
|
||||
public thematicBreak(): ParagraphStyle {
|
||||
|
Reference in New Issue
Block a user