prosemirror-docx-web
Version:
Export from a prosemirror document to Microsoft word forked from curvenote/prosemirror-docx
88 lines (87 loc) • 4.28 kB
TypeScript
import { Mark, Node as ProsemirrorNode, Schema } from 'prosemirror-model';
import { ICommentOptions, IParagraphOptions, IRunOptions, Paragraph, ParagraphChild } from 'docx';
import { INumbering, NumberingStyles } from './numbering';
export declare type AlignOptions = 'left' | 'center' | 'right';
export declare type NodeSerializer<S extends Schema = any> = Record<string, (state: DocxSerializerState<S>, node: ProsemirrorNode<S>, parent: ProsemirrorNode<S>, index: number) => void>;
export declare type MarkSerializer<S extends Schema = any> = Record<string, (state: DocxSerializerState<S>, node: ProsemirrorNode<S>, mark: Mark<S>) => IRunOptions>;
interface ImageBuffer {
arrayBuffer: string | ArrayBuffer;
width: number;
height: number;
}
export declare type Options = {
getImageBuffer: (src: string) => ImageBuffer;
};
export declare type IMathOpts = {
inline?: boolean;
id?: string | null;
numbered?: boolean;
};
export declare class DocxSerializerState<S extends Schema = any> {
private numberingStyles;
private cslFormatService;
private bibliographyTitle;
nodes: NodeSerializer<S>;
options: Options;
marks: MarkSerializer<S>;
children: Paragraph[] | any;
numbering: INumbering[];
nextRunOpts?: IRunOptions;
current: ParagraphChild[] | any;
currentLink?: {
link: string;
children: IRunOptions[];
};
comments: ICommentOptions[];
pageBreak: string;
nextParentParagraphOpts?: IParagraphOptions;
currentNumbering?: {
reference: string;
level: number;
};
private footnoteIdx;
private footnoteState;
private footnoteIds;
private maxImageWidth;
fullCiteContents: Record<string, string>;
transformHtmlToNode: (html: string) => null;
constructor(nodes: NodeSerializer<S>, marks: MarkSerializer<S>, options: Options, fullCiteContents: Record<string, string>, pageBreak?: string, numberingStyles?: Record<NumberingStyles, any> | null, cslFormatService?: any, bibliographyTitle?: string, footnoteState?: string, transformHtmlToNode?: (html: string) => null);
renderContent(parent: ProsemirrorNode, opts?: IParagraphOptions): void;
render(node: ProsemirrorNode<S>, parent: ProsemirrorNode<S>, index: number): void;
renderMarks(node: ProsemirrorNode<S>, marks: Mark[]): IRunOptions;
renderParagraphHtml(html: string): any;
openLink(href: string): void;
curIdx: number;
wrapComment(node: ProsemirrorNode): void;
closeLink(): void;
openTable(): void;
closeTable(): void;
hierarchy_title(node: ProsemirrorNode<S>): void;
horizontal_rule(node: ProsemirrorNode<S>): void;
renderInline(parent: ProsemirrorNode<S>): void;
renderList(node: ProsemirrorNode<S>, style: NumberingStyles): void;
renderListItem(node: ProsemirrorNode<S>): void;
addParagraphOptions(opts: IParagraphOptions): void;
addRunOptions(opts: IRunOptions): void;
text(text: string | null | undefined, opts?: IRunOptions): void;
math(latex: string, opts?: IMathOpts): void;
bib_cite(node: ProsemirrorNode<S>): void;
bibliography(node: ProsemirrorNode<S>): void;
footnoteRef(id: string): void;
imageWithType(): void;
image(src: string, align?: AlignOptions, widthPercent?: number): void;
imageInline(src: string): void;
addAside(text?: string): void;
addCodeBlock(node: ProsemirrorNode): void;
captionLabel(id: string, kind: 'Figure' | 'Table'): void;
table(node: ProsemirrorNode<S>): void;
columns(node: ProsemirrorNode<S>): void;
closeBlock(node: ProsemirrorNode<S>, props?: IParagraphOptions): void;
}
export declare class DocxSerializer<S extends Schema = any> {
nodes: NodeSerializer<S>;
marks: MarkSerializer<S>;
constructor(nodes: NodeSerializer<S>, marks: MarkSerializer<S>);
serialize(content: ProsemirrorNode<S>, options: Options, footerText: string | undefined, footnotes: string[] | undefined, pageOptions: any, fullCiteContents: Record<string, string>, externalStyles?: any, numberingStyles?: Record<NumberingStyles, any> | null, cslFormatService?: any, bibliographyTitle?: string, footnoteTitle?: string, transformHtmlToNode?: (html: string) => any, log?: (...args: any[]) => void): import("docx").Document;
}
export {};