UNPKG

docx

Version:

Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.

33 lines (32 loc) 1.43 kB
import { default as JSZip } from 'jszip'; import { FileChild } from '../file/file-child'; import { ParagraphChild } from '../file/paragraph'; import { OutputByType, OutputType } from '../util/output-type'; export type InputDataType = Buffer | string | number[] | Uint8Array | ArrayBuffer | Blob | NodeJS.ReadableStream | JSZip; export declare const PatchType: { readonly DOCUMENT: "file"; readonly PARAGRAPH: "paragraph"; }; type ParagraphPatch = { readonly type: typeof PatchType.PARAGRAPH; readonly children: readonly ParagraphChild[]; }; type FilePatch = { readonly type: typeof PatchType.DOCUMENT; readonly children: readonly FileChild[]; }; export type IPatch = ParagraphPatch | FilePatch; export type PatchDocumentOutputType = OutputType; export type PatchDocumentOptions<T extends PatchDocumentOutputType = PatchDocumentOutputType> = { readonly outputType: T; readonly data: InputDataType; readonly patches: Readonly<Record<string, IPatch>>; readonly keepOriginalStyles?: boolean; readonly placeholderDelimiters?: Readonly<{ readonly start: string; readonly end: string; }>; readonly recursive?: boolean; }; export declare const patchDocument: <T extends PatchDocumentOutputType = PatchDocumentOutputType>({ outputType, data, patches, keepOriginalStyles, placeholderDelimiters, recursive, }: PatchDocumentOptions<T>) => Promise<OutputByType[T]>; export {};