From 8fc8f978793be14618a054c11c8d6ff59b13f432 Mon Sep 17 00:00:00 2001 From: Jakob Schlanstedt Date: Wed, 5 Nov 2025 16:06:08 +0100 Subject: [PATCH] refactor(create-note-naming): simplify naming --- apps/client/src/services/note_autocomplete.ts | 40 +++++++++---------- .../src/translations/en/translation.json | 11 +++-- .../ribbon/components/AttributeEditor.tsx | 8 ++-- .../src/plugins/mention_customization.ts | 8 ++-- .../commons/src/lib/create_note_actions.ts | 8 ++-- 5 files changed, 37 insertions(+), 38 deletions(-) diff --git a/apps/client/src/services/note_autocomplete.ts b/apps/client/src/services/note_autocomplete.ts index f4e24212a..6c9baf935 100644 --- a/apps/client/src/services/note_autocomplete.ts +++ b/apps/client/src/services/note_autocomplete.ts @@ -46,10 +46,10 @@ export enum SuggestionAction { // This overlap ensures that when a suggestion triggers a note creation callback, // the receiving features (e.g. note creation handlers, CKEditor mentions) can interpret // the action type consistently - CreateNoteIntoInbox = CreateNoteAction.CreateNoteIntoInbox, - CreateNoteIntoPath = CreateNoteAction.CreateNoteIntoPath, - CreateAndLinkNoteIntoInbox = CreateNoteAction.CreateAndLinkNoteIntoInbox, - CreateAndLinkNoteIntoPath = CreateNoteAction.CreateAndLinkNoteIntoPath, + CreateNote = CreateNoteAction.CreateNote, + CreateChildNote = CreateNoteAction.CreateChildNote, + CreateAndLinkNote = CreateNoteAction.CreateAndLinkNote, + CreateAndLinkChildNote = CreateNoteAction.CreateAndLinkChildNote, SearchNotes = "search-notes", ExternalLink = "external-link", @@ -182,16 +182,16 @@ async function autocompleteSource( case CreateMode.CreateOnly: { results = [ { - action: SuggestionAction.CreateNoteIntoInbox, + action: SuggestionAction.CreateNote, noteTitle: trimmedTerm, parentNoteId: "inbox", - highlightedNotePathTitle: t("note_autocomplete.create-note-into-inbox", { term: trimmedTerm }), + highlightedNotePathTitle: t("note_autocomplete.create-note", { term: trimmedTerm }), }, { - action: SuggestionAction.CreateNoteIntoPath, + action: SuggestionAction.CreateChildNote, noteTitle: trimmedTerm, parentNoteId: activeNoteId || "root", - highlightedNotePathTitle: t("note_autocomplete.create-note-into-path", { term: trimmedTerm }), + highlightedNotePathTitle: t("note_autocomplete.create-child-note", { term: trimmedTerm }), }, ...results, ]; @@ -201,16 +201,16 @@ async function autocompleteSource( case CreateMode.CreateAndLink: { results = [ { - action: SuggestionAction.CreateAndLinkNoteIntoInbox, + action: SuggestionAction.CreateAndLinkNote, noteTitle: trimmedTerm, parentNoteId: "inbox", - highlightedNotePathTitle: t("note_autocomplete.create-and-link-note-into-inbox", { term: trimmedTerm }), + highlightedNotePathTitle: t("note_autocomplete.create-and-link-note", { term: trimmedTerm }), }, { - action: SuggestionAction.CreateAndLinkNoteIntoPath, + action: SuggestionAction.CreateAndLinkChildNote, noteTitle: trimmedTerm, parentNoteId: activeNoteId || "root", - highlightedNotePathTitle: t("note_autocomplete.create-and-link-note-into-path", { term: trimmedTerm }), + highlightedNotePathTitle: t("note_autocomplete.create-and-link-child-note", { term: trimmedTerm }), }, ...results, ]; @@ -316,11 +316,11 @@ function renderNoteSuggestion(s: Suggestion): string { switch (s.action) { case SuggestionAction.SearchNotes: return "bx bx-search"; - case SuggestionAction.CreateAndLinkNoteIntoInbox: - case SuggestionAction.CreateNoteIntoInbox: + case SuggestionAction.CreateAndLinkNote: + case SuggestionAction.CreateNote: return "bx bx-plus"; - case SuggestionAction.CreateAndLinkNoteIntoPath: - case SuggestionAction.CreateNoteIntoPath: + case SuggestionAction.CreateAndLinkChildNote: + case SuggestionAction.CreateChildNote: return "bx bx-plus"; case SuggestionAction.ExternalLink: return "bx bx-link-external"; @@ -477,7 +477,7 @@ function initNoteAutocomplete($el: JQuery, options?: Options) { } // --- CREATE NOTE INTO INBOX --- - case SuggestionAction.CreateNoteIntoInbox: { + case SuggestionAction.CreateNote: { const { note } = await noteCreateService.createNote( { target: "inbox", @@ -495,7 +495,7 @@ function initNoteAutocomplete($el: JQuery, options?: Options) { break; } - case SuggestionAction.CreateAndLinkNoteIntoInbox: { + case SuggestionAction.CreateAndLinkNote: { const { note } = await noteCreateService.createNote( { target: "inbox", @@ -516,7 +516,7 @@ function initNoteAutocomplete($el: JQuery, options?: Options) { return; } - case SuggestionAction.CreateNoteIntoPath: { + case SuggestionAction.CreateChildNote: { if (!suggestion.parentNoteId) { console.warn("Missing parentNoteId for CreateNoteIntoPath"); return; @@ -538,7 +538,7 @@ function initNoteAutocomplete($el: JQuery, options?: Options) { break; } - case SuggestionAction.CreateAndLinkNoteIntoPath: { + case SuggestionAction.CreateAndLinkChildNote: { if (!suggestion.parentNoteId) { console.warn("Missing parentNoteId for CreateNoteIntoPath"); return; diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 7dc1ed5b9..b9b3cab06 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -1897,14 +1897,13 @@ }, "note_autocomplete": { "search-for": "Search for \"{{term}}\"", - "create-note-into-path": "Create child note \"{{term}}\"", - "create-note-into-inbox": "Create in Inbox note \"{{term}}\"", - "create-and-link-note-into-path": "Create and link child note \"{{term}}\"", - "create-and-link-note-into-inbox": "Create in Inbox and link note \"{{term}}\"", + "create-child-note": "Create child note \"{{term}}\"", + "create-note": "Create note \"{{term}}\"", + "create-and-link-child-note": "Create and link child note \"{{term}}\"", + "create-and-link-note": "Create and link note \"{{term}}\"", "insert-external-link": "Insert external link to \"{{term}}\"", "clear-text-field": "Clear text field", - "show-recent-notes": "Show recent notes", - "full-text-search": "Full text search" + "show-recent-notes": "Show recent notes" }, "note_tooltip": { "note-has-been-deleted": "Note has been deleted.", diff --git a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx index 9f80de910..243a6c08d 100644 --- a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx +++ b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx @@ -254,8 +254,8 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI action: CreateNoteAction ): Promise => { switch (action) { - case CreateNoteAction.CreateNoteIntoInbox: - case CreateNoteAction.CreateAndLinkNoteIntoInbox: { + case CreateNoteAction.CreateNote: + case CreateNoteAction.CreateAndLinkNote: { const { note } = await note_create.createNote( { target: "inbox", @@ -267,8 +267,8 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI return note?.getBestNotePathString() ?? ""; } - case CreateNoteAction.CreateNoteIntoPath: - case CreateNoteAction.CreateAndLinkNoteIntoPath: { + case CreateNoteAction.CreateChildNote: + case CreateNoteAction.CreateAndLinkChildNote: { if (!parentNotePath) { console.warn("Missing parentNotePath in createNoteFromCkEditor()"); return ""; diff --git a/packages/ckeditor5/src/plugins/mention_customization.ts b/packages/ckeditor5/src/plugins/mention_customization.ts index c8cd9f003..1c4470e72 100644 --- a/packages/ckeditor5/src/plugins/mention_customization.ts +++ b/packages/ckeditor5/src/plugins/mention_customization.ts @@ -59,10 +59,10 @@ class CustomMentionCommand extends Command { }); } else if ( - mention.action === CreateNoteAction.CreateNoteIntoInbox || - mention.action === CreateNoteAction.CreateNoteIntoPath || - mention.action === CreateNoteAction.CreateAndLinkNoteIntoInbox || - mention.action === CreateNoteAction.CreateAndLinkNoteIntoPath + mention.action === CreateNoteAction.CreateNote || + mention.action === CreateNoteAction.CreateChildNote || + mention.action === CreateNoteAction.CreateAndLinkNote || + mention.action === CreateNoteAction.CreateAndLinkChildNote ) { const editorEl = this.editor.editing.view.getDomRoot(); const component = glob.getComponentByEl(editorEl); diff --git a/packages/commons/src/lib/create_note_actions.ts b/packages/commons/src/lib/create_note_actions.ts index beb1c96dd..712621aa5 100644 --- a/packages/commons/src/lib/create_note_actions.ts +++ b/packages/commons/src/lib/create_note_actions.ts @@ -1,6 +1,6 @@ export enum CreateNoteAction { - CreateNoteIntoInbox = "create-note-into-inbox", - CreateNoteIntoPath = "create-note-into-path", - CreateAndLinkNoteIntoInbox = "create-and-link-note-into-inbox", - CreateAndLinkNoteIntoPath = "create-and-link-note-into-path" + CreateNote = "create-note", + CreateChildNote = "create-child-note", + CreateAndLinkNote = "create-and-link-note", + CreateAndLinkChildNote = "create-and-link-child-note" }