added #font method to paragraph styles
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import { Attributes, XmlComponent } from "../xml-components";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
export { Underline } from "./underline";
|
export { Underline } from "./underline";
|
||||||
export { SubScript, SuperScript } from "./script";
|
export { SubScript, SuperScript } from "./script";
|
||||||
|
export { RunFonts } from "./run-fonts";
|
||||||
|
|
||||||
export class Bold extends XmlComponent {
|
export class Bold extends XmlComponent {
|
||||||
|
|
||||||
|
@ -131,6 +131,13 @@ export class ParagraphStyle extends Style {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public font(fontName: string): ParagraphStyle {
|
||||||
|
this.addRunProperty(new formatting.RunFonts(fontName));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------- Paragraph formatting ------------------------ //
|
||||||
|
|
||||||
public indent(left: number, hanging?: number): ParagraphStyle {
|
public indent(left: number, hanging?: number): ParagraphStyle {
|
||||||
this.addParagraphProperty(new Indent(left, hanging));
|
this.addParagraphProperty(new Indent(left, hanging));
|
||||||
return this;
|
return this;
|
||||||
|
@ -320,6 +320,19 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("#font", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.font("Times");
|
||||||
|
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:rFonts": [{_attr: {"w:ascii": "Times", "w:hAnsi": "Times"}}]}]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("#bold", () => {
|
it("#bold", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId")
|
||||||
.bold();
|
.bold();
|
||||||
|
Reference in New Issue
Block a user