mirror of
https://github.com/zadam/trilium.git
synced 2025-11-11 17:08:58 +01:00
chore(react/type_widgets): port @-mention note creation
This commit is contained in:
parent
d443d79685
commit
37d33fb975
@ -13,6 +13,7 @@ import { loadIncludedNote, refreshIncludedNote } from "./utils";
|
||||
import getTemplates, { updateTemplateCache } from "./snippets.js";
|
||||
import appContext from "../../../components/app_context";
|
||||
import link, { parseNavigationStateFromUrl } from "../../../services/link";
|
||||
import note_create from "../../../services/note_create";
|
||||
|
||||
/**
|
||||
* The editor can operate into two distinct modes:
|
||||
@ -84,6 +85,7 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext
|
||||
}
|
||||
});
|
||||
},
|
||||
// Include note functionality note
|
||||
addIncludeNoteToTextCommand() {
|
||||
if (!editorApiRef.current) return;
|
||||
parentComponent?.triggerCommand("showIncludeNoteDialog", {
|
||||
@ -91,6 +93,20 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext
|
||||
});
|
||||
},
|
||||
loadIncludedNote,
|
||||
// Creating notes in @-completion
|
||||
async createNoteForReferenceLink(title: string) {
|
||||
const notePath = noteContext?.notePath;
|
||||
if (!notePath) return;
|
||||
|
||||
const resp = await note_create.createNoteWithTypePrompt(notePath, {
|
||||
activate: false,
|
||||
title: title
|
||||
});
|
||||
|
||||
if (!resp || !resp.note) return;
|
||||
return resp.note.getBestNotePathString();
|
||||
},
|
||||
// Keyboard shortcut
|
||||
async followLinkUnderCursorCommand() {
|
||||
const editor = await waitForEditor();
|
||||
const selection = editor?.model.document.selection;
|
||||
|
||||
@ -71,23 +71,6 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
||||
resolve(this.watchdog.editor as CKTextEditor);
|
||||
}
|
||||
|
||||
async createNoteForReferenceLink(title: string) {
|
||||
if (!this.notePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
const resp = await noteCreateService.createNoteWithTypePrompt(this.notePath, {
|
||||
activate: false,
|
||||
title: title
|
||||
});
|
||||
|
||||
if (!resp || !resp.note) {
|
||||
return;
|
||||
}
|
||||
|
||||
return resp.note.getBestNotePathString();
|
||||
}
|
||||
|
||||
async reinitialize() {
|
||||
const data = this.watchdog.editor?.getData();
|
||||
await this.reinitializeWithData(data ?? "");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user