From 2c270a1d57c1ec34bde9e1fba93804a8f42d4281 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 00:03:55 -0800 Subject: [PATCH] =?UTF-8?q?Context=20menu:=20the=20Spelling=20submenu=20on?= =?UTF-8?q?=20type=20also=20has=20Check=20Spelling=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A right-click on type now has Check Spelling… after Auto Spell Check in its Spelling submenu, as Edit › Spelling has it. The item runs the existing ui.checkSpelling command on the selection, which the right-click sets to the type under the pointer. A right-click on an underlined word offers it too. The help page describes this right-click route to the dialog: https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/check-and-correct-spelling.html The context menu draws check marks only in a submenu of toggles alone. The Spelling submenu now also shows them, so Auto Spell Check keeps its mark next to the plain Check Spelling… item. Other submenus are unchanged. --- crates/ui-egui/src/menus/bar.rs | 12 +++-- crates/ui-egui/src/menus/context.rs | 13 +++-- crates/ui-egui/src/tests/contextmenu.rs | 64 ++++++++++++++++++++++++- docs/gaps.md | 2 +- docs/target-app-parity.md | 2 +- 5 files changed, 82 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/menus/bar.rs b/crates/ui-egui/src/menus/bar.rs index 85588620e8..72cbc4535b 100644 --- a/crates/ui-egui/src/menus/bar.rs +++ b/crates/ui-egui/src/menus/bar.rs @@ -138,7 +138,7 @@ pub(super) fn render_items(app: &VectorcraftApp, ui: &mut egui::Ui, items: &[Ite ui.menu_button(label, |ui| { widgets::menu_scroll(ui, |ui| { widgets::menu_min_width(ui, 200.0); - render_items(app, ui, children, checks || only_toggles(app, children), clicked); + render_items(app, ui, children, checks || shows_marks(app, children), clicked); }); }); } @@ -147,8 +147,14 @@ pub(super) fn render_items(app: &VectorcraftApp, ui: &mut egui::Ui, items: &[Ite } } -/// Whether every item of a submenu can be on or off: a menu drawn without check marks (the canvas -/// context menu) still shows them there, since its label alone can't say whether it is on. +/// Whether a submenu of a menu drawn without check marks (the canvas context menu) still shows +/// them: when every item can be on or off, or when it holds Auto Spell Check (the Spelling +/// submenu, with Check Spelling… after it), since a toggle's label alone can't say whether it is on. +fn shows_marks(app: &VectorcraftApp, items: &[Item]) -> bool { + only_toggles(app, items) || items.iter().any(|it| matches!(it, Item::Cmd(_, "edit.autoSpellCheck", _))) +} + +/// Whether every item of a submenu can be on or off. fn only_toggles(app: &VectorcraftApp, items: &[Item]) -> bool { let mut rows = items.iter().filter_map(|it| entry(app, it)).filter(|e| !matches!(e, Entry::Sep)).peekable(); rows.peek().is_some() && rows.all(|e| matches!(e, Entry::Item(r) if r.checked.is_some())) diff --git a/crates/ui-egui/src/menus/context.rs b/crates/ui-egui/src/menus/context.rs index 68b2a93574..ca7dae0ef5 100644 --- a/crates/ui-egui/src/menus/context.rs +++ b/crates/ui-egui/src/menus/context.rs @@ -96,10 +96,13 @@ pub fn context_items(app: &VectorcraftApp) -> Vec { // The paragraphs of the selected type, or those the Type tool's selection touches. if crate::panels::character::text_style(app).is_some() { v.push(sub("Bullets and Numbering", vec![c("Apply Bullets", "type.applyBullets"), c("Apply Numbers", "type.applyNumbers")])); - // A right-click on type turns Auto Spell Check on or off, as Edit › Spelling does, per - // the public [Check and correct spelling](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/check-and-correct-spelling.html) - // page. Its submenu holds only toggles, so it shows the check mark (`render_items`). - v.push(sub("Spelling", vec![c("Auto Spell Check", "edit.autoSpellCheck")])); + // A right-click on type turns Auto Spell Check on or off and opens Check Spelling…, as + // Edit › Spelling does, per the public [Check and correct spelling](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/check-and-correct-spelling.html) + // page. The submenu shows Auto Spell Check's check mark (`render_items`). + v.push(sub( + "Spelling", + vec![c("Auto Spell Check", "edit.autoSpellCheck"), c("Check Spelling…", crate::dialogs::check_spelling::COMMAND)], + )); } v.extend([c("Make Guides", "view.guides.make"), Sep, sub("Transform", transform_items())]); if intertwine.is_none() { @@ -274,7 +277,7 @@ pub fn context_menu_body(app: &VectorcraftApp, ui: &mut egui::Ui, clicked: &mut widgets::menu_scroll(ui, |ui| { widgets::menu_min_width(ui, 200.0); // Its toggles already say what they do (Show Rulers, Hide Guides): no check-mark gutter, - // except in a submenu of toggles alone (Spelling › Auto Spell Check). + // except in a submenu of toggles alone and in Spelling, for Auto Spell Check. render_items(app, ui, &context_items(app), false, clicked); }); } diff --git a/crates/ui-egui/src/tests/contextmenu.rs b/crates/ui-egui/src/tests/contextmenu.rs index b73bb08dfa..d82edabe51 100644 --- a/crates/ui-egui/src/tests/contextmenu.rs +++ b/crates/ui-egui/src/tests/contextmenu.rs @@ -383,7 +383,7 @@ fn selected_type_has_apply_numbers() { /// A right-click on type has Spelling › Auto Spell Check, which turns it on or off as Edit › /// Spelling does (helpx: Check and correct spelling, "Turn on Auto Spell Check"). The context menu -/// draws no check marks, but this submenu holds only the toggle, so it shows whether it is on; +/// draws no check marks, but this submenu shows whether it is on, with Check Spelling… after it; /// other submenus stay without the room for one. Other art has no Spelling submenu. #[test] fn right_click_on_type_turns_auto_spell_check_on_and_off() { @@ -417,10 +417,72 @@ fn right_click_on_type_turns_auto_spell_check_on_and_off() { assert!(!has(&texts, "Spelling"), "the menu closed: {texts:?}"); let texts = open_spelling(&mut app); assert!(texts.iter().any(|(s, _)| s == "✓ Auto Spell Check"), "checked: {texts:?}"); + assert!(texts.iter().any(|(s, _)| s == "Check Spelling…"), "the dialog's item, which has no check mark: {texts:?}"); click(&mut app, &ctx, at(&texts, "✓ Auto Spell Check"), PointerButton::Primary); assert!(!app.ui.view.auto_spell_check, "turned off"); } +/// A right-click on type has Spelling › Check Spelling… after Auto Spell Check, as Edit › +/// Spelling has, which opens the Check Spelling dialog on the type right-clicked (helpx: Check and +/// correct spelling). Other art has no such item. +#[test] +fn right_click_on_type_opens_check_spelling() { + let mut app = app(); + rect(&mut app, 200.0, 150.0); + let t = NodeId(app.run("text.create", json!({"x": 20, "y": 60, "text": "Hello wrold", "size": 24})).unwrap()["id"].as_u64().unwrap()); + app.run("select.none", json!({})).unwrap(); + let ctx = egui::Context::default(); + frame(&mut app, &ctx, vec![]); + let p = screen(&app, 250.0, 200.0); + click(&mut app, &ctx, p, PointerButton::Secondary); + let dialog_item = |app: &VectorcraftApp| { + menus::context_entries(app).into_iter().position(|e| e.command.as_deref() == Some(crate::dialogs::check_spelling::COMMAND)) + }; + assert!(dialog_item(&app).is_none(), "a rectangle has no Check Spelling…"); + let away = screen(&app, 390.0, 290.0); + click(&mut app, &ctx, away, PointerButton::Primary); + let p = word_at(&app, t, 0, 5); + let texts = click(&mut app, &ctx, p, PointerButton::Secondary); + assert_eq!(app.session.active().unwrap().selection.objects, [t], "the type right-clicked is selected"); + // Agents see it under the Spelling path, after Auto Spell Check. + let entries = menus::context_entries(&app); + let i = dialog_item(&app).expect("Check Spelling…"); + assert_eq!((entries[i].path.as_slice(), entries[i].label.as_str(), entries[i].enabled), (&["Spelling".to_string()][..], "Check Spelling…", true)); + assert_eq!(entries.get(i.wrapping_sub(1)).and_then(|e| e.command.as_deref()), Some("edit.autoSpellCheck")); + frame(&mut app, &ctx, vec![Event::PointerMoved(at(&texts, "Spelling"))]); + let texts = frame(&mut app, &ctx, vec![]); + let (auto, check) = (at(&texts, " Auto Spell Check"), at(&texts, "Check Spelling…")); + assert!(auto.y < check.y, "Auto Spell Check first: {texts:?}"); + let texts = click(&mut app, &ctx, check, PointerButton::Primary); + assert!(!has(&texts, "Spelling"), "the menu closed: {texts:?}"); + let d = app.ui.dialog.as_ref().expect("a dialog opened"); + assert_eq!(d.kind.as_str(), crate::dialogs::check_spelling::KIND); + assert_eq!(d.fields["ids"], json!([t.0]), "it checks the type right-clicked"); + assert_eq!(d.fields["not_in_dictionary"], json!("wrold"), "and stops at its unknown word"); +} + +/// A right-click on a word Auto Spell Check underlined lists the suggestions, Ignore All and Add +/// to Dictionary, and the type's Spelling submenu with Check Spelling… as well. +#[test] +fn right_click_on_an_underlined_word_also_offers_check_spelling() { + let mut app = app(); + let id = spelled(&mut app, "the speling cat"); + let ctx = egui::Context::default(); + frame(&mut app, &ctx, vec![]); + let p = word_at(&app, id, 4, 11); + let texts = click(&mut app, &ctx, p, PointerButton::Secondary); + assert!(has(&texts, "Ignore All") && has(&texts, "Add to Dictionary"), "{texts:?}"); + let e = menus::context_entries(&app).into_iter().find(|e| e.command.as_deref() == Some(crate::dialogs::check_spelling::COMMAND)); + assert_eq!(e.map(|e| e.path), Some(vec!["Spelling".to_string()]), "Spelling › Check Spelling…"); + frame(&mut app, &ctx, vec![Event::PointerMoved(at(&texts, "Spelling"))]); + let texts = frame(&mut app, &ctx, vec![]); + assert!(texts.iter().any(|(s, _)| s == "✓ Auto Spell Check"), "checked: {texts:?}"); + click(&mut app, &ctx, at(&texts, "Check Spelling…"), PointerButton::Primary); + let d = app.ui.dialog.as_ref().expect("a dialog opened"); + assert_eq!(d.kind.as_str(), crate::dialogs::check_spelling::KIND); + assert_eq!(d.fields["not_in_dictionary"], json!("speling")); +} + /// The members of the overlap area of Intertwine group `g` at (x, y), in the order they are drawn /// there, bottom first. fn intertwine_order(app: &VectorcraftApp, g: NodeId, x: f64, y: f64) -> Vec { diff --git a/docs/gaps.md b/docs/gaps.md index eda7bb21dd..90bd9d4a8d 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -460,7 +460,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi - **Done:** COLR and SVG glyphs go with type that geometry effects reshape, into Expand Appearance and EMF/WMF export, where the type's outlines used to leave them out; bitmap glyphs (emoji) too, as images that hold their own pixels until a document takes them in; estimate unchanged. -- **Done:** spell check (#4936): engine (`text.spelling.check` and `text.spelling.suggest` on craft-proof); custom dictionary and Ignore All (`text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary`, `ignoreAll`); Auto Spell Check (`edit.autoSpellCheck`) with red wavy underlines and canvas context menu suggestions, Ignore All and Add to Dictionary; Edit › Edit Custom Dictionary…; and modal Check Spelling dialog (Edit › Spelling › Check Spelling…, `ui.checkSpelling`) with sentence context, suggestions list, "Change to" edit, Ignore, Ignore All, Change, Change All, Add to Dictionary, Done, Cancel, and keyboard navigation. Estimate unchanged. +- **Done:** spell check (#4936): engine (`text.spelling.check` and `text.spelling.suggest` on craft-proof); custom dictionary and Ignore All (`text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary`, `ignoreAll`); Auto Spell Check (`edit.autoSpellCheck`) with red wavy underlines and canvas context menu suggestions, Ignore All and Add to Dictionary; Edit › Edit Custom Dictionary…; and modal Check Spelling dialog (Edit › Spelling › Check Spelling…, and Spelling › Check Spelling… in the canvas context menu of type, `ui.checkSpelling`) with sentence context, suggestions list, "Change to" edit, Ignore, Ignore All, Change, Change All, Add to Dictionary, Done, Cancel, and keyboard navigation. Estimate unchanged. - **Missing:** CJK vertical composition (custom mojikumi sets and the Mojikumi Settings dialog, kinsoku settings #633, manual tate-chu-yoko), Middle Eastern features beyond bidi, digit types, Character Direction and Kashidas (a split caret; the Middle Eastern & South Asian composers are done, #4935), diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 0782bacab9..197b3333b9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2596,7 +2596,7 @@ Auto Spell Check followed (2026-11-09): the same page has Edit › Spelling › The right-click followed (2026-11-10), as the same page's "Correct spelling errors during Auto Spell Check" describes it: right-click a word with a red underline, then choose a suggested word, Ignore All to skip it in the current document, or Add to Dictionary (#4936). The canvas context menu lists the words `text.spelling.suggest` gives for it in its run's language, each replacing the word with `text.editRange` as one undo step, or No Suggestions; then Ignore All (`text.spelling.ignoreAll`) and Add to Dictionary (`text.spelling.addWord`). It lists nothing for a word that is right, with Auto Spell Check off, or once the word under the right-click has changed (`ui-egui/src/tests/contextmenu.rs`). The dialogs remain. -The page's other way to turn Auto Spell Check on followed (2026-11-10): right-click the text and choose Spelling › Auto Spell Check (#4936). A right-click on type (which selects it) has a Spelling submenu with Auto Spell Check, which runs `edit.autoSpellCheck` as Edit › Spelling does. The context menu draws no check marks, its toggles saying what they do (Show Rulers, Hide Guides), but a submenu that holds only toggles shows them, so Auto Spell Check is checked while it is on; other art has no Spelling submenu (`right_click_on_type_turns_auto_spell_check_on_and_off`). +The page's other way to turn Auto Spell Check on followed (2026-11-10): right-click the text and choose Spelling › Auto Spell Check (#4936). A right-click on type (which selects it) has a Spelling submenu with Auto Spell Check, which runs `edit.autoSpellCheck` as Edit › Spelling does. The context menu draws no check marks, its toggles saying what they do (Show Rulers, Hide Guides), but a submenu that holds only toggles shows them, and so does Spelling, so Auto Spell Check is checked while it is on; other art has no Spelling submenu (`right_click_on_type_turns_auto_spell_check_on_and_off`). Check Spelling… followed in the same submenu (2026-11-15), after Auto Spell Check as in Edit › Spelling, as the page also describes opening the Check Spelling dialog from Spelling in the menu of right-clicked text. It runs `ui.checkSpelling` on the selection, which the right-click made the type under the pointer, and a right-click on an underlined word has it too (`right_click_on_type_opens_check_spelling`, `right_click_on_an_underlined_word_also_offers_check_spelling`). Edit Custom Dictionary followed (2026-11-10), as the same page's "Edit the custom dictionary" describes it: Edit › Edit Custom Dictionary…, then enter a word in the Entry field and Add it, select a word and Delete it, or select a word, edit it in the Entry field and Change it, then Done (#4936). The dialog lists the custom dictionary's words (`text.spelling.dictionary`); picking one puts it in the Entry field. Add and Change take one word that isn't listed yet, kept in lower case as the dictionary keeps it, and Delete and Change need a word picked. Nothing changes until Done, which deletes and adds the words that differ (`text.spelling.removeWord`, `text.spelling.addWord`); Cancel leaves the dictionary as it was (`ui-egui/src/dialogs/custom_dictionary.rs`).