Skip to main content
Module

x/docxml/src/classes/XmlComponent.ts>XmlComponent

An experimental Deno tool to transform XML to DOCX with a little XPath- and component based configuration
Go to Latest
class XmlComponent
import { XmlComponent } from "https://deno.land/x/docxml@1.4.0/src/classes/XmlComponent.ts";

Constructors

new
XmlComponent(props: PropsGeneric, ...children: ChildGeneric[])

Type Parameters

optional
PropsGeneric extends { [key: string]: unknown; } = { [key: string]: never; }
optional
ChildGeneric extends AnyXmlComponent | string = never

Properties

readonly
children: ChildGeneric[]

The children given to this component instance.

readonly
props: PropsGeneric

The props given to this component instance.

Methods

toNode(ancestry?: AnyXmlComponent[]): XmlComponentNodes

Create a DOM node for this XML component, one that can be stringified to schema-valid OOXML.

By default, an XML component would serialize to its children and string contents -- like a fragment. Most components have an override to use specific OOXML elememnts, such as <w:p>.

Static Properties

readonly
children: string[]

Informs the JSX pragma which child components are allowed in this component. The JSX pragma can use this to attempt repairs at invalidly nested children.

readonly
mixed: boolean

Informs the JSX pragma on wether or not this component can contain text (string) children. The JSX pragma can use this to attempt repairs at invalidly nested children.

Static Methods

matchesNode(_node: Node): boolean