Skip to content

Conversation

@asumaran
Copy link

@asumaran asumaran commented Feb 13, 2026

Problem

The slash menu (/) was completely invisible in presentation mode (layout engine enabled). Pressing / would steal focus to the menu's hidden search input, blocking all typing, but the menu itself was rendered off-screen at ~left: -9900px.

Root cause: Editor.coordsAtPos() always used the ProseMirror view's coordinates, but in presentation mode the PM view is hidden off-screen (left: -9999px). The layout engine renders the visible content separately.

Fixes #781

Changes

  1. Editor.coordsAtPos: delegate to PresentationEditor.coordsAtPos() when available, which returns visual layout coordinates instead of hidden PM view coordinates.

  2. PresentationEditor.coordsAtPos: add caret geometry fallback via #computeCaretLayoutRect + denormalizeClientPoint for positions where getRangeRects returns empty (collapsed selections on empty lines).

  3. Slash menu plugin: add surface top-left fallback when coordsAtPos returns null (blank document before first layout). Set MENU_OFFSET_X to 0 so the menu aligns with the cursor.

Test plan

  • pnpm dev (layout engine ON by default)
  • Blank document: press /, menu appears at top-left of editor
  • Type several lines, press Enter for new line, press /, menu appears at cursor position
  • Right-click context menu still works as before
  • pnpm test, all 5545 tests pass

In presentation mode the ProseMirror view is hidden off-screen
(left: -9999px), so view.coordsAtPos() returns coordinates in
the hidden editor's space. Delegate to PresentationEditor.coordsAtPos()
which computes visual layout coordinates instead.

This was the root cause of the slash menu being positioned off-screen
when triggered via "/" in presentation mode.
getRangeRects returns empty for collapsed selections on empty lines
because there is no painted inline content to measure. Fall back to
#computeCaretLayoutRect which combines DOM position data with layout
metrics, then convert to viewport coordinates via denormalizeClientPoint.
Two fixes for slash menu positioning:

- Add fallback when coordsAtPos returns null (e.g. blank document
  before first layout): position the menu at the top-left of the
  visible editor surface instead of leaving coordinates at (0,0)
  which ends up off-screen after containing-block adjustment.

- Set MENU_OFFSET_X to 0 so the menu aligns with the cursor position.
  The previous 100px offset was never noticed because the menu was
  invisible in presentation mode.
@asumaran asumaran changed the title Fix/slash menu position presentation mode fix: slash menu invisible in presentation mode Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

why sometimes slash-menu-items doesn't exist

1 participant