docxml
Version:
TypeScript (component) library for building and parsing a DOCX file
63 lines (62 loc) • 2.19 kB
TypeScript
import { type ComponentAncestor, Component, ComponentContext } from '../classes/Component.js';
import { FileMime } from '../enums.js';
import { RelationshipsXml } from '../files/RelationshipsXml.js';
import { type Length } from '../utilities/length.js';
/**
* A type describing the components accepted as children of {@link Image}.
*/
export declare type ImageChild = never;
export declare type DataExtensions = {
svg?: Promise<string>;
};
/**
* A type describing the props accepted by {@link Image}.
*/
export declare type ImageProps = {
data: Promise<Uint8Array>;
mime?: FileMime;
dataExtensions?: DataExtensions;
title?: null | string;
alt?: null | string;
width: Length;
height: Length;
};
/**
* A component that represents an image in your DOCX document. You can create a new image by
* passing any promise to an `Uint8Array` into the `data` prop, eg. get it from your file system
* or from a web request.
*/
export declare class Image extends Component<ImageProps, ImageChild> {
#private;
static readonly children: string[];
static readonly mixed: boolean;
get meta(): {
readonly location: string;
readonly mime: Promise<FileMime>;
readonly relationshipId: string | null;
readonly extensions: {
readonly svg: {
readonly location: string;
readonly relationshipId: string | null;
} | undefined;
};
};
constructor(props: ImageProps, ...children: ImageChild[]);
/**
* An event hook with which this component can ensure that the correct relationship type is
* recorded to the relationship XML.
*/
ensureRelationship(relationships: RelationshipsXml): Promise<void>;
/**
* Creates an XML DOM node for this component instance.
*/
toNode(_ancestry: ComponentAncestor[]): 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, { archive, relationships }: ComponentContext): Image;
}