added page break
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import {XmlComponent, Attributes} from "./xml-components";
|
||||
import {XmlComponent, Attributes} from "../xml-components";
|
||||
|
||||
class Border implements XmlComponent {
|
||||
private bottom: Array<XmlComponent>;
|
@ -1,5 +1,8 @@
|
||||
import {XmlComponent, Attributes, ParagraphProperties, Run} from "./xml-components";
|
||||
import {XmlComponent, Attributes} from "../xml-components";
|
||||
import {ThematicBreak} from "./border";
|
||||
import {PageBreak} from "./page-break";
|
||||
import {TextRun} from "./text-run";
|
||||
import {ParagraphProperties} from "./properties";
|
||||
|
||||
class Style {
|
||||
private pStyle: Array<XmlComponent>;
|
||||
@ -32,10 +35,10 @@ export class Paragraph {
|
||||
this.p.push(new Attributes());
|
||||
this.properties = new ParagraphProperties();
|
||||
this.p.push(this.properties);
|
||||
this.p.push(new Run(text));
|
||||
this.p.push(new TextRun(text));
|
||||
}
|
||||
|
||||
addText(run: Run) {
|
||||
addText(run: TextRun) {
|
||||
this.p.push(run);
|
||||
return this;
|
||||
}
|
||||
@ -94,12 +97,9 @@ export class Paragraph {
|
||||
this.properties.push(new ThematicBreak());
|
||||
return this;
|
||||
}
|
||||
|
||||
pageBreak () {
|
||||
this.properties.push(new ThematicBreak());
|
||||
|
||||
|
||||
paragraphProperties.push(pBreak);
|
||||
return this;
|
||||
}
|
||||
pageBreak() {
|
||||
this.properties.push(new PageBreak());
|
||||
return this;
|
||||
}
|
||||
}
|
19
ts/docx/paragraph/page-break.ts
Normal file
19
ts/docx/paragraph/page-break.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import {XmlComponent, Attributes, Run} from "../xml-components";
|
||||
|
||||
class Break implements XmlComponent {
|
||||
private br: Array<XmlComponent>;
|
||||
constructor() {
|
||||
this.br = new Array<XmlComponent>();
|
||||
this.br.push(new Attributes({
|
||||
type: "page"
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
export class PageBreak extends Run {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.r.push(new Break());
|
||||
}
|
||||
}
|
14
ts/docx/paragraph/properties.ts
Normal file
14
ts/docx/paragraph/properties.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import {XmlComponent, Attributes} from "../xml-components";
|
||||
|
||||
export class ParagraphProperties implements XmlComponent {
|
||||
private pPr: Array<XmlComponent>;
|
||||
|
||||
constructor() {
|
||||
this.pPr = new Array<XmlComponent>();
|
||||
this.pPr.push(new Attributes());
|
||||
}
|
||||
|
||||
push(item: XmlComponent) {
|
||||
this.pPr.push(item);
|
||||
}
|
||||
}
|
11
ts/docx/paragraph/text-run.ts
Normal file
11
ts/docx/paragraph/text-run.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import {Run, Text} from "../xml-components";
|
||||
import {ParagraphProperties} from "./properties";
|
||||
|
||||
export class TextRun extends Run {
|
||||
|
||||
constructor(text: string) {
|
||||
super();
|
||||
this.r.push(new ParagraphProperties());
|
||||
this.r.push(new Text(text));
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ interface AttributesProperties {
|
||||
color?: string;
|
||||
space?: string;
|
||||
sz?: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export class Attributes implements XmlComponent {
|
||||
@ -21,26 +22,11 @@ export class Attributes implements XmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export class ParagraphProperties implements XmlComponent {
|
||||
private pPr: Array<XmlComponent>;
|
||||
export class Run implements XmlComponent {
|
||||
protected r: Array<XmlComponent>;
|
||||
|
||||
constructor() {
|
||||
this.pPr = new Array<XmlComponent>();
|
||||
this.pPr.push(new Attributes());
|
||||
}
|
||||
|
||||
push(item: XmlComponent) {
|
||||
this.pPr.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
export class Run implements XmlComponent {
|
||||
private r: Array<XmlComponent>;
|
||||
|
||||
constructor(text: string) {
|
||||
this.r = new Array<XmlComponent>();
|
||||
this.r.push(new ParagraphProperties());
|
||||
this.r.push(new Text(text));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user