Skip to content

Commit 643e271

Browse files
author
Jakob Schlanstedt
committed
refactor(create-note-naming): simplify naming
1 parent ba3596b commit 643e271

File tree

5 files changed

+37
-38
lines changed

5 files changed

+37
-38
lines changed

apps/client/src/services/note_autocomplete.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ export enum SuggestionAction {
4646
// This overlap ensures that when a suggestion triggers a note creation callback,
4747
// the receiving features (e.g. note creation handlers, CKEditor mentions) can interpret
4848
// the action type consistently
49-
CreateNoteIntoInbox = CreateNoteAction.CreateNoteIntoInbox,
50-
CreateNoteIntoPath = CreateNoteAction.CreateNoteIntoPath,
51-
CreateAndLinkNoteIntoInbox = CreateNoteAction.CreateAndLinkNoteIntoInbox,
52-
CreateAndLinkNoteIntoPath = CreateNoteAction.CreateAndLinkNoteIntoPath,
49+
CreateNote = CreateNoteAction.CreateNote,
50+
CreateChildNote = CreateNoteAction.CreateChildNote,
51+
CreateAndLinkNote = CreateNoteAction.CreateAndLinkNote,
52+
CreateAndLinkChildNote = CreateNoteAction.CreateAndLinkChildNote,
5353

5454
SearchNotes = "search-notes",
5555
ExternalLink = "external-link",
@@ -182,16 +182,16 @@ async function autocompleteSource(
182182
case CreateMode.CreateOnly: {
183183
results = [
184184
{
185-
action: SuggestionAction.CreateNoteIntoInbox,
185+
action: SuggestionAction.CreateNote,
186186
noteTitle: trimmedTerm,
187187
parentNoteId: "inbox",
188-
highlightedNotePathTitle: t("note_autocomplete.create-note-into-inbox", { term: trimmedTerm }),
188+
highlightedNotePathTitle: t("note_autocomplete.create-note", { term: trimmedTerm }),
189189
},
190190
{
191-
action: SuggestionAction.CreateNoteIntoPath,
191+
action: SuggestionAction.CreateChildNote,
192192
noteTitle: trimmedTerm,
193193
parentNoteId: activeNoteId || "root",
194-
highlightedNotePathTitle: t("note_autocomplete.create-note-into-path", { term: trimmedTerm }),
194+
highlightedNotePathTitle: t("note_autocomplete.create-child-note", { term: trimmedTerm }),
195195
},
196196
...results,
197197
];
@@ -201,16 +201,16 @@ async function autocompleteSource(
201201
case CreateMode.CreateAndLink: {
202202
results = [
203203
{
204-
action: SuggestionAction.CreateAndLinkNoteIntoInbox,
204+
action: SuggestionAction.CreateAndLinkNote,
205205
noteTitle: trimmedTerm,
206206
parentNoteId: "inbox",
207-
highlightedNotePathTitle: t("note_autocomplete.create-and-link-note-into-inbox", { term: trimmedTerm }),
207+
highlightedNotePathTitle: t("note_autocomplete.create-and-link-note", { term: trimmedTerm }),
208208
},
209209
{
210-
action: SuggestionAction.CreateAndLinkNoteIntoPath,
210+
action: SuggestionAction.CreateAndLinkChildNote,
211211
noteTitle: trimmedTerm,
212212
parentNoteId: activeNoteId || "root",
213-
highlightedNotePathTitle: t("note_autocomplete.create-and-link-note-into-path", { term: trimmedTerm }),
213+
highlightedNotePathTitle: t("note_autocomplete.create-and-link-child-note", { term: trimmedTerm }),
214214
},
215215
...results,
216216
];
@@ -316,11 +316,11 @@ function renderNoteSuggestion(s: Suggestion): string {
316316
switch (s.action) {
317317
case SuggestionAction.SearchNotes:
318318
return "bx bx-search";
319-
case SuggestionAction.CreateAndLinkNoteIntoInbox:
320-
case SuggestionAction.CreateNoteIntoInbox:
319+
case SuggestionAction.CreateAndLinkNote:
320+
case SuggestionAction.CreateNote:
321321
return "bx bx-plus";
322-
case SuggestionAction.CreateAndLinkNoteIntoPath:
323-
case SuggestionAction.CreateNoteIntoPath:
322+
case SuggestionAction.CreateAndLinkChildNote:
323+
case SuggestionAction.CreateChildNote:
324324
return "bx bx-plus";
325325
case SuggestionAction.ExternalLink:
326326
return "bx bx-link-external";
@@ -477,7 +477,7 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
477477
}
478478

479479
// --- CREATE NOTE INTO INBOX ---
480-
case SuggestionAction.CreateNoteIntoInbox: {
480+
case SuggestionAction.CreateNote: {
481481
const { note } = await noteCreateService.createNote(
482482
{
483483
target: "inbox",
@@ -495,7 +495,7 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
495495
break;
496496
}
497497

498-
case SuggestionAction.CreateAndLinkNoteIntoInbox: {
498+
case SuggestionAction.CreateAndLinkNote: {
499499
const { note } = await noteCreateService.createNote(
500500
{
501501
target: "inbox",
@@ -516,7 +516,7 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
516516
return;
517517
}
518518

519-
case SuggestionAction.CreateNoteIntoPath: {
519+
case SuggestionAction.CreateChildNote: {
520520
if (!suggestion.parentNoteId) {
521521
console.warn("Missing parentNoteId for CreateNoteIntoPath");
522522
return;
@@ -538,7 +538,7 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
538538
break;
539539
}
540540

541-
case SuggestionAction.CreateAndLinkNoteIntoPath: {
541+
case SuggestionAction.CreateAndLinkChildNote: {
542542
if (!suggestion.parentNoteId) {
543543
console.warn("Missing parentNoteId for CreateNoteIntoPath");
544544
return;

apps/client/src/translations/en/translation.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,14 +1888,13 @@
18881888
},
18891889
"note_autocomplete": {
18901890
"search-for": "Search for \"{{term}}\"",
1891-
"create-note-into-path": "Create child note \"{{term}}\"",
1892-
"create-note-into-inbox": "Create in Inbox note \"{{term}}\"",
1893-
"create-and-link-note-into-path": "Create and link child note \"{{term}}\"",
1894-
"create-and-link-note-into-inbox": "Create in Inbox and link note \"{{term}}\"",
1891+
"create-child-note": "Create child note \"{{term}}\"",
1892+
"create-note": "Create note \"{{term}}\"",
1893+
"create-and-link-child-note": "Create and link child note \"{{term}}\"",
1894+
"create-and-link-note": "Create and link note \"{{term}}\"",
18951895
"insert-external-link": "Insert external link to \"{{term}}\"",
18961896
"clear-text-field": "Clear text field",
1897-
"show-recent-notes": "Show recent notes",
1898-
"full-text-search": "Full text search"
1897+
"show-recent-notes": "Show recent notes"
18991898
},
19001899
"note_tooltip": {
19011900
"note-has-been-deleted": "Note has been deleted.",

apps/client/src/widgets/ribbon/components/AttributeEditor.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI
254254
action: CreateNoteAction
255255
): Promise<string> => {
256256
switch (action) {
257-
case CreateNoteAction.CreateNoteIntoInbox:
258-
case CreateNoteAction.CreateAndLinkNoteIntoInbox: {
257+
case CreateNoteAction.CreateNote:
258+
case CreateNoteAction.CreateAndLinkNote: {
259259
const { note } = await note_create.createNote(
260260
{
261261
target: "inbox",
@@ -267,8 +267,8 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI
267267
return note?.getBestNotePathString() ?? "";
268268
}
269269

270-
case CreateNoteAction.CreateNoteIntoPath:
271-
case CreateNoteAction.CreateAndLinkNoteIntoPath: {
270+
case CreateNoteAction.CreateChildNote:
271+
case CreateNoteAction.CreateAndLinkChildNote: {
272272
if (!parentNotePath) {
273273
console.warn("Missing parentNotePath in createNoteFromCkEditor()");
274274
return "";

packages/ckeditor5/src/plugins/mention_customization.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class CustomMentionCommand extends Command {
5959
});
6060
}
6161
else if (
62-
mention.action === CreateNoteAction.CreateNoteIntoInbox ||
63-
mention.action === CreateNoteAction.CreateNoteIntoPath ||
64-
mention.action === CreateNoteAction.CreateAndLinkNoteIntoInbox ||
65-
mention.action === CreateNoteAction.CreateAndLinkNoteIntoPath
62+
mention.action === CreateNoteAction.CreateNote ||
63+
mention.action === CreateNoteAction.CreateChildNote ||
64+
mention.action === CreateNoteAction.CreateAndLinkNote ||
65+
mention.action === CreateNoteAction.CreateAndLinkChildNote
6666
) {
6767
const editorEl = this.editor.editing.view.getDomRoot();
6868
const component = glob.getComponentByEl<EditorComponent>(editorEl);
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export enum CreateNoteAction {
2-
CreateNoteIntoInbox = "create-note-into-inbox",
3-
CreateNoteIntoPath = "create-note-into-path",
4-
CreateAndLinkNoteIntoInbox = "create-and-link-note-into-inbox",
5-
CreateAndLinkNoteIntoPath = "create-and-link-note-into-path"
2+
CreateNote = "create-note",
3+
CreateChildNote = "create-child-note",
4+
CreateAndLinkNote = "create-and-link-note",
5+
CreateAndLinkChildNote = "create-and-link-child-note"
66
}

0 commit comments

Comments
 (0)