UNPKG

docxml

Version:

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

19 lines (18 loc) 1.01 kB
import { type AnyComponent, type ComponentDefinition, ComponentContext } from '../classes/Component.js'; /** * Register a component in such a way that it can be found by its name later. Uses the class * name as unique key. * * @TODO test that this works well in minified JS * * This helps avoid circular dependencies in components that can be a descendant of themselves. * For example, Table --> Row --> Cell --> Table */ export declare function registerComponent<C extends AnyComponent>(component: ComponentDefinition<C>): ComponentDefinition<C>; /** * Transforms a list of (OOXML) XML nodes to component instances based on a list of possible component * names. The component names must have been registered before using {@link registerComponent}. * * This is useful for instantiating the children of a component based on an existing DOCX file. */ export declare function createChildComponentsFromNodes<T extends AnyComponent | string>(names: string[], nodes: Node[], context: ComponentContext): T[];