Skip to content

feat(editor): slash command menu (PRSM-47) - #15

Merged
nchopra merged 2 commits into
mainfrom
slash
May 15, 2026
Merged

feat(editor): slash command menu (PRSM-47)#15
nchopra merged 2 commits into
mainfrom
slash

Conversation

@nchopra

@nchopra nchopra commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Notion-style `/` command menu for the TipTap note editor. Built on `@tiptap/suggestion` + a custom React popover. Renderer-only — no schema changes, no markdown round-trip impact.

Items (10): Heading 1/2/3, Bullet list, Numbered list, Check list, Quote, Code block, Divider, Table. No skill / artifact items — those have their own surfaces.

Trigger: `/` at the start of an empty paragraph (optionally after a single leading space). Mid-sentence `/` does not fire. Disabled inside `tableCell` / `tableHeader` / `artifact` wrappers.

Notable design choices

  • Renderer-only. Mounted in `buildRendererExtensions`, NOT in `buildEditorExtensions` (the headless schema). Markdown export/import and Yjs collab schema are untouched.
  • `set` not `toggle`.** Headings/quote/code-block items use `setHeading` / `setBlockquote` / `setCodeBlock`. Lists keep `toggle*` (TipTap 3.x list extensions don't expose `set*` variants) but are guarded by `editor.isActive(...)` — picking the type you're already in is a no-op instead of demoting.
  • Viewport clamp + flip-up. Popover flips above the caret when there's no room below; left edge clamps inside the viewport.

After Opus adversarial review

Opus surfaced 3 required + 3 nice-to-have items; all 6 addressed in commit `bd5283b`:

  • viewport clamp + flip
  • `allow` walks ancestors to exclude unwanted parents
  • set-not-toggle (with isActive guard for lists)
  • tighter `Suggestion<SlashMenuItem, SlashMenuItem>` generic
  • `role="listbox"` on the `
      `
    • dropped dead Escape branch in `onKeyDown`

    Test plan

    Automated:

    • `pnpm -F desktop type:check` — clean
    • `pnpm -F desktop test --run tests/editor/` — 25 tests pass (8 files; 3 new in `slash-menu-items.test.ts`)

    Manual smoke (please verify in dev):

    • Type `/` at start of an empty paragraph at the top, middle, and bottom of the viewport — popover appears; flips up near the bottom.
    • Mid-sentence `/` does NOT trigger.
    • Inside a table cell paragraph: `/` does NOT trigger.
    • Inside an artifact block: `/` does NOT trigger.
    • Each item produces the expected node tree; trigger text is replaced cleanly.
    • Inside an existing bullet list, picking "Bullet list" is a no-op (does NOT demote to paragraph).
    • ArrowUp/ArrowDown navigates; Enter applies; Esc dismisses.
    • Click selects.

@nchopra
nchopra requested a review from haritabh-z01 May 15, 2026 01:20
@nchopra
nchopra merged commit c60034c into main May 15, 2026
6 checks passed
@nchopra
nchopra deleted the slash branch May 15, 2026 01:33
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.

1 participant