From 0dc60d9e156f5816b3e6645c548859e39a26ff6c Mon Sep 17 00:00:00 2001 From: Lahiru Weliwitiya Date: Mon, 2 Nov 2026 16:56:44 +0530 Subject: [PATCH] fix(write): group the copy items above the paste items in the Edit menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Write added "Copy as ▸" after the shell's "Paste without formatting", so it sat below the paste items. It now follows Copy, and only "Paste as Markdown" follows the paste items: Cut, Copy, Copy as ▸, then Paste, Paste without formatting, Paste as Markdown. Wonky-Task: T-23 Co-Authored-By: Claude Opus 5.5 --- specs/wonky_write/05-screens-menus-toolbar.md | 4 ++ wonky_write/lib/config/write_menus.dart | 5 +- .../features/config/write_menus_test.dart | 16 +++++++ .../screen/write_document_screen_test.dart | 48 +++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/specs/wonky_write/05-screens-menus-toolbar.md b/specs/wonky_write/05-screens-menus-toolbar.md index 06ace67a..de16060a 100644 --- a/specs/wonky_write/05-screens-menus-toolbar.md +++ b/specs/wonky_write/05-screens-menus-toolbar.md @@ -316,6 +316,10 @@ Write behaviour noted. | Find next / previous | `write.find.next` / `previous` | ⌘G / ⌘⇧G | Ctrl+G, F3 / Ctrl+Shift+G, Shift+F3 | query set | | Go to heading… | `write.nav.goToHeading` | ⌘⌥G | Ctrl+Alt+G | outline non-empty | +The copy items (Cut, Copy, *Copy as ▸*) form one group, directly above the paste items (Paste, +Paste without formatting, Paste as Markdown): Write inserts *Copy as ▸* after the shell's Copy +and *Paste as Markdown* after its *Paste without formatting* (`write_menus.dart`, T-23). + ### 7.3 View | Item | Command | macOS | Win/Linux | Enabled when | diff --git a/wonky_write/lib/config/write_menus.dart b/wonky_write/lib/config/write_menus.dart index 97a16217..1f3655c6 100644 --- a/wonky_write/lib/config/write_menus.dart +++ b/wonky_write/lib/config/write_menus.dart @@ -65,13 +65,16 @@ MenuRoot writeMenus(ShellMenus shell, {WriteLocalizations? l10n}) { ]); // ---- Edit (§7.2) ---- + // The copy items together, right above the paste items. root = root - .insertAfter('shell.edit.pasteWithoutFormatting', [ + .insertAfter('shell.edit.copy', [ MenuSpec.submenu('edit.copyAs', l.menuCopyAs, [ _c('write.edit.copyAsMarkdown', label: l.menuCopyAsMarkdown), _c('write.edit.copyAsPlainText', label: l.menuCopyAsPlainText), _c('write.edit.copyAsHtml', label: l.menuCopyAsHtml), ]), + ]) + .insertAfter('shell.edit.pasteWithoutFormatting', [ _c('write.edit.pasteAsMarkdown', label: l.cmdEditPasteAsMarkdown), ]) .insertAfter('shell.edit.selectAll', [_c('write.edit.delete')]) diff --git a/wonky_write/test/features/config/write_menus_test.dart b/wonky_write/test/features/config/write_menus_test.dart index 064b073c..9a0f7099 100644 --- a/wonky_write/test/features/config/write_menus_test.dart +++ b/wonky_write/test/features/config/write_menus_test.dart @@ -38,6 +38,22 @@ void main() { ); }); + test('when reading the Edit menu then the copy items are together, right ' + 'above the paste items (Write 05 §7.2, T-23)', () { + final edit = menus.find(ShellMenuIds.edit)! as MenuSubmenu; + final ids = [for (final s in edit.children) s.effectiveId]; + final cut = ids.indexOf('shell.edit.cut'); + + expect(ids.sublist(cut, cut + 6), [ + 'shell.edit.cut', + 'shell.edit.copy', + 'edit.copyAs', + 'shell.edit.paste', + 'shell.edit.pasteWithoutFormatting', + 'write.edit.pasteAsMarkdown', + ]); + }); + test('when walking the menubar then menu ids are unique', () { final ids = []; void walk(List specs) { diff --git a/wonky_write/test/features/screen/write_document_screen_test.dart b/wonky_write/test/features/screen/write_document_screen_test.dart index 5fcaa72d..a7c2c39c 100644 --- a/wonky_write/test/features/screen/write_document_screen_test.dart +++ b/wonky_write/test/features/screen/write_document_screen_test.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:flutter/material.dart' show Material, MaterialType; +import 'package:flutter/services.dart' show LogicalKeyboardKey; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:provider/provider.dart'; @@ -140,6 +141,53 @@ void main() { expect(tester.takeException(), isNull); }); + for (final dark in [false, true]) { + testWidgets('Given an open document (${dark ? 'dark' : 'light'}) when ' + 'opening the Edit menu then the copy items are together, right above ' + 'the paste items (Write 05 §7.2, T-23)', (tester) async { + await pumpScreen(tester, dark: dark); + + await tester.tap(find.byKey(const ValueKey('menubar.edit'))); + await tester.pumpAndSettle(); + + // Top to bottom as rendered. + const clipboard = [ + 'shell.edit.cut', + 'shell.edit.copy', + 'edit.copyAs', + 'shell.edit.paste', + 'shell.edit.pasteWithoutFormatting', + 'write.edit.pasteAsMarkdown', + ]; + final tops = [ + for (final id in clipboard) + tester.getTopLeft(find.byKey(ValueKey('menu.$id'))).dy, + ]; + for (var i = 1; i < tops.length; i++) { + expect( + tops[i], + greaterThan(tops[i - 1]), + reason: '${clipboard[i]} below ${clipboard[i - 1]}', + ); + } + // Nothing else between the last copy item and the first paste item. + final between = find.byWidgetPredicate((w) { + final key = w.key; + if (key is! ValueKey || !key.value.startsWith('menu.')) { + return false; + } + final top = tester.getTopLeft(find.byWidget(w)).dy; + return top > tops[2] && top < tops[3]; + }); + expect(between, findsNothing); + expect(tester.takeException(), isNull); + + await tester.sendKeyEvent(LogicalKeyboardKey.escape); + await tester.pumpWidget(const SizedBox()); + await tester.pump(const Duration(seconds: 2)); + }); + } + for (final width in [760.0, 1024.0]) { for (final dark in [false, true]) { testWidgets('Given a ${width.toInt()} px wide ${dark ? 'dark' : 'light'} '