refactor(create-note-naming): simplify naming

This commit is contained in:
Jakob Schlanstedt 2025-11-05 16:06:08 +01:00
parent 547cdff510
commit 8fc8f97879
5 changed files with 37 additions and 38 deletions

View File

@ -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<HTMLElement>, 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<HTMLElement>, options?: Options) {
break;
}
case SuggestionAction.CreateAndLinkNoteIntoInbox: {
case SuggestionAction.CreateAndLinkNote: {
const { note } = await noteCreateService.createNote(
{
target: "inbox",
@ -516,7 +516,7 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, 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<HTMLElement>, options?: Options) {
break;
}
case SuggestionAction.CreateAndLinkNoteIntoPath: {
case SuggestionAction.CreateAndLinkChildNote: {
if (!suggestion.parentNoteId) {
console.warn("Missing parentNoteId for CreateNoteIntoPath");
return;

View File

@ -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.",

View File

@ -254,8 +254,8 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI
action: CreateNoteAction
): Promise<string> => {
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 "";

View File

@ -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<EditorComponent>(editorEl);

View File

@ -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"
}