Finish making numbering declarative

This commit is contained in:
Dolan
2019-11-08 03:11:19 +00:00
parent 9b40b5e55e
commit 643e3c2f84
14 changed files with 530 additions and 501 deletions

View File

@ -1,23 +1,37 @@
// Numbered lists
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Numbering, Packer, Paragraph } from "../build";
import { AlignmentType, Document, Packer, Paragraph } from "../build";
const doc = new Document();
const numbering = new Numbering();
const abstractNum = numbering.createAbstractNumbering();
abstractNum.createLevel(0, "upperRoman", "%1", "start").indent({ left: 720, hanging: 260 });
const concrete = numbering.createConcreteNumbering(abstractNum);
const doc = new Document({
numbering: {
config: [
{
levels: [
{
level: 0,
format: "upperRoman",
text: "%1",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 720, hanging: 260 },
},
},
},
],
reference: "my-crazy-reference",
},
],
},
});
doc.addSection({
children: [
new Paragraph({
text: "line with contextual spacing",
numbering: {
num: concrete,
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: true,
@ -28,7 +42,7 @@ doc.addSection({
new Paragraph({
text: "line with contextual spacing",
numbering: {
num: concrete,
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: true,
@ -39,7 +53,7 @@ doc.addSection({
new Paragraph({
text: "line without contextual spacing",
numbering: {
num: concrete,
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: false,
@ -50,7 +64,7 @@ doc.addSection({
new Paragraph({
text: "line without contextual spacing",
numbering: {
num: concrete,
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: false,