#713 Update chinese demo and refactor
This commit is contained in:
@ -425,4 +425,25 @@ describe("File", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should create default run and paragraph property document defaults", () => {
|
||||
const doc = new File({
|
||||
styles: {
|
||||
default: {},
|
||||
},
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(doc.Styles);
|
||||
|
||||
expect(tree["w:styles"][1]).to.deep.equal({
|
||||
"w:docDefaults": [
|
||||
{
|
||||
"w:rPrDefault": {},
|
||||
},
|
||||
{
|
||||
"w:pPrDefault": {},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -13,11 +13,11 @@ export class DocumentDefaults extends XmlComponent {
|
||||
private readonly runPropertiesDefaults: RunPropertiesDefaults;
|
||||
private readonly paragraphPropertiesDefaults: ParagraphPropertiesDefaults;
|
||||
|
||||
constructor(options?: IDocumentDefaultsOptions) {
|
||||
constructor(options: IDocumentDefaultsOptions) {
|
||||
super("w:docDefaults");
|
||||
|
||||
this.runPropertiesDefaults = new RunPropertiesDefaults(options && options.run);
|
||||
this.paragraphPropertiesDefaults = new ParagraphPropertiesDefaults(options && options.paragraph);
|
||||
this.runPropertiesDefaults = new RunPropertiesDefaults(options.run);
|
||||
this.paragraphPropertiesDefaults = new ParagraphPropertiesDefaults(options.paragraph);
|
||||
|
||||
this.root.push(this.runPropertiesDefaults);
|
||||
this.root.push(this.paragraphPropertiesDefaults);
|
||||
|
@ -2,11 +2,9 @@ import { IRunStylePropertiesOptions, RunProperties } from "file/paragraph/run/pr
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
|
||||
export class RunPropertiesDefaults extends XmlComponent {
|
||||
private readonly properties: RunProperties;
|
||||
|
||||
constructor(options?: IRunStylePropertiesOptions) {
|
||||
super("w:rPrDefault");
|
||||
this.properties = new RunProperties(options);
|
||||
this.root.push(this.properties);
|
||||
|
||||
this.root.push(new RunProperties(options));
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ export class DefaultStylesFactory {
|
||||
return {
|
||||
initialStyles: documentAttributes,
|
||||
importedStyles: [
|
||||
new DocumentDefaults(options.document),
|
||||
new DocumentDefaults(options.document ?? {}),
|
||||
new TitleStyle({
|
||||
run: {
|
||||
size: 56,
|
||||
|
Reference in New Issue
Block a user