docxml
Version:
TypeScript (component) library for building and parsing a DOCX file
51 lines (50 loc) • 1.98 kB
TypeScript
import { FileMime } from '../enums.js';
import { ContentTypesXml } from '../files/ContentTypesXml.js';
import { type Archive } from './Archive.js';
import { type BinaryFile } from './BinaryFile.js';
declare abstract class XmlFileBase {
static readonly contentType: FileMime;
readonly location: string;
protected constructor(location: string);
get contentType(): FileMime;
/**
* Create a (slimdom) Document DOM for this XML file. This is useful for serializing it to string
* and writing to a ZIP/DOCX archive later.
*/
protected toNode(): Document | Promise<Document>;
/**
* @deprecated FOR TEST PURPOSES ONLY
*/
$$$toNode(): Document | Promise<Document>;
/**
* Get all XmlFile instances related to this one, including self. This helps the system
* serialize itself back to DOCX fullly. Probably not useful for consumers of the library.
*
* By default only returns the instance itself but no other related instances.
*/
getRelated(): Array<XmlFileBase | BinaryFile>;
/**
* Let a file tell the system when it is effectively empty, so it can be omitted from the archive.
*/
isEmpty(): boolean;
/**
* Add all related files to the given archive.
*/
addToArchive(archive: Archive): Promise<void>;
}
export declare class XmlFile extends XmlFileBase {
/**
* Promise a new JS instance of this file based on the given archive.
*/
static fromArchive(_archive: Archive, location: string): Promise<XmlFile>;
}
export declare class UnhandledXmlFile extends XmlFile {
#private;
protected constructor(location: string, xml: string);
protected toNode(): Document;
static fromArchive(archive: Archive, location: string): Promise<UnhandledXmlFile>;
}
export declare class XmlFileWithContentTypes extends XmlFileBase {
static fromArchive(_archive: Archive, _contentTypes: ContentTypesXml, location: string): Promise<XmlFile>;
}
export {};