UNPKG

docxml

Version:

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

47 lines (46 loc) 1.44 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 separator between the instruction of a compex field, and the last computed value. */ export class FieldRangeSeparator 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 { "separate" } } `, {}); } /** * Asserts whether or not a given XML node correlates with this component. */ static matchesNode(node) { return evaluateXPathToBoolean('self::w:fldChar and @w:fldCharType = "separate"', node); } /** * Instantiate this component from the XML in an existing DOCX file. */ static fromNode() { return new FieldRangeSeparator({}); } } Object.defineProperty(FieldRangeSeparator, "children", { enumerable: true, configurable: true, writable: true, value: [] }); Object.defineProperty(FieldRangeSeparator, "mixed", { enumerable: true, configurable: true, writable: true, value: false }); registerComponent(FieldRangeSeparator);