move file options.defaultStyles to options.styles.default
This commit is contained in:
@ -17,55 +17,55 @@ import {
|
||||
} from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
defaultStyles: {
|
||||
heading1: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 52,
|
||||
bold: true,
|
||||
color: "000000",
|
||||
underline: {
|
||||
type: UnderlineType.SINGLE,
|
||||
styles: {
|
||||
default: {
|
||||
heading1: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 52,
|
||||
bold: true,
|
||||
color: "000000",
|
||||
underline: {
|
||||
type: UnderlineType.SINGLE,
|
||||
color: "000000",
|
||||
},
|
||||
},
|
||||
paragraph: {
|
||||
alignment: AlignmentType.CENTER,
|
||||
spacing: { line: 340 },
|
||||
},
|
||||
},
|
||||
paragraph: {
|
||||
alignment: AlignmentType.CENTER,
|
||||
spacing: { line: 340 },
|
||||
heading2: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 26,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: { line: 340 },
|
||||
},
|
||||
},
|
||||
heading3: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 26,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: { line: 276 },
|
||||
},
|
||||
},
|
||||
heading4: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 26,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
alignment: AlignmentType.JUSTIFIED,
|
||||
},
|
||||
},
|
||||
},
|
||||
heading2: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 26,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: { line: 340 },
|
||||
},
|
||||
},
|
||||
heading3: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 26,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: { line: 276 },
|
||||
},
|
||||
},
|
||||
heading4: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 26,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
alignment: AlignmentType.JUSTIFIED,
|
||||
},
|
||||
},
|
||||
},
|
||||
styles: {
|
||||
paragraphStyles: [
|
||||
{
|
||||
id: "normalPara",
|
||||
|
@ -7,43 +7,43 @@ const doc = new Document({
|
||||
creator: "Clippy",
|
||||
title: "Sample Document",
|
||||
description: "A brief example of using docx",
|
||||
defaultStyles: {
|
||||
heading1: {
|
||||
run: {
|
||||
size: 28,
|
||||
bold: true,
|
||||
italics: true,
|
||||
color: "red",
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
after: 120,
|
||||
},
|
||||
},
|
||||
},
|
||||
heading2: {
|
||||
run: {
|
||||
size: 26,
|
||||
bold: true,
|
||||
underline: {
|
||||
type: UnderlineType.DOUBLE,
|
||||
color: "FF0000",
|
||||
},
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
before: 240,
|
||||
after: 120,
|
||||
},
|
||||
},
|
||||
},
|
||||
listParagraph: {
|
||||
run: {
|
||||
color: '#FF0000'
|
||||
}
|
||||
}
|
||||
},
|
||||
styles: {
|
||||
default: {
|
||||
heading1: {
|
||||
run: {
|
||||
size: 28,
|
||||
bold: true,
|
||||
italics: true,
|
||||
color: "red",
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
after: 120,
|
||||
},
|
||||
},
|
||||
},
|
||||
heading2: {
|
||||
run: {
|
||||
size: 26,
|
||||
bold: true,
|
||||
underline: {
|
||||
type: UnderlineType.DOUBLE,
|
||||
color: "FF0000",
|
||||
},
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
before: 240,
|
||||
after: 120,
|
||||
},
|
||||
},
|
||||
},
|
||||
listParagraph: {
|
||||
run: {
|
||||
color: '#FF0000'
|
||||
}
|
||||
}
|
||||
},
|
||||
paragraphStyles: [
|
||||
{
|
||||
id: "aside",
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { IDefaultStylesOptions } from "file/styles/factory";
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { IDocumentBackgroundOptions } from "../document";
|
||||
|
||||
@ -29,7 +28,6 @@ export interface IPropertiesOptions {
|
||||
readonly revision?: string;
|
||||
readonly externalStyles?: string;
|
||||
readonly styles?: IStylesOptions;
|
||||
readonly defaultStyles?: IDefaultStylesOptions;
|
||||
readonly numbering?: INumberingOptions;
|
||||
readonly footnotes?: Paragraph[];
|
||||
readonly hyperlinks?: {
|
||||
|
@ -106,14 +106,14 @@ export class File {
|
||||
this.styles = stylesFactory.newInstance(options.externalStyles);
|
||||
} else if (options.styles) {
|
||||
const stylesFactory = new DefaultStylesFactory();
|
||||
const defaultStyles = stylesFactory.newInstance(options.defaultStyles);
|
||||
const defaultStyles = stylesFactory.newInstance(options.styles.default);
|
||||
this.styles = new Styles({
|
||||
...defaultStyles,
|
||||
...options.styles,
|
||||
});
|
||||
} else {
|
||||
const stylesFactory = new DefaultStylesFactory();
|
||||
this.styles = new Styles(stylesFactory.newInstance(options.defaultStyles));
|
||||
this.styles = new Styles(stylesFactory.newInstance());
|
||||
}
|
||||
|
||||
this.addDefaultRelationships();
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { IDefaultStylesOptions } from "file/styles/factory";
|
||||
import { BaseXmlComponent, ImportedXmlComponent, XmlComponent } from "file/xml-components";
|
||||
|
||||
import { StyleForCharacter, StyleForParagraph } from "./style";
|
||||
import { ICharacterStyleOptions } from "./style/character-style";
|
||||
import { IParagraphStyleOptions } from "./style/paragraph-style";
|
||||
export * from "./border";
|
||||
|
||||
export interface IStylesOptions {
|
||||
readonly default?: IDefaultStylesOptions;
|
||||
readonly initialStyles?: BaseXmlComponent;
|
||||
readonly paragraphStyles?: IParagraphStyleOptions[];
|
||||
readonly characterStyles?: ICharacterStyleOptions[];
|
||||
|
Reference in New Issue
Block a user