New

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

API Referencev1.3.2

@eigenpal/docx-editor-core/editor

Functions(3)

Run the pure layout compute pass (the 6 steps in this file's header), lifted verbatim from `useLayoutPipeline`. The adapter performs the DOM paint (`renderPages`), scroll-restore, `painter:painted`, and state writeback with the returned values.

declare function computeLayout(inputs: ComputeLayoutInputs): LayoutComputation;
declare function createLayoutScheduler(run: (state: EditorState) => void, scheduleFrame?: (cb: () => void) => number, cancelFrame?: (handle: number) => void): LayoutScheduler;

Clear the scroll-into-view flag on `transaction` in place. Call inside `dispatchTransaction` before `state.apply(transaction)`. `probeTr` should be a fresh `view.state.tr` used only for the one-shot drift canary (so the real transaction is never mutated by the probe).

declare function stripScrollFlag(transaction: Transaction, probeTr: Transaction): void;

Interfaces(3)

interface ComputeLayoutInputs
MemberTypeSummary
columnsColumnLayout | undefined
contentWidthnumber
documentDocument | null
finalColumnsColumnLayout | undefined
finalMarginsPageMargins
finalPageSizePageSizePx
finalSectionPropertiesSectionProperties | null | undefined
firstPageFooterContentHeaderFooter | null | undefined
firstPageHeaderContentHeaderFooter | null | undefined
footerContentHeaderFooter | null | undefined
getHfPmDoc(hf: HeaderFooter) => Node | null | undefinedHF unification: the persistent PM doc for an HF, or null to re-parse content.
headerContentHeaderFooter | null | undefinedResolved HF objects for the section (default + first-page).
marginsPageMargins
measureBlocksMeasureBlocksFn
pageGapnumber
pageSizePageSizePx
sectionPropertiesSectionProperties | null | undefined
stateEditorState
stylesStyleDefinitions | null | undefined
themeTheme | null | undefined
interface LayoutComputation
MemberTypeSummary
blocksFlowBlock[]
firstPageFooterForRenderHeaderFooterContent | undefined
firstPageHeaderForRenderHeaderFooterContent | undefined
footerContentForRenderHeaderFooterContent | undefined
footerDistancePxnumber | undefined
footnotesByPageMap<number, FootnoteRenderItem[]> | undefined
hasTitlePgboolean
headerContentForRenderHeaderFooterContent | undefined
headerDistancePxnumber | undefined
layoutLayout
measuresMeasure[]
pageBordersSectionProperties['pageBorders'] | undefined
watermarkWatermark | undefined

rAF-coalescing layout scheduler shared by the React and Vue adapters (issue #696 Tier 2). Rapid doc-changing transactions (a burst of keystrokes) collapse to a single layout pass per animation frame: while a frame is pending, later `schedule` calls just replace the target state, so only the final state lays out.

`scheduleFrame`/`cancelFrame` are injected so a headless/test host can pass a synchronous stub; they default to requestAnimationFrame.

interface LayoutScheduler
MemberTypeSummary
cancelCancel any pending frame (call on teardown).
scheduleRequest a layout for `state`, coalesced into the pending frame.

Type aliases(1)

Adapter-supplied block measurer (React's is caching).

type MeasureBlocksFn = (blocks: FlowBlock[], contentWidth: number | number[], pageGeometry?: FloatPageGeometry) => Measure[];