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,
|
||||
TabStopPosition,
|
||||
UnderlineType,
|
||||
LevelFormat,
|
||||
} from "../build";
|
||||
|
||||
const table = new Table({
|
||||
@ -51,6 +52,19 @@ const table = new Table({
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
numbering:{
|
||||
config:[{
|
||||
reference: 'ref1',
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: '%1)',
|
||||
start: 50,
|
||||
}
|
||||
],
|
||||
}]
|
||||
},
|
||||
styles: {
|
||||
default: {
|
||||
heading1: {
|
||||
@ -155,6 +169,28 @@ const doc = new Document({
|
||||
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: [
|
||||
@ -260,6 +296,14 @@ const doc = new Document({
|
||||
text: "Test 2",
|
||||
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,19 +123,23 @@ export class Compiler {
|
||||
path: "word/document.xml",
|
||||
},
|
||||
Styles: {
|
||||
data: xml(
|
||||
this.formatter.format(file.Styles, {
|
||||
viewWrapper: file.Document,
|
||||
file,
|
||||
}),
|
||||
{
|
||||
indent: prettify,
|
||||
declaration: {
|
||||
standalone: "yes",
|
||||
encoding: "UTF-8",
|
||||
data: (() => {
|
||||
const xmlStyles = xml(
|
||||
this.formatter.format(file.Styles, {
|
||||
viewWrapper: file.Document,
|
||||
file,
|
||||
}),
|
||||
{
|
||||
indent: prettify,
|
||||
declaration: {
|
||||
standalone: "yes",
|
||||
encoding: "UTF-8",
|
||||
},
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
const referencedXmlStyles = this.numberingReplacer.replace(xmlStyles, file.Numbering.ConcreteNumbering);
|
||||
return referencedXmlStyles;
|
||||
})(),
|
||||
path: "word/styles.xml",
|
||||
},
|
||||
Properties: {
|
||||
|
@ -24,6 +24,12 @@ export interface IParagraphStylePropertiesOptions {
|
||||
readonly keepNext?: boolean;
|
||||
readonly keepLines?: boolean;
|
||||
readonly outlineLevel?: number;
|
||||
readonly numbering?: {
|
||||
readonly reference: string;
|
||||
readonly level: number;
|
||||
readonly instance?: number;
|
||||
readonly custom?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOptions {
|
||||
@ -40,12 +46,6 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp
|
||||
readonly bullet?: {
|
||||
readonly level: number;
|
||||
};
|
||||
readonly numbering?: {
|
||||
readonly reference: string;
|
||||
readonly level: number;
|
||||
readonly instance?: number;
|
||||
readonly custom?: boolean;
|
||||
};
|
||||
readonly shading?: IShadingAttributesProperties;
|
||||
readonly widowControl?: boolean;
|
||||
readonly frame?: IFrameOptions;
|
||||
|
Reference in New Issue
Block a user