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)
class
packages/core/src/prosemirror/index.ts:166LayoutSelectionGate
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| Member | Type | Summary |
|---|---|---|
| getDebugInfo | — | Get debug info about current state. |
| getRenderSeq | — | Get current layout render sequence. |
| getStateSeq | — | Get current document state sequence. |
| incrementStateSeq | — | Increment document state sequence (convenience method). Returns the new sequence value. |
| isSafeToRender | — | Check if it's safe to render selection. Safe when: layout is not updating AND render sequence = state sequence |
| onLayoutComplete | — | Called when layout computation and DOM painting completes. |
| onLayoutStart | — | Called when layout computation starts. |
| onRender | — | Register a callback to be called on render events. |
| requestRender | — | Request a selection render. Will be executed when safe. If already safe, executes immediately. |
| reset | — | Reset the gate state (useful for testing or document reload). |
| setStateSeq | — | Set the document state sequence (call when document changes). This should be called on every ProseMirror transaction that changes the doc. |