diff --git a/src/file/styles/style/character-style.spec.ts b/src/file/styles/style/character-style.spec.ts index 1556aae109..727b7f3a3f 100644 --- a/src/file/styles/style/character-style.spec.ts +++ b/src/file/styles/style/character-style.spec.ts @@ -243,6 +243,56 @@ describe("CharacterStyle", () => { }); }); + it("#bold", () => { + const style = new CharacterStyle("myStyleId").bold(); + const tree = new Formatter().format(style); + expect(tree).to.deep.equal({ + "w:style": [ + { _attr: { "w:type": "character", "w:styleId": "myStyleId" } }, + { + "w:rPr": [{ "w:b": [{ _attr: { "w:val": true } }] }], + }, + { + "w:uiPriority": [ + { + _attr: { + "w:val": "99", + }, + }, + ], + }, + { + "w:unhideWhenUsed": [], + }, + ], + }); + }); + + it("#italics", () => { + const style = new CharacterStyle("myStyleId").italics(); + const tree = new Formatter().format(style); + expect(tree).to.deep.equal({ + "w:style": [ + { _attr: { "w:type": "character", "w:styleId": "myStyleId" } }, + { + "w:rPr": [{ "w:i": [{ _attr: { "w:val": true } }] }], + }, + { + "w:uiPriority": [ + { + _attr: { + "w:val": "99", + }, + }, + ], + }, + { + "w:unhideWhenUsed": [], + }, + ], + }); + }); + it("#link", () => { const style = new CharacterStyle("myStyleId").link("MyLink"); const tree = new Formatter().format(style); diff --git a/src/file/styles/style/character-style.ts b/src/file/styles/style/character-style.ts index f7354ae788..c7f677b331 100644 --- a/src/file/styles/style/character-style.ts +++ b/src/file/styles/style/character-style.ts @@ -29,6 +29,14 @@ export class CharacterStyle extends Style { return this.addRunProperty(new formatting.Color(color)); } + public bold(): CharacterStyle { + return this.addRunProperty(new formatting.Bold()); + } + + public italics(): CharacterStyle { + return this.addRunProperty(new formatting.Italics()); + } + public underline(underlineType?: string, color?: string): CharacterStyle { return this.addRunProperty(new formatting.Underline(underlineType, color)); }