UNPKG

docxml

Version:

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

56 lines (55 loc) 2.23 kB
import './Text.js'; import { type ComponentAncestor, Component, ComponentContext } from '../classes/Component.js'; import { type BookmarkRangeEnd } from './BookmarkRangeEnd.js'; import { type BookmarkRangeStart } from './BookmarkRangeStart.js'; import { type CommentRangeEnd } from './CommentRangeEnd.js'; import { type CommentRangeStart } from './CommentRangeStart.js'; import { type Hyperlink } from './Hyperlink.js'; import { type Text } from './Text.js'; import { type TextAddition } from './TextAddition.js'; import { type TextDeletion } from './TextDeletion.js'; /** * A type describing the components accepted as children of {@link Field}. */ export declare type FieldChild = BookmarkRangeStart | BookmarkRangeEnd | CommentRangeStart | CommentRangeEnd | TextDeletion | TextAddition | Text | Hyperlink; /** * A type describing the props accepted by {@link Field}. */ export declare type FieldProps = { instruction: string; /** * Indicates that its current results are invalid (stale) due to other modifications made to the * document, and these contents should be updated before they are displayed if this functionality * is supported by the next processing application. * * Defaults to `false`. */ isDirty?: boolean; /** * Specifies that the parent field shall not have its field result recalculated, even if an * application attempts to recalculate the results of all fields in the document or a recalculation * is explicitly requested. * * Defaults to `false`. */ isLocked?: boolean; }; /** * A component that represents a (simple) instruction field. */ export declare class Field extends Component<FieldProps, FieldChild> { static readonly children: string[]; static readonly mixed: boolean; /** * Creates an XML DOM node for this component instance. */ toNode(ancestry: ComponentAncestor[]): Promise<Node>; /** * Asserts whether or not a given XML node correlates with this component. */ static matchesNode(node: Node): boolean; /** * Instantiate this component from the XML in an existing DOCX file. */ static fromNode(node: Node, context: ComponentContext): Field; }