UNPKG

docxml

Version:

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

51 lines (50 loc) 1.58 kB
import './Text.js'; import { Bookmark } from '../classes/Bookmarks.js'; import { type ComponentAncestor, Component, ComponentContext } from '../classes/Component.js'; import { type RelationshipsXml } from '../files/RelationshipsXml.js'; import { type Field } from './Field.js'; import { type Text } from './Text.js'; /** * A type describing the components accepted as children of {@link Hyperlink}. */ export declare type HyperlinkChild = Text | Field; /** * A type describing the props accepted by {@link Hyperlink}. */ export declare type HyperlinkProps = { anchor: string; bookmark?: never; url?: never; tooltip?: string; } | { anchor?: never; bookmark: Bookmark; url?: never; tooltip?: string; } | { anchor?: never; bookmark?: never; url: string; tooltip?: string; }; /** * A component that represents a hyperlink to another part of the same document. */ export declare class Hyperlink extends Component<HyperlinkProps, HyperlinkChild> { #private; static readonly children: string[]; static readonly mixed: boolean; ensureRelationship(relationships: RelationshipsXml): void; /** * 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): Hyperlink; }