UNPKG

docxml

Version:

TypeScript (component) library for building and parsing a DOCX file

47 lines (46 loc) 1.36 kB
import { Component } from '../classes/Component.js'; import { registerComponent } from '../utilities/components.js'; import { create } from '../utilities/dom.js'; import { QNS } from '../utilities/namespaces.js'; import { evaluateXPathToBoolean } from '../utilities/xquery.js'; /** * The end of a range associated with a complex field. */ export class FieldRangeEnd extends Component { /** * Creates an XML DOM node for this component instance. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars toNode(_ancestry) { return create(` element ${QNS.w}fldChar { attribute ${QNS.w}fldCharType { "end" } } `, {}); } /** * Asserts whether or not a given XML node correlates with this component. */ static matchesNode(node) { return evaluateXPathToBoolean('self::w:fldChar and @w:fldCharType = "end"', node); } /** * Instantiate this component from the XML in an existing DOCX file. */ static fromNode() { return new FieldRangeEnd({}); } } Object.defineProperty(FieldRangeEnd, "children", { enumerable: true, configurable: true, writable: true, value: [] }); Object.defineProperty(FieldRangeEnd, "mixed", { enumerable: true, configurable: true, writable: true, value: false }); registerComponent(FieldRangeEnd);