add an #underline method to ParagraphStyle
This commit is contained in:
@ -100,6 +100,11 @@ export class ParagraphStyle extends Style {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public underline(underlineType?: string, color?: string): ParagraphStyle {
|
||||||
|
this.addRunProperty(new formatting.Underline(underlineType, color));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public color(color: string): ParagraphStyle {
|
public color(color: string): ParagraphStyle {
|
||||||
this.addRunProperty(new formatting.Color(color));
|
this.addRunProperty(new formatting.Color(color));
|
||||||
return this;
|
return this;
|
||||||
|
@ -235,6 +235,53 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#underline", () => {
|
||||||
|
it("should set underline to 'single' if no arguments are given", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.underline();
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||||
|
{"w:pPr": [{_attr: {}}]},
|
||||||
|
{"w:rPr": [
|
||||||
|
{"w:u": [{_attr: {"w:val": "single"}}]},
|
||||||
|
]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should set the style if given", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.underline("double");
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||||
|
{"w:pPr": [{_attr: {}}]},
|
||||||
|
{"w:rPr": [
|
||||||
|
{"w:u": [{_attr: {"w:val": "double"}}]},
|
||||||
|
]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should set the style and color if given", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.underline("double", "005599");
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||||
|
{"w:pPr": [{_attr: {}}]},
|
||||||
|
{"w:rPr": [
|
||||||
|
{"w:u": [{_attr: {"w:val": "double", "w:color": "005599"}}]},
|
||||||
|
]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("#color", () => {
|
it("#color", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId")
|
||||||
.color("123456");
|
.color("123456");
|
||||||
|
Reference in New Issue
Block a user