added alignment methods to paragraph style
This commit is contained in:
@ -136,6 +136,26 @@ export class ParagraphStyle extends Style {
|
|||||||
|
|
||||||
// --------------------- Paragraph formatting ------------------------ //
|
// --------------------- Paragraph formatting ------------------------ //
|
||||||
|
|
||||||
|
public center(): ParagraphStyle {
|
||||||
|
this.addParagraphProperty(new paragraph.Alignment("center"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public left(): ParagraphStyle {
|
||||||
|
this.addParagraphProperty(new paragraph.Alignment("left"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public right(): ParagraphStyle {
|
||||||
|
this.addParagraphProperty(new paragraph.Alignment("right"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public justified(): ParagraphStyle {
|
||||||
|
this.addParagraphProperty(new paragraph.Alignment("both"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public indent(left: number, hanging?: number): ParagraphStyle {
|
public indent(left: number, hanging?: number): ParagraphStyle {
|
||||||
this.addParagraphProperty(new paragraph.Indent(left, hanging));
|
this.addParagraphProperty(new paragraph.Indent(left, hanging));
|
||||||
return this;
|
return this;
|
||||||
|
@ -212,6 +212,66 @@ describe("ParagraphStyle", () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("#center", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.center();
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||||
|
{"w:pPr": [
|
||||||
|
{"w:jc": [{_attr: {"w:val": "center"}}]},
|
||||||
|
]},
|
||||||
|
{"w:rPr": []},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("#left", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.left();
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||||
|
{"w:pPr": [
|
||||||
|
{"w:jc": [{_attr: {"w:val": "left"}}]},
|
||||||
|
]},
|
||||||
|
{"w:rPr": []},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("#right", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.right();
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||||
|
{"w:pPr": [
|
||||||
|
{"w:jc": [{_attr: {"w:val": "right"}}]},
|
||||||
|
]},
|
||||||
|
{"w:rPr": []},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("#justified", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.justified();
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||||
|
{"w:pPr": [
|
||||||
|
{"w:jc": [{_attr: {"w:val": "both"}}]},
|
||||||
|
]},
|
||||||
|
{"w:rPr": []},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("formatting methods: run properties", () => {
|
describe("formatting methods: run properties", () => {
|
||||||
|
Reference in New Issue
Block a user