feat(editor): hint at Alt+W for a wrapped text and while editing a text

The hint for editing now also takes precedence over the one for a selected
text: a text just created is selected while it's edited.
This commit is contained in:
dwelle committed 2026-11-15 10:41:08 +01:00
1 parent 955315cf98
commit 1beab51331
3 files changed
+41 -6

No files matched your search

+19 -6
View File
@@ -174,17 +174,30 @@ const getHints = ({
});
}
if (selectedElements.length === 1 && isTextElement(selectedElements[0])) {
return t("hints.text_selected", {
shortcut: getTaggedShortcutKey("Enter"),
});
}
const toggleTextAutoResize = t("hints.toggleTextAutoResize", {
shortcut: getTaggedShortcutKey(["Alt", "W"]),
});
// (before the selected text: one just created is selected while edited)
if (appState.editingTextElement) {
return t("hints.text_editing", {
const finishEditing = t("hints.text_editing", {
shortcut_1: getTaggedShortcutKey("Escape"),
shortcut_2: getTaggedShortcutKey(["CtrlOrCmd", "Enter"]),
});
// (a label follows its container)
return appState.editingTextElement.containerId
? finishEditing
: [finishEditing, toggleTextAutoResize];
}
if (selectedElements.length === 1 && isTextElement(selectedElements[0])) {
const editText = t("hints.text_selected", {
shortcut: getTaggedShortcutKey("Enter"),
});
// a wrapped text: its handle unwraps it too, but only on desktop
return selectedElements[0].autoResize
? editText
: [editText, toggleTextAutoResize];
}
if (appState.croppingElementId) {
+1
View File
@@ -396,6 +396,7 @@
"autoshape": "Draw rectangles, circles, diamonds, lines and arrows",
"text_selected": "Double-click or press {{shortcut}} to edit text",
"text_editing": "Press {{shortcut_1}} or {{shortcut_2}} to finish editing",
"toggleTextAutoResize": "{{shortcut}} to toggle text auto-resize",
"linearElementMulti": "Click on last point or press {{shortcut_1}} or {{shortcut_2}} to finish",
"lockAngle": "You can constrain angle by holding {{shortcut}}",
"resize": "You can constrain proportions by holding {{shortcut_1}} while resizing,\nhold {{shortcut_2}} to resize from the center",
@@ -3684,6 +3684,27 @@ describe("textWysiwyg", () => {
},
);
it("hints at Alt+W for a selected wrapped text, and while editing a text", async () => {
const hint = () =>
h.app.ownerDocument.querySelector(".HintViewer")?.textContent ?? "";
const toggleHint = "to toggle text auto-resize";
API.setElements([wrappedText()]);
API.setAppState({ selectedElementIds: { text: true } });
await waitFor(() => expect(hint()).toContain(toggleHint));
// not for a text that doesn't wrap...
API.executeAction(actionTextAutoResize);
await waitFor(() => expect(hint()).toContain("to edit text"));
expect(hint()).not.toContain(toggleHint);
// ...until it's edited
mouse.doubleClickAt(110, 110);
await getTextEditor();
await waitFor(() => expect(hint()).toContain("to finish editing"));
expect(hint()).toContain(toggleHint);
});
it("toggles auto-resizing of the text being edited with Alt+W", async () => {
API.setElements([wrappedText()]);
mouse.doubleClickAt(110, 110);