2018-05-06 03:19:36 +01:00
|
|
|
import { DocumentAttributes } from "../document/document-attributes";
|
2019-10-04 02:37:22 +01:00
|
|
|
import { IStylesOptions } from "./styles";
|
2018-03-28 14:54:07 +02:00
|
|
|
|
2020-11-24 13:30:26 -06:00
|
|
|
import { DocumentDefaults, IDocumentDefaultsOptions } from "./defaults";
|
2017-03-09 09:45:01 +01:00
|
|
|
import {
|
2018-06-28 03:01:25 +01:00
|
|
|
FootnoteReferenceStyle,
|
|
|
|
FootnoteText,
|
|
|
|
FootnoteTextChar,
|
2018-01-23 01:33:12 +00:00
|
|
|
Heading1Style,
|
|
|
|
Heading2Style,
|
|
|
|
Heading3Style,
|
|
|
|
Heading4Style,
|
|
|
|
Heading5Style,
|
|
|
|
Heading6Style,
|
2018-05-06 22:23:04 -05:00
|
|
|
HyperlinkStyle,
|
2020-11-24 13:30:26 -06:00
|
|
|
IBaseCharacterStyleOptions,
|
|
|
|
IBaseParagraphStyleOptions,
|
2018-01-23 01:33:12 +00:00
|
|
|
ListParagraph,
|
|
|
|
TitleStyle,
|
2017-03-09 09:45:01 +01:00
|
|
|
} from "./style";
|
2016-05-09 03:44:16 +01:00
|
|
|
|
2020-11-24 13:30:26 -06:00
|
|
|
export interface IDefaultStylesOptions {
|
|
|
|
readonly document?: IDocumentDefaultsOptions;
|
|
|
|
readonly title?: IBaseParagraphStyleOptions;
|
|
|
|
readonly heading1?: IBaseParagraphStyleOptions;
|
|
|
|
readonly heading2?: IBaseParagraphStyleOptions;
|
|
|
|
readonly heading3?: IBaseParagraphStyleOptions;
|
|
|
|
readonly heading4?: IBaseParagraphStyleOptions;
|
|
|
|
readonly heading5?: IBaseParagraphStyleOptions;
|
|
|
|
readonly heading6?: IBaseParagraphStyleOptions;
|
|
|
|
readonly listParagraph?: IBaseParagraphStyleOptions;
|
|
|
|
readonly hyperlink?: IBaseCharacterStyleOptions;
|
|
|
|
readonly footnoteReference?: IBaseCharacterStyleOptions;
|
|
|
|
readonly footnoteText?: IBaseParagraphStyleOptions;
|
|
|
|
readonly footnoteTextChar?: IBaseCharacterStyleOptions;
|
|
|
|
}
|
|
|
|
|
2016-05-09 03:44:16 +01:00
|
|
|
export class DefaultStylesFactory {
|
2020-11-24 13:30:26 -06:00
|
|
|
public newInstance(options: IDefaultStylesOptions = {}): IStylesOptions {
|
2018-03-28 14:54:07 +02:00
|
|
|
const documentAttributes = new DocumentAttributes({
|
|
|
|
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
|
|
|
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
|
|
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
|
|
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
|
|
|
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
|
|
|
Ignorable: "w14 w15",
|
|
|
|
});
|
2019-10-04 02:37:22 +01:00
|
|
|
return {
|
2019-10-04 01:20:41 +01:00
|
|
|
initialStyles: documentAttributes,
|
|
|
|
importedStyles: [
|
2020-11-24 13:30:26 -06:00
|
|
|
new DocumentDefaults(options.document),
|
2019-10-04 01:20:41 +01:00
|
|
|
new TitleStyle({
|
|
|
|
run: {
|
|
|
|
size: 56,
|
|
|
|
},
|
2020-11-24 13:30:26 -06:00
|
|
|
...options.title,
|
2019-10-04 01:20:41 +01:00
|
|
|
}),
|
|
|
|
new Heading1Style({
|
|
|
|
run: {
|
|
|
|
color: "2E74B5",
|
|
|
|
size: 32,
|
|
|
|
},
|
2020-11-24 13:30:26 -06:00
|
|
|
...options.heading1,
|
2019-10-04 01:20:41 +01:00
|
|
|
}),
|
|
|
|
new Heading2Style({
|
|
|
|
run: {
|
|
|
|
color: "2E74B5",
|
|
|
|
size: 26,
|
|
|
|
},
|
2020-11-24 13:30:26 -06:00
|
|
|
...options.heading2,
|
2019-10-04 01:20:41 +01:00
|
|
|
}),
|
|
|
|
new Heading3Style({
|
|
|
|
run: {
|
|
|
|
color: "1F4D78",
|
|
|
|
size: 24,
|
|
|
|
},
|
2020-11-24 13:30:26 -06:00
|
|
|
...options.heading3,
|
2019-10-04 01:20:41 +01:00
|
|
|
}),
|
|
|
|
new Heading4Style({
|
|
|
|
run: {
|
|
|
|
color: "2E74B5",
|
|
|
|
italics: true,
|
|
|
|
},
|
2020-11-24 13:30:26 -06:00
|
|
|
...options.heading4,
|
2019-10-04 01:20:41 +01:00
|
|
|
}),
|
|
|
|
new Heading5Style({
|
|
|
|
run: {
|
|
|
|
color: "2E74B5",
|
|
|
|
},
|
2020-11-24 13:30:26 -06:00
|
|
|
...options.heading5,
|
2019-10-04 01:20:41 +01:00
|
|
|
}),
|
|
|
|
new Heading6Style({
|
|
|
|
run: {
|
|
|
|
color: "1F4D78",
|
|
|
|
},
|
2020-11-24 13:30:26 -06:00
|
|
|
...options.heading6,
|
2019-10-04 01:20:41 +01:00
|
|
|
}),
|
2020-11-24 13:30:26 -06:00
|
|
|
new ListParagraph(options.listParagraph || {}),
|
|
|
|
new HyperlinkStyle(options.hyperlink || {}),
|
|
|
|
new FootnoteReferenceStyle(options.footnoteReference || {}),
|
|
|
|
new FootnoteText(options.footnoteText || {}),
|
|
|
|
new FootnoteTextChar(options.footnoteTextChar || {}),
|
2019-10-04 01:20:41 +01:00
|
|
|
],
|
2019-10-04 02:37:22 +01:00
|
|
|
};
|
2016-05-09 03:44:16 +01:00
|
|
|
}
|
2017-03-10 08:52:47 +01:00
|
|
|
}
|