added #SubScript and #SuperScript methods to ParagraphStyle
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
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 class Bold extends XmlComponent {
|
export class Bold extends XmlComponent {
|
||||||
|
|
||||||
|
@ -111,6 +111,16 @@ export class ParagraphStyle extends Style {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public subScript(): ParagraphStyle {
|
||||||
|
this.addRunProperty(new formatting.SubScript());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public superScript(): ParagraphStyle {
|
||||||
|
this.addRunProperty(new formatting.SuperScript());
|
||||||
|
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;
|
||||||
|
@ -290,6 +290,36 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("#subScript", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.subScript();
|
||||||
|
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:vertAlign": [{_attr: {"w:val": "subscript"}}]},
|
||||||
|
]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("#superScript", () => {
|
||||||
|
const style = new ParagraphStyle("myStyleId")
|
||||||
|
.superScript();
|
||||||
|
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:vertAlign": [{_attr: {"w:val": "superscript"}}]},
|
||||||
|
]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("#bold", () => {
|
it("#bold", () => {
|
||||||
const style = new ParagraphStyle("myStyleId")
|
const style = new ParagraphStyle("myStyleId")
|
||||||
.bold();
|
.bold();
|
||||||
|
Reference in New Issue
Block a user