New

docx-editor 1.x has shipped. Vue support, i18n, agents. Read the migration guide →

API Referencev1.0.2

@eigenpal/docx-editor-core/layout-bridge/toFlowBlocks

ProseMirror to FlowBlock Converter

Converts a ProseMirror document into FlowBlock[] for the layout engine. Tracks pmStart/pmEnd positions for click-to-position mapping.

The deep import `@eigenpal/.../layout-bridge/toFlowBlocks` is part of the public surface (Vue adapter + tests), so the per-domain helpers under ./toFlowBlocks/ are re-exported from here to keep that path stable.

Functions(4)

Convert an OOXML BorderSpec to a layout-engine BorderStyle. Shared by paragraph borders, cell borders, and header/footer borders.

declare function convertBorderSpecToLayout(border: {
    style?: string;
    size?: number;
    space?: number;
    color?: {
        rgb?: string;
        themeColor?: string;
        themeTint?: string;
        themeShade?: string;
    };
}, theme?: Theme | null): BorderStyle | undefined;

Reset the block ID counter (useful for testing).

declare function resetBlockIdCounter(): void;

Resolve an OOXML lvlText template like "%1.%2." against the counter stack and per-level numFmt list (ECMA-376 §17.9.11).

When a referenced counter has no value yet (e.g. "%2" referenced from a level-0 paragraph), the placeholder AND the punctuation immediately following it are dropped — matches Word's behavior so "%1.%2." renders "1." rather than "1..".

Exported for unit testing.

declare function resolveListTemplate(template: string, counters: number[], levelNumFmts: NumberFormat[] | undefined): string;

Convert a ProseMirror document to FlowBlock array.

Walks the document tree, converting each node to the appropriate block type. Tracks pmStart/pmEnd positions for each block for click-to-position mapping.

declare function toFlowBlocks(doc: Node, options?: ToFlowBlocksOptions): FlowBlock[];

Type aliases(1)

Options for the conversion.

type ToFlowBlocksOptions = {
    defaultFont?: string;
    defaultSize?: number;
    theme?: Theme | null;
    pageContentHeight?: number;
    listCounters?: Map<number, number[]>;
    listSeenNumIds?: Set<string>;
};