mirror of
https://github.com/zadam/trilium.git
synced 2026-01-07 15:14:24 +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 getTemplates, { updateTemplateCache } from "./snippets.js";
|
||||||
import appContext from "../../../components/app_context";
|
import appContext from "../../../components/app_context";
|
||||||
import link, { parseNavigationStateFromUrl } from "../../../services/link";
|
import link, { parseNavigationStateFromUrl } from "../../../services/link";
|
||||||
|
import note_create from "../../../services/note_create";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The editor can operate into two distinct modes:
|
* 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() {
|
addIncludeNoteToTextCommand() {
|
||||||
if (!editorApiRef.current) return;
|
if (!editorApiRef.current) return;
|
||||||
parentComponent?.triggerCommand("showIncludeNoteDialog", {
|
parentComponent?.triggerCommand("showIncludeNoteDialog", {
|
||||||
@ -91,6 +93,20 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadIncludedNote,
|
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() {
|
async followLinkUnderCursorCommand() {
|
||||||
const editor = await waitForEditor();
|
const editor = await waitForEditor();
|
||||||
const selection = editor?.model.document.selection;
|
const selection = editor?.model.document.selection;
|
||||||
|
|||||||
@ -71,23 +71,6 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
resolve(this.watchdog.editor as CKTextEditor);
|
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() {
|
async reinitialize() {
|
||||||
const data = this.watchdog.editor?.getData();
|
const data = this.watchdog.editor?.getData();
|
||||||
await this.reinitializeWithData(data ?? "");
|
await this.reinitializeWithData(data ?? "");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user