Add work for custom level id

This commit is contained in:
Dolan
2019-11-06 20:54:39 +00:00
parent a622c210ef
commit 9b40b5e55e
7 changed files with 77 additions and 95 deletions

View File

@ -8,7 +8,7 @@ import { UnderlineType } from "../paragraph/run/underline";
import { ShadingType } from "../table"; import { ShadingType } from "../table";
import { AbstractNumbering } from "./abstract-numbering"; import { AbstractNumbering } from "./abstract-numbering";
describe.only("AbstractNumbering", () => { describe("AbstractNumbering", () => {
it("stores its ID at its .id property", () => { it("stores its ID at its .id property", () => {
const abstractNumbering = new AbstractNumbering(5, { const abstractNumbering = new AbstractNumbering(5, {
levels: [], levels: [],
@ -29,11 +29,11 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ _attr: { "w:ilvl": 3, "w15:tentative": 1 } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ _attr: { "w:ilvl": 3, "w15:tentative": 1 } });
expect(tree["w:lvl"]).to.include({ "w:start": { _attr: { "w:val": 1 } } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:start": { _attr: { "w:val": 1 } } });
expect(tree["w:lvl"]).to.include({ "w:lvlJc": { _attr: { "w:val": "end" } } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:lvlJc": { _attr: { "w:val": "end" } } });
expect(tree["w:lvl"]).to.include({ "w:numFmt": { _attr: { "w:val": "lowerLetter" } } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:numFmt": { _attr: { "w:val": "lowerLetter" } } });
expect(tree["w:lvl"]).to.include({ "w:lvlText": { _attr: { "w:val": "%1)" } } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:lvlText": { _attr: { "w:val": "%1)" } } });
}); });
it("uses 'start' as the default alignment", () => { it("uses 'start' as the default alignment", () => {
@ -47,11 +47,11 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ _attr: { "w:ilvl": 3, "w15:tentative": 1 } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ _attr: { "w:ilvl": 3, "w15:tentative": 1 } });
expect(tree["w:lvl"]).to.include({ "w:start": { _attr: { "w:val": 1 } } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:start": { _attr: { "w:val": 1 } } });
expect(tree["w:lvl"]).to.include({ "w:lvlJc": { _attr: { "w:val": "start" } } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:lvlJc": { _attr: { "w:val": "start" } } });
expect(tree["w:lvl"]).to.include({ "w:numFmt": { _attr: { "w:val": "lowerLetter" } } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:numFmt": { _attr: { "w:val": "lowerLetter" } } });
expect(tree["w:lvl"]).to.include({ "w:lvlText": { _attr: { "w:val": "%1)" } } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:lvlText": { _attr: { "w:val": "%1)" } } });
}); });
describe("formatting methods: paragraph properties", () => { describe("formatting methods: paragraph properties", () => {
@ -71,7 +71,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [{ "w:ind": { _attr: { "w:left": 720 } } }], "w:pPr": [{ "w:ind": { _attr: { "w:left": 720 } } }],
}); });
}); });
@ -92,7 +92,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [{ "w:spacing": { _attr: { "w:before": 50, "w:after": 150 } } }], "w:pPr": [{ "w:spacing": { _attr: { "w:before": 50, "w:after": 150 } } }],
}); });
}); });
@ -113,7 +113,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [{ "w:jc": { _attr: { "w:val": "center" } } }], "w:pPr": [{ "w:jc": { _attr: { "w:val": "center" } } }],
}); });
}); });
@ -134,7 +134,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [{ "w:jc": { _attr: { "w:val": "left" } } }], "w:pPr": [{ "w:jc": { _attr: { "w:val": "left" } } }],
}); });
}); });
@ -155,7 +155,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [{ "w:jc": { _attr: { "w:val": "right" } } }], "w:pPr": [{ "w:jc": { _attr: { "w:val": "right" } } }],
}); });
}); });
@ -176,7 +176,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [{ "w:jc": { _attr: { "w:val": "both" } } }], "w:pPr": [{ "w:jc": { _attr: { "w:val": "both" } } }],
}); });
}); });
@ -197,7 +197,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [ "w:pPr": [
{ {
"w:pBdr": [ "w:pBdr": [
@ -233,7 +233,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [ "w:pPr": [
{ {
"w:tabs": [{ "w:tab": { _attr: { "w:val": "left", "w:pos": 1200 } } }], "w:tabs": [{ "w:tab": { _attr: { "w:val": "left", "w:pos": 1200 } } }],
@ -258,7 +258,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [ "w:pPr": [
{ {
"w:tabs": [{ "w:tab": { _attr: { "w:val": "right", "w:pos": 9026 } } }], "w:tabs": [{ "w:tab": { _attr: { "w:val": "right", "w:pos": 9026 } } }],
@ -283,7 +283,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [{ "w:keepLines": EMPTY_OBJECT }], "w:pPr": [{ "w:keepLines": EMPTY_OBJECT }],
}); });
}); });
@ -304,7 +304,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:pPr": [{ "w:keepNext": EMPTY_OBJECT }], "w:pPr": [{ "w:keepNext": EMPTY_OBJECT }],
}); });
}); });
@ -327,7 +327,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:sz": { _attr: { "w:val": 24 } } }], "w:rPr": [{ "w:sz": { _attr: { "w:val": 24 } } }],
}); });
}); });
@ -348,7 +348,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:smallCaps": { _attr: { "w:val": true } } }], "w:rPr": [{ "w:smallCaps": { _attr: { "w:val": true } } }],
}); });
}); });
@ -369,7 +369,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:caps": { _attr: { "w:val": true } } }], "w:rPr": [{ "w:caps": { _attr: { "w:val": true } } }],
}); });
}); });
@ -391,7 +391,7 @@ describe.only("AbstractNumbering", () => {
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:strike": { _attr: { "w:val": true } } }], "w:rPr": [{ "w:strike": { _attr: { "w:val": true } } }],
}); });
}); });
@ -412,7 +412,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:dstrike": { _attr: { "w:val": true } } }], "w:rPr": [{ "w:dstrike": { _attr: { "w:val": true } } }],
}); });
}); });
@ -433,7 +433,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "subscript" } } }], "w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "subscript" } } }],
}); });
}); });
@ -454,7 +454,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "superscript" } } }], "w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "superscript" } } }],
}); });
}); });
@ -475,7 +475,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [ "w:rPr": [
{ "w:rFonts": { _attr: { "w:ascii": "Times", "w:cs": "Times", "w:eastAsia": "Times", "w:hAnsi": "Times" } } }, { "w:rFonts": { _attr: { "w:ascii": "Times", "w:cs": "Times", "w:eastAsia": "Times", "w:hAnsi": "Times" } } },
], ],
@ -498,7 +498,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:b": { _attr: { "w:val": true } } }], "w:rPr": [{ "w:b": { _attr: { "w:val": true } } }],
}); });
}); });
@ -519,7 +519,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:i": { _attr: { "w:val": true } } }], "w:rPr": [{ "w:i": { _attr: { "w:val": true } } }],
}); });
}); });
@ -540,7 +540,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:highlight": { _attr: { "w:val": "005599" } } }], "w:rPr": [{ "w:highlight": { _attr: { "w:val": "005599" } } }],
}); });
}); });
@ -565,7 +565,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }], "w:rPr": [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }],
}); });
}); });
@ -587,7 +587,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:u": { _attr: { "w:val": "single" } } }], "w:rPr": [{ "w:u": { _attr: { "w:val": "single" } } }],
}); });
}); });
@ -610,7 +610,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:u": { _attr: { "w:val": "double" } } }], "w:rPr": [{ "w:u": { _attr: { "w:val": "double" } } }],
}); });
}); });
@ -634,7 +634,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:u": { _attr: { "w:val": "double", "w:color": "005599" } } }], "w:rPr": [{ "w:u": { _attr: { "w:val": "double", "w:color": "005599" } } }],
}); });
}); });
@ -656,7 +656,7 @@ describe.only("AbstractNumbering", () => {
], ],
}); });
const tree = new Formatter().format(abstractNumbering); const tree = new Formatter().format(abstractNumbering);
expect(tree["w:lvl"]).to.include({ expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
"w:rPr": [{ "w:color": { _attr: { "w:val": "123456" } } }], "w:rPr": [{ "w:color": { _attr: { "w:val": "123456" } } }],
}); });
}); });

