Compare commits
1 Commits
8.4.0
...
feature/pa
Author | SHA1 | Date | |
---|---|---|---|
c5a2c1c0cb |
@ -10,8 +10,10 @@ import { ColumnBreak, PageBreak } from "./formatting/break";
|
|||||||
import { Bookmark, ConcreteHyperlink, ExternalHyperlink, InternalHyperlink } from "./links";
|
import { Bookmark, ConcreteHyperlink, ExternalHyperlink, InternalHyperlink } from "./links";
|
||||||
import { Math } from "./math";
|
import { Math } from "./math";
|
||||||
import { IParagraphPropertiesOptions, ParagraphProperties } from "./properties";
|
import { IParagraphPropertiesOptions, ParagraphProperties } from "./properties";
|
||||||
import { ImageRun, Run, SequentialIdentifier, SimpleField, SimpleMailMergeField, SymbolRun, TextRun } from "./run";
|
import { ImageRun, PageNumber, Run, SequentialIdentifier, SimpleField, SimpleMailMergeField, SymbolRun, TextRun } from "./run";
|
||||||
import { Comment, CommentRangeEnd, CommentRangeStart, CommentReference, Comments } from "./run/comment-run";
|
import { Comment, CommentRangeEnd, CommentRangeStart, CommentReference, Comments } from "./run/comment-run";
|
||||||
|
import { Begin, End, Separate } from "./run/field";
|
||||||
|
import { NumberOfPages, NumberOfPagesSection, Page } from "./run/page-number";
|
||||||
|
|
||||||
export type ParagraphChild =
|
export type ParagraphChild =
|
||||||
| TextRun
|
| TextRun
|
||||||
@ -33,7 +35,8 @@ export type ParagraphChild =
|
|||||||
| Comment
|
| Comment
|
||||||
| CommentRangeStart
|
| CommentRangeStart
|
||||||
| CommentRangeEnd
|
| CommentRangeEnd
|
||||||
| CommentReference;
|
| CommentReference
|
||||||
|
| PageNumber;
|
||||||
|
|
||||||
export interface IParagraphOptions extends IParagraphPropertiesOptions {
|
export interface IParagraphOptions extends IParagraphPropertiesOptions {
|
||||||
readonly text?: string;
|
readonly text?: string;
|
||||||
@ -63,6 +66,34 @@ export class Paragraph extends FileChild {
|
|||||||
|
|
||||||
if (options.children) {
|
if (options.children) {
|
||||||
for (const child of options.children) {
|
for (const child of options.children) {
|
||||||
|
if (typeof child === "string") {
|
||||||
|
switch (child) {
|
||||||
|
case PageNumber.CURRENT:
|
||||||
|
this.root.push(new TextRun({ children: [new Begin()] }));
|
||||||
|
this.root.push(new TextRun({ children: [new Page()] }));
|
||||||
|
this.root.push(new TextRun({ children: [new Separate()] }));
|
||||||
|
this.root.push(new TextRun({ children: [new End()] }));
|
||||||
|
break;
|
||||||
|
case PageNumber.TOTAL_PAGES:
|
||||||
|
this.root.push(new TextRun({ children: [new Begin()] }));
|
||||||
|
this.root.push(new TextRun({ children: [new NumberOfPages()] }));
|
||||||
|
this.root.push(new TextRun({ children: [new Separate()] }));
|
||||||
|
this.root.push(new TextRun("0"));
|
||||||
|
this.root.push(new TextRun({ children: [new End()] }));
|
||||||
|
break;
|
||||||
|
case PageNumber.TOTAL_PAGES_IN_SECTION:
|
||||||
|
this.root.push(new TextRun({ children: [new Begin()] }));
|
||||||
|
this.root.push(new TextRun({ children: [new NumberOfPagesSection()] }));
|
||||||
|
this.root.push(new TextRun({ children: [new Separate()] }));
|
||||||
|
this.root.push(new TextRun({ children: [new End()] }));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.root.push(new TextRun(child));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (child instanceof Bookmark) {
|
if (child instanceof Bookmark) {
|
||||||
this.root.push(child.start);
|
this.root.push(child.start);
|
||||||
for (const textRun of child.children) {
|
for (const textRun of child.children) {
|
||||||
|
@ -1,13 +1,29 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-w_fldChar-1.html
|
||||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||||
|
|
||||||
|
// <xsd:complexType name="CT_FldChar">
|
||||||
|
// <xsd:choice>
|
||||||
|
// <xsd:element name="fldData" type="CT_Text" minOccurs="0" maxOccurs="1" />
|
||||||
|
// <xsd:element name="ffData" type="CT_FFData" minOccurs="0" maxOccurs="1" />
|
||||||
|
// <xsd:element name="numberingChange" type="CT_TrackChangeNumbering" minOccurs="0" />
|
||||||
|
// </xsd:choice>
|
||||||
|
// <xsd:attribute name="fldCharType" type="ST_FldCharType" use="required" />
|
||||||
|
// <xsd:attribute name="fldLock" type="s:ST_OnOff" />
|
||||||
|
// <xsd:attribute name="dirty" type="s:ST_OnOff" />
|
||||||
|
// </xsd:complexType>
|
||||||
|
|
||||||
enum FieldCharacterType {
|
enum FieldCharacterType {
|
||||||
BEGIN = "begin",
|
BEGIN = "begin",
|
||||||
END = "end",
|
END = "end",
|
||||||
SEPARATE = "separate",
|
SEPARATE = "separate",
|
||||||
}
|
}
|
||||||
|
|
||||||
class FidCharAttrs extends XmlAttributeComponent<{ readonly type: FieldCharacterType; readonly dirty?: boolean }> {
|
class FidCharAttrs extends XmlAttributeComponent<{
|
||||||
protected readonly xmlKeys = { type: "w:fldCharType", dirty: "w:dirty" };
|
readonly type: FieldCharacterType;
|
||||||
|
readonly dirty?: boolean;
|
||||||
|
readonly fieldLock?: boolean;
|
||||||
|
}> {
|
||||||
|
protected readonly xmlKeys = { type: "w:fldCharType", dirty: "w:dirty", fieldLock: "w:fldLock" };
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Begin extends XmlComponent {
|
export class Begin extends XmlComponent {
|
||||||
|
Reference in New Issue
Block a user