Added character spacing attribute

This commit is contained in:
bre7
2018-09-19 18:41:55 -03:00
parent a9c69664c7
commit 6da3efdacc
3 changed files with 30 additions and 0 deletions

View File

@ -25,6 +25,17 @@ export class BoldComplexScript extends XmlComponent {
} }
} }
export class CharacterSpacing extends XmlComponent {
constructor(value: number) {
super("w:spacing");
this.root.push(
new Attributes({
val: value,
}),
);
}
}
export class Italics extends XmlComponent { export class Italics extends XmlComponent {
constructor() { constructor() {
super("w:i"); super("w:i");

View File

@ -133,6 +133,11 @@ export class ParagraphStyle extends Style {
return this; return this;
} }
public characterSpacing(value: number): ParagraphStyle {
this.addRunProperty(new formatting.CharacterSpacing(value));
return this;
}
// --------------------- Paragraph formatting ------------------------ // // --------------------- Paragraph formatting ------------------------ //
public center(): ParagraphStyle { public center(): ParagraphStyle {

View File

@ -219,6 +219,20 @@ describe("ParagraphStyle", () => {
}); });
}); });
it("#character spacing", () => {
const style = new ParagraphStyle("myStyleId").characterSpacing(24);
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:spacing": [{ _attr: { "w:val": 24 } }] }],
},
],
});
});
it("#left", () => { it("#left", () => {
const style = new ParagraphStyle("myStyleId").left(); const style = new ParagraphStyle("myStyleId").left();
const tree = new Formatter().format(style); const tree = new Formatter().format(style);