Skip to content

PT-2609: Add hasBuiltInContextMenu editor option - #58

Draft
rolfheij-sil wants to merge 2 commits into
mainfrom
pt-2609-built-in-context-menu-option
Draft

rolfheij-sil wants to merge 2 commits into
mainfrom
pt-2609-built-in-context-menu-option

Conversation

@rolfheij-sil

@rolfheij-sil rolfheij-sil commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds an editor option, hasBuiltInContextMenu (default true), that lets a host stop the editor from mounting its own right-click menu.

Platform.Bible is moving the Scripture editors' right-click menu to the platform's own context menu (PT-2609: localized, shadcn look, items declared in menus.json, Copy disabled without a selection). For that the host needs to switch the built-in ContextMenuPlugin off. The core PR that uses the option follows; nothing opts in yet, so no editor changes behaviour with this PR alone.

What changes

  • EditorOptions.hasBuiltInContextMenu?: boolean, marked @experimental. false skips mounting ContextMenuPlugin; unset or true is today's behaviour.
  • It is a dedicated option, not tied to hasExternalUI: Enhanced Resources, the footnote editor, the Storybook stories and this repo's own demos all pass hasExternalUI: true and still rely on the built-in menu.
  • ClipboardPlugin stays mounted either way, so EditorRef.cut()/copy()/paste()/pastePlainText() and the empty-copy guard are unaffected.
  • CHANGELOG entry under Unreleased; committed dist and etc rebuilt with pnpm rebuild-committed-output.

Later, once no host uses the built-in menu, ContextMenuPlugin, EditorOptions.contextMenu and this option can be removed together (a breaking change, not part of this PR).

Verification

Check Result
New tests in Editor.test.tsx (options.hasBuiltInContextMenu, 7 tests): red before the change (the 3 false cases failed, the 4 controls passed), green after; with the mount made unconditional again the same 3 fail 7 passed
nx test @eten-tech-foundation/platform-editor 5424 passed, 57 expected failures, 142 skipped
nx run-many -t typecheck 9 projects pass
nx run-many -t lint 0 errors
pnpm rebuild-committed-output, run last only packages/platform/dist and etc changed; platform-editor.api.md lists the new member

Not run: nx test shared-react (not touched); a live run in Platform.Bible (it happens in the core PR, against this branch staged locally; this description will be updated with the result); the /process-pr-feedback --verify-only pass and the full /pr-review pipeline (the source change is one option and one conditional mount). Instead, an independent reviewer with no prior context read the commit against the surrounding code: no important findings; its four minor ones (README options table, TSDoc on what the host must do, a duplicate test, a copy test that could not fail) are fixed in the second commit, where the new empty-copy test was shown to fail with the guard removed.

AI-assisted — session

🤖 Generated with Claude Code

https://claude.ai/code/session_012P3p4beP5twfPwL6U3xjTX


This change is Reviewable

rolfheij-sil and others added 2 commits November 19, 2026 19:22
… right-click menu

The new experimental editor option hasBuiltInContextMenu (default true) controls whether the
editor mounts its own right-click menu. A host that shows its own menu sets it to false. It is
independent of hasExternalUI, which other consumers pass while still relying on the built-in menu.
The clipboard plugin stays mounted, so EditorRef.copy() keeps working.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012P3p4beP5twfPwL6U3xjTX
…menu off

Add the option to the package README options table, note on contextMenu that its items are ignored
when the built-in menu is off, and spell out in the TSDoc that the host must then prevent the
browser's own menu itself. Mark the changelog entry experimental. Drop a test that duplicated
another and add one proving a collapsed-selection copy() still writes nothing with the menu off.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012P3p4beP5twfPwL6U3xjTX
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