Declarative styles

This commit is contained in:
Dolan
2019-10-04 01:20:41 +01:00
parent 2536fbe752
commit 591b2f4e04
20 changed files with 920 additions and 484 deletions

View File

@ -1,7 +1,7 @@
import { DocumentAttributes } from "../document/document-attributes";
import { Color, Italics, Size } from "../paragraph/run/formatting";
import { Styles } from "./";
import { Styles } from "./styles";
import { DocumentDefaults } from "./defaults";
import {
FootnoteReferenceStyle,
FootnoteText,
@ -27,57 +27,58 @@ export class DefaultStylesFactory {
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
Ignorable: "w14 w15",
});
const styles = new Styles(documentAttributes);
const styles = new Styles({
initialStyles: documentAttributes,
importedStyles: [
new DocumentDefaults(),
new TitleStyle({
run: {
size: 56,
},
}),
new Heading1Style({
run: {
color: "2E74B5",
size: 32,
},
}),
new Heading2Style({
run: {
color: "2E74B5",
size: 26,
},
}),
new Heading3Style({
run: {
color: "1F4D78",
size: 24,
},
}),
new Heading4Style({
run: {
color: "2E74B5",
italics: true,
},
}),
new Heading5Style({
run: {
color: "2E74B5",
},
}),
new Heading6Style({
run: {
color: "1F4D78",
},
}),
new ListParagraph({}),
new HyperlinkStyle({}),
new FootnoteReferenceStyle({}),
new FootnoteText({}),
new FootnoteTextChar({}),
],
});
styles.createDocumentDefaults();
const titleStyle = new TitleStyle();
titleStyle.addRunProperty(new Size(56));
styles.push(titleStyle);
const heading1Style = new Heading1Style();
heading1Style.addRunProperty(new Color("2E74B5"));
heading1Style.addRunProperty(new Size(32));
styles.push(heading1Style);
const heading2Style = new Heading2Style();
heading2Style.addRunProperty(new Color("2E74B5"));
heading2Style.addRunProperty(new Size(26));
styles.push(heading2Style);
const heading3Style = new Heading3Style();
heading3Style.addRunProperty(new Color("1F4D78"));
heading3Style.addRunProperty(new Size(24));
styles.push(heading3Style);
const heading4Style = new Heading4Style();
heading4Style.addRunProperty(new Color("2E74B5"));
heading4Style.addRunProperty(new Italics());
styles.push(heading4Style);
const heading5Style = new Heading5Style();
heading5Style.addRunProperty(new Color("2E74B5"));
styles.push(heading5Style);
const heading6Style = new Heading6Style();
heading6Style.addRunProperty(new Color("1F4D78"));
styles.push(heading6Style);
const listParagraph = new ListParagraph();
// listParagraph.addParagraphProperty();
styles.push(listParagraph);
const hyperLinkStyle = new HyperlinkStyle();
styles.push(hyperLinkStyle);
const footnoteReferenceStyle = new FootnoteReferenceStyle();
styles.push(footnoteReferenceStyle);
const footnoteTextStyle = new FootnoteText();
styles.push(footnoteTextStyle);
const footnoteTextCharStyle = new FootnoteTextChar();
styles.push(footnoteTextCharStyle);
return styles;
}
}