docxml
Version:
TypeScript (component) library for building and parsing a DOCX file
53 lines (52 loc) • 1.45 kB
JavaScript
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 { evaluateXPathToMap } from '../utilities/xquery.js';
/**
* The end of a range associated with a comment.
*/
export class CommentRangeEnd 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}commentRangeEnd {
attribute ${QNS.w}id { $id }
}
`, {
id: this.props.id,
});
}
/**
* Asserts whether or not a given XML node correlates with this component.
*/
static matchesNode(node) {
return node.nodeName === 'w:commentRangeEnd';
}
/**
* Instantiate this component from the XML in an existing DOCX file.
*/
static fromNode(node) {
return new CommentRangeEnd(evaluateXPathToMap(`
map {
"id": ./@${QNS.w}id/number()
}
`, node));
}
}
Object.defineProperty(CommentRangeEnd, "children", {
enumerable: true,
configurable: true,
writable: true,
value: []
});
Object.defineProperty(CommentRangeEnd, "mixed", {
enumerable: true,
configurable: true,
writable: true,
value: false
});
registerComponent(CommentRangeEnd);