added a method for clear the page breaks of a paragraph
This commit is contained in:
@ -288,6 +288,7 @@ export class File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public generateTablesOfContents(): void {
|
public generateTablesOfContents(): void {
|
||||||
|
// console.log("generateTablesOfContents");
|
||||||
this.document.getTablesOfContents().forEach((child) => this.generateContent(child));
|
this.document.getTablesOfContents().forEach((child) => this.generateContent(child));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,9 +302,10 @@ export class File {
|
|||||||
private generateContentForHeaderRange(toc: TableOfContents): void {
|
private generateContentForHeaderRange(toc: TableOfContents): void {
|
||||||
const headerRange = toc.getHeaderRange();
|
const headerRange = toc.getHeaderRange();
|
||||||
const hyphenIndex = headerRange.indexOf("-");
|
const hyphenIndex = headerRange.indexOf("-");
|
||||||
|
// console.log("Hyphen Index: ", hyphenIndex);
|
||||||
if (hyphenIndex !== -1) {
|
if (hyphenIndex !== -1) {
|
||||||
const rangeBegin = parseInt(headerRange.substring(0, hyphenIndex), 2);
|
const rangeBegin = parseInt(headerRange.substring(0, hyphenIndex), 10);
|
||||||
const rangeEnd = parseInt(headerRange.substring(hyphenIndex + 1), 2);
|
const rangeEnd = parseInt(headerRange.substring(hyphenIndex + 1), 10);
|
||||||
const styles = new Array<string>();
|
const styles = new Array<string>();
|
||||||
for (let i = rangeBegin; i <= rangeEnd; i++) {
|
for (let i = rangeBegin; i <= rangeEnd; i++) {
|
||||||
styles.push(`Heading${i}`);
|
styles.push(`Heading${i}`);
|
||||||
@ -327,7 +329,7 @@ export class File {
|
|||||||
// console.log("Generating content for paragraph: ", bookmarkId);
|
// console.log("Generating content for paragraph: ", bookmarkId);
|
||||||
|
|
||||||
const generatedParagraph = cloneDeep(paragraph);
|
const generatedParagraph = cloneDeep(paragraph);
|
||||||
generatedParagraph.rightTabStop(9016, "dot");
|
generatedParagraph.clearPageBreaks().rightTabStop(9016, "dot");
|
||||||
|
|
||||||
const tabRun = new Run();
|
const tabRun = new Run();
|
||||||
tabRun.addChildElement(new Tab());
|
tabRun.addChildElement(new Tab());
|
||||||
|
@ -240,4 +240,10 @@ export class Paragraph extends XmlComponent {
|
|||||||
this.root.splice(1, 0, run);
|
this.root.splice(1, 0, run);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clearPageBreaks(): Paragraph {
|
||||||
|
this.root = this.root.filter((child) => !(child instanceof PageBreak));
|
||||||
|
this.properties.clearPageBreaks();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// http://officeopenxml.com/WPparagraphProperties.php
|
// http://officeopenxml.com/WPparagraphProperties.php
|
||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { Border } from "./formatting/border";
|
import { Border } from "./formatting/border";
|
||||||
|
import { PageBreakBefore } from "./formatting/page-break";
|
||||||
import { Style } from "./formatting/style";
|
import { Style } from "./formatting/style";
|
||||||
|
|
||||||
export class ParagraphProperties extends XmlComponent {
|
export class ParagraphProperties extends XmlComponent {
|
||||||
@ -22,4 +23,9 @@ export class ParagraphProperties extends XmlComponent {
|
|||||||
public getStyles(): Style[] {
|
public getStyles(): Style[] {
|
||||||
return this.root.filter((child) => child instanceof Style) as Style[];
|
return this.root.filter((child) => child instanceof Style) as Style[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clearPageBreaks(): ParagraphProperties {
|
||||||
|
this.root = this.root.filter((child) => !(child instanceof PageBreakBefore));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user