Merge pull request #1163 from anti-the-social/attaching-numbering-to-custom-style
Attaching numbering to custom style
This commit is contained in:
@ -15,6 +15,7 @@ import {
|
|||||||
TableRow,
|
TableRow,
|
||||||
TabStopPosition,
|
TabStopPosition,
|
||||||
UnderlineType,
|
UnderlineType,
|
||||||
|
LevelFormat,
|
||||||
} from "../build";
|
} from "../build";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
@ -51,6 +52,19 @@ const table = new Table({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
|
numbering:{
|
||||||
|
config:[{
|
||||||
|
reference: 'ref1',
|
||||||
|
levels: [
|
||||||
|
{
|
||||||
|
level: 0,
|
||||||
|
format: LevelFormat.DECIMAL,
|
||||||
|
text: '%1)',
|
||||||
|
start: 50,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}]
|
||||||
|
},
|
||||||
styles: {
|
styles: {
|
||||||
default: {
|
default: {
|
||||||
heading1: {
|
heading1: {
|
||||||
@ -155,6 +169,28 @@ const doc = new Document({
|
|||||||
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
|
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "numberedPara",
|
||||||
|
name: "Numbered Para",
|
||||||
|
basedOn: "Normal",
|
||||||
|
next: "Normal",
|
||||||
|
quickFormat: true,
|
||||||
|
run: {
|
||||||
|
font: "Calibri",
|
||||||
|
size: 26,
|
||||||
|
bold: true,
|
||||||
|
},
|
||||||
|
paragraph: {
|
||||||
|
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
|
||||||
|
rightTabStop: TabStopPosition.MAX,
|
||||||
|
leftTabStop: 453.543307087,
|
||||||
|
numbering : {
|
||||||
|
reference: 'ref1',
|
||||||
|
instance: 0,
|
||||||
|
level: 0,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
sections: [
|
sections: [
|
||||||
@ -260,6 +296,14 @@ const doc = new Document({
|
|||||||
text: "Test 2",
|
text: "Test 2",
|
||||||
style: "normalPara2",
|
style: "normalPara2",
|
||||||
}),
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "Numbered paragraph that has numbering attached to custom styles",
|
||||||
|
style: "numberedPara",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "Numbered para would show up in the styles pane at Word",
|
||||||
|
style: "numberedPara",
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -123,7 +123,8 @@ export class Compiler {
|
|||||||
path: "word/document.xml",
|
path: "word/document.xml",
|
||||||
},
|
},
|
||||||
Styles: {
|
Styles: {
|
||||||
data: xml(
|
data: (() => {
|
||||||
|
const xmlStyles = xml(
|
||||||
this.formatter.format(file.Styles, {
|
this.formatter.format(file.Styles, {
|
||||||
viewWrapper: file.Document,
|
viewWrapper: file.Document,
|
||||||
file,
|
file,
|
||||||
@ -135,7 +136,10 @@ export class Compiler {
|
|||||||
encoding: "UTF-8",
|
encoding: "UTF-8",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
),
|
);
|
||||||
|
const referencedXmlStyles = this.numberingReplacer.replace(xmlStyles, file.Numbering.ConcreteNumbering);
|
||||||
|
return referencedXmlStyles;
|
||||||
|
})(),
|
||||||
path: "word/styles.xml",
|
path: "word/styles.xml",
|
||||||
},
|
},
|
||||||
Properties: {
|
Properties: {
|
||||||
|
@ -24,6 +24,12 @@ export interface IParagraphStylePropertiesOptions {
|
|||||||
readonly keepNext?: boolean;
|
readonly keepNext?: boolean;
|
||||||
readonly keepLines?: boolean;
|
readonly keepLines?: boolean;
|
||||||
readonly outlineLevel?: number;
|
readonly outlineLevel?: number;
|
||||||
|
readonly numbering?: {
|
||||||
|
readonly reference: string;
|
||||||
|
readonly level: number;
|
||||||
|
readonly instance?: number;
|
||||||
|
readonly custom?: boolean;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOptions {
|
export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOptions {
|
||||||
@ -40,12 +46,6 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp
|
|||||||
readonly bullet?: {
|
readonly bullet?: {
|
||||||
readonly level: number;
|
readonly level: number;
|
||||||
};
|
};
|
||||||
readonly numbering?: {
|
|
||||||
readonly reference: string;
|
|
||||||
readonly level: number;
|
|
||||||
readonly instance?: number;
|
|
||||||
readonly custom?: boolean;
|
|
||||||
};
|
|
||||||
readonly shading?: IShadingAttributesProperties;
|
readonly shading?: IShadingAttributesProperties;
|
||||||
readonly widowControl?: boolean;
|
readonly widowControl?: boolean;
|
||||||
readonly frame?: IFrameOptions;
|
readonly frame?: IFrameOptions;
|
||||||
|
Reference in New Issue
Block a user