Add back default styles
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { DocumentAttributes } from "../document/document-attributes";
|
||||
import { Styles } from "./styles";
|
||||
import { IStylesOptions } from "./styles";
|
||||
|
||||
import { DocumentDefaults } from "./defaults";
|
||||
import {
|
||||
@ -18,7 +18,7 @@ import {
|
||||
} from "./style";
|
||||
|
||||
export class DefaultStylesFactory {
|
||||
public newInstance(): Styles {
|
||||
public newInstance(): IStylesOptions {
|
||||
const documentAttributes = new DocumentAttributes({
|
||||
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
||||
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||
@ -27,7 +27,7 @@ export class DefaultStylesFactory {
|
||||
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
||||
Ignorable: "w14 w15",
|
||||
});
|
||||
const styles = new Styles({
|
||||
return {
|
||||
initialStyles: documentAttributes,
|
||||
importedStyles: [
|
||||
new DocumentDefaults(),
|
||||
@ -76,9 +76,6 @@ export class DefaultStylesFactory {
|
||||
new FootnoteText({}),
|
||||
new FootnoteTextChar({}),
|
||||
],
|
||||
});
|
||||
styles.createDocumentDefaults();
|
||||
|
||||
return styles;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
import { BaseXmlComponent, ImportedXmlComponent, XmlComponent } from "file/xml-components";
|
||||
|
||||
import { DocumentDefaults } from "./defaults";
|
||||
import { CharacterStyle, ParagraphStyle } from "./style";
|
||||
import { ICharacterStyleOptions } from "./style/character-style";
|
||||
import { IParagraphStyleOptions } from "./style/paragraph-style";
|
||||
export * from "./border";
|
||||
|
||||
interface IStylesOptions {
|
||||
export interface IStylesOptions {
|
||||
readonly initialStyles?: BaseXmlComponent;
|
||||
readonly paragraphStyles?: IParagraphStyleOptions[];
|
||||
readonly characterStyles?: ICharacterStyleOptions[];
|
||||
@ -21,6 +20,12 @@ export class Styles extends XmlComponent {
|
||||
this.root.push(options.initialStyles);
|
||||
}
|
||||
|
||||
if (options.importedStyles) {
|
||||
for (const style of options.importedStyles) {
|
||||
this.root.push(style);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.paragraphStyles) {
|
||||
for (const style of options.paragraphStyles) {
|
||||
this.root.push(new ParagraphStyle(style));
|
||||
@ -32,17 +37,5 @@ export class Styles extends XmlComponent {
|
||||
this.root.push(new CharacterStyle(style));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.importedStyles) {
|
||||
for (const style of options.importedStyles) {
|
||||
this.root.push(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public createDocumentDefaults(): DocumentDefaults {
|
||||
const defaults = new DocumentDefaults();
|
||||
this.root.push(defaults);
|
||||
return defaults;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user