Merge branch 'master' of https://github.com/h4buli/docx into feat/h4buli-update
# Conflicts: # package.json # src/file/numbering/numbering.ts
This commit is contained in:
@ -1 +1,2 @@
|
||||
export * from "./numbering";
|
||||
export * from "./abstract-numbering";
|
@ -1,12 +1,14 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { XmlComponent, IXmlableObject } from "file/xml-components";
|
||||
import { DocumentAttributes } from "../document/document-attributes";
|
||||
import { Indent } from "../paragraph/formatting";
|
||||
import { AbstractNumbering } from "./abstract-numbering";
|
||||
import { Num } from "./num";
|
||||
|
||||
export class Numbering extends XmlComponent {
|
||||
private nextId: number;
|
||||
|
||||
private abstractNumbering: Array<XmlComponent> = [];
|
||||
private concreteNumbering: Array<XmlComponent> = [];
|
||||
|
||||
constructor() {
|
||||
super("w:numbering");
|
||||
this.root.push(
|
||||
@ -32,39 +34,23 @@ export class Numbering extends XmlComponent {
|
||||
);
|
||||
|
||||
this.nextId = 0;
|
||||
|
||||
const abstractNumbering = this.createAbstractNumbering();
|
||||
|
||||
abstractNumbering.createLevel(0, "bullet", "\u25CF", "left").addParagraphProperty(new Indent({ left: 720, hanging: 360 }));
|
||||
|
||||
abstractNumbering.createLevel(1, "bullet", "\u25CB", "left").addParagraphProperty(new Indent({ left: 1440, hanging: 360 }));
|
||||
|
||||
abstractNumbering.createLevel(2, "bullet", "\u25A0", "left").addParagraphProperty(new Indent({ left: 2160, hanging: 360 }));
|
||||
|
||||
abstractNumbering.createLevel(3, "bullet", "\u25CF", "left").addParagraphProperty(new Indent({ left: 2880, hanging: 360 }));
|
||||
|
||||
abstractNumbering.createLevel(4, "bullet", "\u25CB", "left").addParagraphProperty(new Indent({ left: 3600, hanging: 360 }));
|
||||
|
||||
abstractNumbering.createLevel(5, "bullet", "\u25A0", "left").addParagraphProperty(new Indent({ left: 4320, hanging: 360 }));
|
||||
|
||||
abstractNumbering.createLevel(6, "bullet", "\u25CF", "left").addParagraphProperty(new Indent({ left: 5040, hanging: 360 }));
|
||||
|
||||
abstractNumbering.createLevel(7, "bullet", "\u25CB", "left").addParagraphProperty(new Indent({ left: 5760, hanging: 360 }));
|
||||
|
||||
abstractNumbering.createLevel(8, "bullet", "\u25A0", "left").addParagraphProperty(new Indent({ left: 6480, hanging: 360 }));
|
||||
|
||||
this.createConcreteNumbering(abstractNumbering);
|
||||
}
|
||||
|
||||
public createAbstractNumbering(): AbstractNumbering {
|
||||
const num = new AbstractNumbering(this.nextId++);
|
||||
this.root.push(num);
|
||||
this.abstractNumbering.push(num);
|
||||
return num;
|
||||
}
|
||||
|
||||
public createConcreteNumbering(abstractNumbering: AbstractNumbering): Num {
|
||||
const num = new Num(this.nextId++, abstractNumbering.id);
|
||||
this.root.push(num);
|
||||
this.concreteNumbering.push(num);
|
||||
return num;
|
||||
}
|
||||
|
||||
public prepForXml(): IXmlableObject {
|
||||
this.abstractNumbering.forEach(x => this.root.push(x));
|
||||
this.concreteNumbering.forEach(x => this.root.push(x));
|
||||
return super.prepForXml();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user