Use one menu lifecycle and shared menu rows in the editors

Phase 4c. The Markdown, code, Read, and image menus open through
showActionMenu. It closes a menu on an outside press, an outside scroll,
a resize, and window blur. A host surface now gives its own focus
return, so four copies of the listener code are gone.

- menuItems.ts builds Undo, Redo, the clipboard rows, and the search
  row. The Markdown, code, Read, table cell, and table range menus use
  it. The Markdown and table menus now show the shortcuts for Cut,
  Copy, Paste, and Select all, as the other menus did.
- writerSearch.ts is now editorSearch.ts, because it serves Write and
  Source.
- Plugins still get only close() from api.ui.showActionMenu. The SDK
  menu types do not change.
- The table range menu and the native spelling menu keep their own
  lifecycle, because their open state drives table editing and the
  native spelling protocol.
- docs/ui-design.md names the shared rows and the search modules. The
  menu inventory has the new count for markdownMenu.ts.

pnpm check, pnpm test (341 of 341), and the full smoke suite pass, except
tables/formulas, which failed one time under load and passed on retry.
This commit is contained in:
Knotty Wyvern
2026-10-28 11:09:09 -07:00
parent 724402729e
commit 6cd9195370
17 changed files with 152 additions and 135 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ await runSmoke("editor/surfaces", async ({ page }) => {
await text.click({ button: 'right', position: { x: 20, y: 8 } });
const writer = menu('Markdown text actions');
assert.deepEqual(await styles(writer), reference);
for (const name of ['Add link', 'Add external link', 'Format', 'Paragraph', 'Insert', 'Paste', 'Select all']) assert.equal(await item(name).count(), 1);
for (const name of ['Add link', 'Add external link', 'Format', 'Paragraph', 'Insert', 'Paste Ctrl+V', 'Select all Ctrl+A']) assert.equal(await item(name).count(), 1);
await item('Corrected').waitFor();
assert.equal(await item('Spelling').count(), 0, 'Corrections appear directly in the main menu');
assert.equal(await writer.locator(':scope > button').first().textContent(), 'Corrected');