Merge pull request #728 from dolanmiu/feat/strong-style
Add strong default style
This commit is contained in:
@ -40,9 +40,9 @@ const doc = new Document({
|
||||
},
|
||||
listParagraph: {
|
||||
run: {
|
||||
color: '#FF0000'
|
||||
}
|
||||
}
|
||||
color: "#FF0000",
|
||||
},
|
||||
},
|
||||
},
|
||||
paragraphStyles: [
|
||||
{
|
||||
@ -161,6 +161,18 @@ doc.addSection({
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
style: "Strong",
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Strong Style",
|
||||
}),
|
||||
new TextRun({
|
||||
text:
|
||||
" - Very strong.",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -16,6 +16,7 @@ import {
|
||||
IBaseCharacterStyleOptions,
|
||||
IBaseParagraphStyleOptions,
|
||||
ListParagraph,
|
||||
StrongStyle,
|
||||
TitleStyle,
|
||||
} from "./style";
|
||||
|
||||
@ -28,6 +29,7 @@ export interface IDefaultStylesOptions {
|
||||
readonly heading4?: IBaseParagraphStyleOptions;
|
||||
readonly heading5?: IBaseParagraphStyleOptions;
|
||||
readonly heading6?: IBaseParagraphStyleOptions;
|
||||
readonly strong?: IBaseParagraphStyleOptions;
|
||||
readonly listParagraph?: IBaseParagraphStyleOptions;
|
||||
readonly hyperlink?: IBaseCharacterStyleOptions;
|
||||
readonly footnoteReference?: IBaseCharacterStyleOptions;
|
||||
@ -95,6 +97,12 @@ export class DefaultStylesFactory {
|
||||
},
|
||||
...options.heading6,
|
||||
}),
|
||||
new StrongStyle({
|
||||
run: {
|
||||
bold: true,
|
||||
},
|
||||
...options.strong,
|
||||
}),
|
||||
new ListParagraph(options.listParagraph || {}),
|
||||
new HyperlinkStyle(options.hyperlink || {}),
|
||||
new FootnoteReferenceStyle(options.footnoteReference || {}),
|
||||
|
@ -120,6 +120,20 @@ describe("Default Styles", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("StrongStyle#constructor", () => {
|
||||
const style = new defaultStyles.StrongStyle({});
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "Strong" } },
|
||||
{ "w:name": { _attr: { "w:val": "Strong" } } },
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:next": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:qFormat": EMPTY_OBJECT },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("ListParagraph#constructor", () => {
|
||||
const style = new defaultStyles.ListParagraph({});
|
||||
const tree = new Formatter().format(style);
|
||||
|
@ -84,6 +84,16 @@ export class Heading6Style extends HeadingStyle {
|
||||
}
|
||||
}
|
||||
|
||||
export class StrongStyle extends HeadingStyle {
|
||||
constructor(options: IBaseParagraphStyleOptions) {
|
||||
super({
|
||||
...options,
|
||||
id: "Strong",
|
||||
name: "Strong",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class ListParagraph extends StyleForParagraph {
|
||||
constructor(options: IBaseParagraphStyleOptions) {
|
||||
super({
|
||||
|
Reference in New Issue
Block a user