New

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

API Referencev1.0.2

@eigenpal/docx-editor-core/prosemirror/utils/LayoutSelectionGate

Layout Selection Gate

Guards selection rendering until layout is up-to-date. Uses sequenced versioning to prevent stale cursor positions.

Classes(1)

LayoutSelectionGate coordinates the timing between document edits and layout reflow so that selection overlays are only painted against current DOM geometry.

Workflow: 1. Document changes → setStateSeq(++seq) 2. Layout starts → onLayoutStart() 3. Layout completes → onLayoutComplete(seq) 4. Selection update requested → requestRender() 5. If safe → callback is called

declare class LayoutSelectionGate
MemberTypeSummary
getDebugInfoGet debug info about current state.
getRenderSeqGet current layout render sequence.
getStateSeqGet current document state sequence.
incrementStateSeqIncrement document state sequence (convenience method). Returns the new sequence value.
isSafeToRenderCheck if it's safe to render selection. Safe when: layout is not updating AND render sequence = state sequence
onLayoutCompleteCalled when layout computation and DOM painting completes.
onLayoutStartCalled when layout computation starts.
onRenderRegister a callback to be called on render events.
requestRenderRequest a selection render. Will be executed when safe. If already safe, executes immediately.
resetReset the gate state (useful for testing or document reload).
setStateSeqSet the document state sequence (call when document changes). This should be called on every ProseMirror transaction that changes the doc.