Added character spacing attribute
This commit is contained in:
@ -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");
|
||||||
|
@ -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 {
|
||||||
|
@ -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);
|
||||||
|
Reference in New Issue
Block a user