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 {
|
||||
// console.log("generateTablesOfContents");
|
||||
this.document.getTablesOfContents().forEach((child) => this.generateContent(child));
|
||||
}
|
||||
|
||||
@ -301,9 +302,10 @@ export class File {
|
||||
private generateContentForHeaderRange(toc: TableOfContents): void {
|
||||
const headerRange = toc.getHeaderRange();
|
||||
const hyphenIndex = headerRange.indexOf("-");
|
||||
// console.log("Hyphen Index: ", hyphenIndex);
|
||||
if (hyphenIndex !== -1) {
|
||||
const rangeBegin = parseInt(headerRange.substring(0, hyphenIndex), 2);
|
||||
const rangeEnd = parseInt(headerRange.substring(hyphenIndex + 1), 2);
|
||||
const rangeBegin = parseInt(headerRange.substring(0, hyphenIndex), 10);
|
||||
const rangeEnd = parseInt(headerRange.substring(hyphenIndex + 1), 10);
|
||||
const styles = new Array<string>();
|
||||
for (let i = rangeBegin; i <= rangeEnd; i++) {
|
||||
styles.push(`Heading${i}`);
|
||||
@ -327,7 +329,7 @@ export class File {
|
||||
// console.log("Generating content for paragraph: ", bookmarkId);
|
||||
|
||||
const generatedParagraph = cloneDeep(paragraph);
|
||||
generatedParagraph.rightTabStop(9016, "dot");
|
||||
generatedParagraph.clearPageBreaks().rightTabStop(9016, "dot");
|
||||
|
||||
const tabRun = new Run();
|
||||
tabRun.addChildElement(new Tab());
|
||||
|
@ -240,4 +240,10 @@ export class Paragraph extends XmlComponent {
|
||||
this.root.splice(1, 0, run);
|
||||
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
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { Border } from "./formatting/border";
|
||||
import { PageBreakBefore } from "./formatting/page-break";
|
||||
import { Style } from "./formatting/style";
|
||||
|
||||
export class ParagraphProperties extends XmlComponent {
|
||||
@ -22,4 +23,9 @@ export class ParagraphProperties extends XmlComponent {
|
||||
public getStyles(): 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