added numbering files
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import * as _ from "lodash";
|
||||
import {ParagraphProperties} from "../paragraph/properties";
|
||||
import {RunProperties} from "../run/properties";
|
||||
|
||||
export abstract class BaseXmlComponent {
|
||||
protected rootKey: string;
|
||||
@ -54,9 +56,15 @@ export abstract class XmlAttributeComponent extends BaseXmlComponent {
|
||||
protected root: Object;
|
||||
private xmlKeys: Object;
|
||||
|
||||
constructor(xmlKeys: Object) {
|
||||
constructor(xmlKeys: Object, properties: Object) {
|
||||
super("_attr");
|
||||
this.xmlKeys = xmlKeys;
|
||||
|
||||
this.root = properties
|
||||
|
||||
if (!properties) {
|
||||
this.root = {};
|
||||
}
|
||||
}
|
||||
|
||||
replaceKey(): void {
|
||||
|
28
ts/numbering/abstract-numbering.ts
Normal file
28
ts/numbering/abstract-numbering.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import {XmlComponent} from "../docx/xml-components";
|
||||
import {XmlAttributeComponent} from "../docx/xml-components";
|
||||
|
||||
interface AbstractNumberingAttributesProperties {
|
||||
abstractNumId?: Number,
|
||||
restartNumberingAfterBreak?: Number
|
||||
}
|
||||
|
||||
class AbstractNumberingAttributes extends XmlAttributeComponent {
|
||||
|
||||
constructor(properties: AbstractNumberingAttributesProperties) {
|
||||
super({
|
||||
abstractNumId: "w:abstractNumId",
|
||||
restartNumberingAfterBreak: "w15:restartNumberingAfterBreak"
|
||||
}, properties);
|
||||
}
|
||||
}
|
||||
|
||||
export class AbstractNumbering extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:abstractNum");
|
||||
this.root.push(new AbstractNumberingAttributes({
|
||||
abstractNumId: 0,
|
||||
restartNumberingAfterBreak: 0
|
||||
}));
|
||||
}
|
||||
}
|
28
ts/numbering/index.ts
Normal file
28
ts/numbering/index.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import {XmlComponent} from "../docx/xml-components";
|
||||
import {DocumentAttributes} from "../docx/document/document-attributes"
|
||||
|
||||
export class Numbering extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:numbering");
|
||||
this.root.push(new DocumentAttributes({
|
||||
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
||||
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
||||
o: "urn:schemas-microsoft-com:office:office",
|
||||
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||
m: "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
||||
v: "urn:schemas-microsoft-com:vml",
|
||||
wp14: "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
|
||||
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
||||
w10: "urn:schemas-microsoft-com:office:word",
|
||||
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
||||
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
||||
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
||||
wpg: "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",
|
||||
wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
|
||||
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
||||
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
||||
Ignorable: "w14 w15 wp14"
|
||||
}));
|
||||
}
|
||||
}
|
101
ts/numbering/level.ts
Normal file
101
ts/numbering/level.ts
Normal file
@ -0,0 +1,101 @@
|
||||
import {XmlComponent, Attributes, MultiPropertyXmlComponent} from "../docx/xml-components";
|
||||
import {XmlAttributeComponent} from "../docx/xml-components";
|
||||
import {RunProperties} from "../docx/run/properties";
|
||||
import {ParagraphProperties} from "../docx/paragraph/properties";
|
||||
|
||||
interface LevelAttributesProperties {
|
||||
ilvl?: number,
|
||||
tentative?: number
|
||||
}
|
||||
|
||||
class LevelAttributes extends XmlAttributeComponent {
|
||||
|
||||
constructor(properties: LevelAttributesProperties) {
|
||||
super({
|
||||
ilvl: "w:ilvl",
|
||||
tentative: "w15:tentative"
|
||||
}, properties);
|
||||
}
|
||||
|
||||
properties
|
||||
}
|
||||
|
||||
class Start extends XmlComponent {
|
||||
|
||||
constructor(value: number) {
|
||||
super("w:start");
|
||||
this.root.push(new Attributes({
|
||||
val: value
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
class NumberFormat extends XmlComponent {
|
||||
|
||||
constructor(value: string) {
|
||||
super("w:numFmt");
|
||||
this.root.push(new Attributes({
|
||||
val: value
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
class LevelText extends XmlComponent {
|
||||
|
||||
constructor(value: string) {
|
||||
super("w:lvlText");
|
||||
this.root.push(new Attributes({
|
||||
val: value
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
class LevelJc extends XmlComponent {
|
||||
|
||||
constructor(value: string) {
|
||||
super("w:lvlJc");
|
||||
this.root.push(new Attributes({
|
||||
val: value
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
export class Level extends XmlComponent {
|
||||
private paragraphProperties: ParagraphProperties;
|
||||
private runProperties: RunProperties;
|
||||
|
||||
constructor(level: number, numberFormat: string, levelText: string, lvlJc: string) {
|
||||
super("w:lvl");
|
||||
this.root.push(new LevelAttributes({
|
||||
ilvl: level,
|
||||
tentative: 1
|
||||
}));
|
||||
|
||||
this.root.push(new Start(1));
|
||||
this.root.push(new NumberFormat(numberFormat));
|
||||
this.root.push(new LevelText(levelText));
|
||||
this.root.push(new LevelJc(lvlJc));
|
||||
|
||||
this.paragraphProperties = new ParagraphProperties();
|
||||
this.runProperties = new RunProperties();
|
||||
|
||||
this.root.push(this.paragraphProperties);
|
||||
this.root.push(this.runProperties);
|
||||
}
|
||||
|
||||
clearVariables(): void {
|
||||
this.paragraphProperties.clearVariables();
|
||||
this.runProperties.clearVariables();
|
||||
|
||||
delete this.paragraphProperties;
|
||||
delete this.runProperties;
|
||||
}
|
||||
|
||||
addParagraphProperty(property: XmlComponent): void {
|
||||
this.paragraphProperties.push(property);
|
||||
}
|
||||
|
||||
addRunProperty(property: XmlComponent): void {
|
||||
this.runProperties.push(property);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user