View File

@ -7,7 +7,7 @@ import { ConcreteNumbering } from "./num";
describe("ConcreteNumbering", () => { describe("ConcreteNumbering", () => {
describe("#overrideLevel", () => { describe("#overrideLevel", () => {
let concreteNumbering; let concreteNumbering: ConcreteNumbering;
beforeEach(() => { beforeEach(() => {
concreteNumbering = new ConcreteNumbering(0, 1); concreteNumbering = new ConcreteNumbering(0, 1);
}); });
@ -17,18 +17,13 @@ describe("ConcreteNumbering", () => {
const tree = new Formatter().format(concreteNumbering); const tree = new Formatter().format(concreteNumbering);
expect(tree["w:num"]).to.include({ expect(tree["w:num"]).to.include({
"w:lvlOverride": [ "w:lvlOverride": [
{ _attr: { "w:ilvl": 3 } },
{ {
_attr: { "w:lvl": [
"w:ilvl": 3, { _attr: { "w:ilvl": 3, "w15:tentative": 1 } },
}, { "w:start": { _attr: { "w:val": 1 } } },
}, { "w:lvlJc": { _attr: { "w:val": "start" } } },
{ ],
"w:lvl": {
_attr: {
"w:ilvl": 3,
"w15:tentative": 1,
},
},
}, },
], ],
}); });
@ -52,12 +47,11 @@ describe("ConcreteNumbering", () => {
}, },
}, },
{ {
"w:lvl": { "w:lvl": [
_attr: { { _attr: { "w:ilvl": 1, "w15:tentative": 1 } },
"w:ilvl": 1, { "w:start": { _attr: { "w:val": 1 } } },
"w15:tentative": 1, { "w:lvlJc": { _attr: { "w:val": "start" } } },
}, ],
},
}, },
], ],
}); });
@ -67,11 +61,16 @@ describe("ConcreteNumbering", () => {
const ol = concreteNumbering.overrideLevel(1); const ol = concreteNumbering.overrideLevel(1);
expect(ol.Level).to.be.instanceof(LevelForOverride); expect(ol.Level).to.be.instanceof(LevelForOverride);
const tree = new Formatter().format(concreteNumbering); const tree = new Formatter().format(concreteNumbering);
expect(tree["w:num"]).to.include({ expect(tree["w:num"]).to.include({
"w:lvlOverride": [ "w:lvlOverride": [
{ _attr: { "w:ilvl": 1 } }, { _attr: { "w:ilvl": 1 } },
{ {
"w:lvl": { _attr: { "w15:tentative": 1, "w:ilvl": 1 } }, "w:lvl": [
{ _attr: { "w:ilvl": 1, "w15:tentative": 1 } },
{ "w:start": { _attr: { "w:val": 1 } } },
{ "w:lvlJc": { _attr: { "w:val": "start" } } },
],
}, },
], ],
}); });

View File

@ -79,8 +79,8 @@ export enum LevelSuffix {
export interface ILevelsOptions { export interface ILevelsOptions {
readonly level: number; readonly level: number;
readonly format: string; readonly format?: string;
readonly text: string; readonly text?: string;
readonly alignment?: AlignmentType; readonly alignment?: AlignmentType;
readonly start?: number; readonly start?: number;
readonly suffix?: LevelSuffix; readonly suffix?: LevelSuffix;
@ -115,10 +115,16 @@ export class LevelBase extends XmlComponent {
); );
this.root.push(new Start(start)); this.root.push(new Start(start));
this.root.push(new NumberFormat(format));
this.root.push(new LevelText(text));
this.root.push(new LevelJc(alignment)); this.root.push(new LevelJc(alignment));
if (format) {
this.root.push(new NumberFormat(format));
}
if (text) {
this.root.push(new LevelText(text));
}
this.paragraphProperties = new ParagraphProperties({}); this.paragraphProperties = new ParagraphProperties({});
this.runProperties = new RunProperties(); this.runProperties = new RunProperties();

View File

@ -55,7 +55,9 @@ export class LevelOverride extends XmlComponent {
this.root.push(new StartOverride(start)); this.root.push(new StartOverride(start));
} }
this.lvl = new LevelForOverride(this.levelNum); this.lvl = new LevelForOverride({
level: this.levelNum,
});
this.root.push(this.lvl); this.root.push(this.lvl);
} }

View File

@ -1,7 +1,7 @@
import { Attributes, XmlComponent } from "file/xml-components"; import { Attributes, XmlComponent } from "file/xml-components";
export class NumberProperties extends XmlComponent { export class NumberProperties extends XmlComponent {
constructor(numberId: number, indentLevel: number) { constructor(numberId: number | string, indentLevel: number) {
super("w:numPr"); super("w:numPr");
this.root.push(new IndentLevel(indentLevel)); this.root.push(new IndentLevel(indentLevel));
this.root.push(new NumberId(numberId)); this.root.push(new NumberId(numberId));
@ -20,11 +20,11 @@ class IndentLevel extends XmlComponent {
} }
class NumberId extends XmlComponent { class NumberId extends XmlComponent {
constructor(id: number) { constructor(id: number | string) {
super("w:numId"); super("w:numId");
this.root.push( this.root.push(
new Attributes({ new Attributes({
val: id, val: typeof id === "string" ? `__${id}__` : id,
}), }),
); );
} }

View File

@ -3,7 +3,6 @@ import { assert, expect } from "chai";
import { Formatter } from "export/formatter"; import { Formatter } from "export/formatter";
import { EMPTY_OBJECT } from "file/xml-components"; import { EMPTY_OBJECT } from "file/xml-components";
import { Numbering } from "../numbering";
import { AlignmentType, HeadingLevel, LeaderType, PageBreak, TabStopPosition, TabStopType } from "./formatting"; import { AlignmentType, HeadingLevel, LeaderType, PageBreak, TabStopPosition, TabStopType } from "./formatting";
import { Paragraph } from "./paragraph"; import { Paragraph } from "./paragraph";
@ -596,19 +595,9 @@ describe("Paragraph", () => {
describe("#setNumbering", () => { describe("#setNumbering", () => {
it("should add list paragraph style to JSON", () => { it("should add list paragraph style to JSON", () => {
const numbering = new Numbering({
levels: [
{
level: 0,
format: "lowerLetter",
text: "%1)",
},
],
});
const paragraph = new Paragraph({ const paragraph = new Paragraph({
numbering: { numbering: {
num: letterNumbering, reference: "test id",
level: 0, level: 0,
}, },
}); });
@ -627,19 +616,9 @@ describe("Paragraph", () => {
}); });
it("it should add numbered properties", () => { it("it should add numbered properties", () => {
const numbering = new Numbering({
levels: [
{
level: 0,
format: "lowerLetter",
text: "%1)",
},
],
});
const paragraph = new Paragraph({ const paragraph = new Paragraph({
numbering: { numbering: {
num: letterNumbering, reference: "test id",
level: 0, level: 0,
}, },
}); });
@ -650,10 +629,7 @@ describe("Paragraph", () => {
"w:pPr": [ "w:pPr": [
{ "w:pStyle": { _attr: { "w:val": "ListParagraph" } } }, { "w:pStyle": { _attr: { "w:val": "ListParagraph" } } },
{ {
"w:numPr": [ "w:numPr": [{ "w:ilvl": { _attr: { "w:val": 0 } } }, { "w:numId": { _attr: { "w:val": "__test id__" } } }],
{ "w:ilvl": { _attr: { "w:val": 0 } } },
{ "w:numId": { _attr: { "w:val": letterNumbering.id } } },
],
}, },
], ],
}, },

View File

@ -1,6 +1,5 @@
// http://officeopenxml.com/WPparagraph.php // http://officeopenxml.com/WPparagraph.php
import { FootnoteReferenceRun } from "file/footnotes/footnote/run/reference-run"; import { FootnoteReferenceRun } from "file/footnotes/footnote/run/reference-run";
import { ConcreteNumbering } from "file/numbering/num";
import { XmlComponent } from "file/xml-components"; import { XmlComponent } from "file/xml-components";
import { Alignment, AlignmentType } from "./formatting/alignment"; import { Alignment, AlignmentType } from "./formatting/alignment";
@ -41,7 +40,7 @@ export interface IParagraphOptions {
readonly level: number; readonly level: number;
}; };
readonly numbering?: { readonly numbering?: {
readonly num: ConcreteNumbering; readonly reference: string;
readonly level: number; readonly level: number;
readonly custom?: boolean; readonly custom?: boolean;
}; };
@ -141,7 +140,7 @@ export class Paragraph extends XmlComponent {
if (!options.numbering.custom) { if (!options.numbering.custom) {
this.properties.push(new Style("ListParagraph")); this.properties.push(new Style("ListParagraph"));
} }
this.properties.push(new NumberProperties(options.numbering.num.id, options.numbering.level)); this.properties.push(new NumberProperties(options.numbering.reference, options.numbering.level));
} }
if (options.children) { if (options.children) {