added #smallCaps and #allCaps methods to ParagraphStyle
This commit is contained in:
@ -74,6 +74,8 @@ export class ParagraphStyle extends Style {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------- Run formatting ---------------------- //
|
||||||
|
|
||||||
public size(twips: number): ParagraphStyle {
|
public size(twips: number): ParagraphStyle {
|
||||||
this.addRunProperty(new formatting.Size(twips));
|
this.addRunProperty(new formatting.Size(twips));
|
||||||
return this;
|
return this;
|
||||||
@ -89,6 +91,16 @@ export class ParagraphStyle extends Style {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public smallCaps(): ParagraphStyle {
|
||||||
|
this.addRunProperty(new formatting.SmallCaps());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public allCaps(): ParagraphStyle {
|
||||||
|
this.addRunProperty(new formatting.Caps());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public underline(underlineType?: string, color?: string): ParagraphStyle {
|
public underline(underlineType?: string, color?: string): ParagraphStyle {
|
||||||
this.addRunProperty(new formatting.Underline(underlineType, color));
|
this.addRunProperty(new formatting.Underline(underlineType, color));
|
||||||
return this;
|
return this;
|
||||||
|
@ -230,6 +230,36 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("#smallCaps", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.smallCaps();
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||||
|
{"w:pPr": []},
|
||||||
|
{"w:rPr": [
|
||||||
|
{"w:smallCaps": [{_attr: {"w:val": true}}]},
|
||||||
|
]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("#allCaps", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.allCaps();
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||||
|
{"w:pPr": []},
|
||||||
|
{"w:rPr": [
|
||||||
|
{"w:caps": [{_attr: {"w:val": true}}]},
|
||||||
|
]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("#bold", () => {
|
it("#bold", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId")
|
||||||
.bold();
|
.bold();
|
||||||
|
Reference in New Issue
Block a user