added numbering
This commit is contained in:
@ -1,5 +1,7 @@
|
|||||||
import {XmlComponent} from "../docx/xml-components";
|
import {XmlComponent} from "../docx/xml-components";
|
||||||
import {XmlAttributeComponent} from "../docx/xml-components";
|
import {XmlAttributeComponent} from "../docx/xml-components";
|
||||||
|
import {Level} from "./level";
|
||||||
|
import {MultiLevelType} from "./multi-level-type";
|
||||||
|
|
||||||
interface AbstractNumberingAttributesProperties {
|
interface AbstractNumberingAttributesProperties {
|
||||||
abstractNumId?: Number,
|
abstractNumId?: Number,
|
||||||
@ -18,11 +20,16 @@ class AbstractNumberingAttributes extends XmlAttributeComponent {
|
|||||||
|
|
||||||
export class AbstractNumbering extends XmlComponent {
|
export class AbstractNumbering extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor(id: number) {
|
||||||
super("w:abstractNum");
|
super("w:abstractNum");
|
||||||
this.root.push(new AbstractNumberingAttributes({
|
this.root.push(new AbstractNumberingAttributes({
|
||||||
abstractNumId: 0,
|
abstractNumId: id,
|
||||||
restartNumberingAfterBreak: 0
|
restartNumberingAfterBreak: 0
|
||||||
}));
|
}));
|
||||||
|
this.root.push(new MultiLevelType("hybridMultilevel"));
|
||||||
|
}
|
||||||
|
|
||||||
|
addLevel(level: Level): void {
|
||||||
|
this.root.push(level);
|
||||||
}
|
}
|
||||||
}
|
}
|
27
ts/numbering/indent.ts
Normal file
27
ts/numbering/indent.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import {XmlComponent, XmlAttributeComponent} from "../docx/xml-components";
|
||||||
|
|
||||||
|
interface IndentAttributesProperties {
|
||||||
|
left: number;
|
||||||
|
hanging: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
class IndentAttributes extends XmlAttributeComponent {
|
||||||
|
|
||||||
|
constructor(properties: IndentAttributesProperties) {
|
||||||
|
super({
|
||||||
|
left: "w:left",
|
||||||
|
hanging: "w:hanging"
|
||||||
|
}, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Indent extends XmlComponent {
|
||||||
|
|
||||||
|
constructor(left: number, hanging: number) {
|
||||||
|
super("w:ind");
|
||||||
|
this.root.push(new IndentAttributes({
|
||||||
|
left: left,
|
||||||
|
hanging: hanging
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,12 @@
|
|||||||
import {XmlComponent} from "../docx/xml-components";
|
import {MultiPropertyXmlComponent} from "../docx/xml-components";
|
||||||
import {DocumentAttributes} from "../docx/document/document-attributes"
|
import {DocumentAttributes} from "../docx/document/document-attributes"
|
||||||
|
import {AbstractNumbering} from "./abstract-numbering";
|
||||||
|
import {Level} from "./level";
|
||||||
|
import {Indent} from "./indent";
|
||||||
|
import {RunFonts} from "./run-fonts";
|
||||||
|
import {Num} from "./num";
|
||||||
|
|
||||||
export class Numbering extends XmlComponent {
|
export class Numbering extends MultiPropertyXmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:numbering");
|
super("w:numbering");
|
||||||
@ -24,5 +29,55 @@ export class Numbering extends XmlComponent {
|
|||||||
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
||||||
Ignorable: "w14 w15 wp14"
|
Ignorable: "w14 w15 wp14"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
var abstractNumbering = new AbstractNumbering(0);
|
||||||
|
|
||||||
|
var level0 = new Level(0, "bullet", "", "left");
|
||||||
|
level0.addParagraphProperty(new Indent(720, 360));
|
||||||
|
level0.addRunProperty(new RunFonts("Symbol", "default"));
|
||||||
|
abstractNumbering.addLevel(level0);
|
||||||
|
|
||||||
|
var level1 = new Level(1, "bullet", "o", "left");
|
||||||
|
level1.addParagraphProperty(new Indent(1440, 360));
|
||||||
|
level1.addRunProperty(new RunFonts("Courier New", "default"));
|
||||||
|
abstractNumbering.addLevel(level1);
|
||||||
|
|
||||||
|
var level2 = new Level(2, "bullet", "", "left");
|
||||||
|
level2.addParagraphProperty(new Indent(2160, 360));
|
||||||
|
level2.addRunProperty(new RunFonts("Wingdings", "default"));
|
||||||
|
abstractNumbering.addLevel(level2);
|
||||||
|
|
||||||
|
var level3 = new Level(3, "bullet", "", "left");
|
||||||
|
level3.addParagraphProperty(new Indent(2880, 360));
|
||||||
|
level3.addRunProperty(new RunFonts("Symbol", "default"));
|
||||||
|
abstractNumbering.addLevel(level3);
|
||||||
|
|
||||||
|
var level4 = new Level(4, "bullet", "o", "left");
|
||||||
|
level4.addParagraphProperty(new Indent(3600, 360));
|
||||||
|
level4.addRunProperty(new RunFonts("Courier New", "default"));
|
||||||
|
abstractNumbering.addLevel(level4);
|
||||||
|
|
||||||
|
var level5 = new Level(5, "bullet", "", "left");
|
||||||
|
level5.addParagraphProperty(new Indent(4320, 360));
|
||||||
|
level5.addRunProperty(new RunFonts("Wingdings", "default"));
|
||||||
|
abstractNumbering.addLevel(level5);
|
||||||
|
|
||||||
|
var level6 = new Level(6, "bullet", "", "left");
|
||||||
|
level6.addParagraphProperty(new Indent(5040, 360));
|
||||||
|
level6.addRunProperty(new RunFonts("Symbol", "default"));
|
||||||
|
abstractNumbering.addLevel(level6);
|
||||||
|
|
||||||
|
var level7 = new Level(4, "bullet", "o", "left");
|
||||||
|
level7.addParagraphProperty(new Indent(5760, 360));
|
||||||
|
level7.addRunProperty(new RunFonts("Courier New", "default"));
|
||||||
|
abstractNumbering.addLevel(level7);
|
||||||
|
|
||||||
|
var level8 = new Level(5, "bullet", "", "left");
|
||||||
|
level8.addParagraphProperty(new Indent(6480, 360));
|
||||||
|
level8.addRunProperty(new RunFonts("Wingdings", "default"));
|
||||||
|
abstractNumbering.addLevel(level8);
|
||||||
|
|
||||||
|
this.root.push(abstractNumbering);
|
||||||
|
this.root.push(new Num(1, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,8 +16,6 @@ class LevelAttributes extends XmlAttributeComponent {
|
|||||||
tentative: "w15:tentative"
|
tentative: "w15:tentative"
|
||||||
}, properties);
|
}, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
properties
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Start extends XmlComponent {
|
class Start extends XmlComponent {
|
||||||
|
11
ts/numbering/multi-level-type.ts
Normal file
11
ts/numbering/multi-level-type.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import {XmlComponent, Attributes} from "../docx/xml-components";
|
||||||
|
|
||||||
|
export class MultiLevelType extends XmlComponent {
|
||||||
|
|
||||||
|
constructor(value: string) {
|
||||||
|
super("w:multiLevelType");
|
||||||
|
this.root.push(new Attributes({
|
||||||
|
val: value
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
35
ts/numbering/num.ts
Normal file
35
ts/numbering/num.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import {XmlComponent, Attributes, XmlAttributeComponent} from "../docx/xml-components";
|
||||||
|
|
||||||
|
class AbstractNumId extends XmlComponent {
|
||||||
|
|
||||||
|
constructor(value: number) {
|
||||||
|
super("w:abstractNumId");
|
||||||
|
this.root.push(new Attributes({
|
||||||
|
val: value
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface NumAttributesProperties {
|
||||||
|
numId: number
|
||||||
|
}
|
||||||
|
|
||||||
|
class NumAttributes extends XmlAttributeComponent {
|
||||||
|
|
||||||
|
constructor(properties: NumAttributesProperties) {
|
||||||
|
super({
|
||||||
|
numId: "w:numId"
|
||||||
|
}, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Num extends XmlComponent {
|
||||||
|
|
||||||
|
constructor(numId: number, abstractNumId: number) {
|
||||||
|
super("w:num");
|
||||||
|
this.root.push(new NumAttributes({
|
||||||
|
numId: numId
|
||||||
|
}));
|
||||||
|
this.root.push(new AbstractNumId(abstractNumId));
|
||||||
|
}
|
||||||
|
}
|
29
ts/numbering/run-fonts.ts
Normal file
29
ts/numbering/run-fonts.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import {XmlComponent, XmlAttributeComponent} from "../docx/xml-components";
|
||||||
|
|
||||||
|
interface RunFontAttributesProperties {
|
||||||
|
ascii: string;
|
||||||
|
hAnsi: string;
|
||||||
|
hint: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
class RunFontAttributes extends XmlAttributeComponent {
|
||||||
|
|
||||||
|
constructor(properties: RunFontAttributesProperties) {
|
||||||
|
super({
|
||||||
|
left: "w:left",
|
||||||
|
hanging: "w:hanging"
|
||||||
|
}, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RunFonts extends XmlComponent {
|
||||||
|
|
||||||
|
constructor(ascii: string, hint: string) {
|
||||||
|
super("w:ind");
|
||||||
|
this.root.push(new RunFontAttributes({
|
||||||
|
ascii: ascii,
|
||||||
|
hAnsi: ascii,
|
||||||
|
hint: hint
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user