mirror of
https://github.com/zadam/trilium.git
synced 2025-12-04 22:44:25 +01:00
Merge 9004b724e7e54850026a071287a972297dd4a261 into a867a25d5f09e410d0c73b7fbeab18b4641f484a
This commit is contained in:
commit
2a2cf510b5
@ -165,9 +165,20 @@ export function CodeEditor({ parentComponent, ntxId, containerRef: externalConta
|
|||||||
useTriliumEvent("executeWithCodeEditor", async ({ resolve, ntxId: eventNtxId }) => {
|
useTriliumEvent("executeWithCodeEditor", async ({ resolve, ntxId: eventNtxId }) => {
|
||||||
if (eventNtxId !== ntxId) return;
|
if (eventNtxId !== ntxId) return;
|
||||||
await initialized.current.promise();
|
await initialized.current.promise();
|
||||||
|
if (!codeEditorRef.current) return;
|
||||||
resolve(codeEditorRef.current!);
|
resolve(codeEditorRef.current!);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useTriliumEvent("noteContextRemoved", async ({ ntxIds: eventNtxIds }) => {
|
||||||
|
if (!ntxId || !eventNtxIds.includes(ntxId)) return;
|
||||||
|
|
||||||
|
const cm = codeEditorRef.current;
|
||||||
|
if (cm) {
|
||||||
|
cm.destroy();
|
||||||
|
codeEditorRef.current = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
useTriliumEvent("executeWithContentElement", async ({ resolve, ntxId: eventNtxId}) => {
|
useTriliumEvent("executeWithContentElement", async ({ resolve, ntxId: eventNtxId}) => {
|
||||||
if (eventNtxId !== ntxId) return;
|
if (eventNtxId !== ntxId) return;
|
||||||
await initialized.current.promise();
|
await initialized.current.promise();
|
||||||
|
|||||||
@ -188,6 +188,16 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext
|
|||||||
resolve(editor);
|
resolve(editor);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useTriliumEvent("noteContextRemoved", async ({ ntxIds: eventNtxIds }) => {
|
||||||
|
if (!ntxId || !eventNtxIds.includes(ntxId)) return;
|
||||||
|
|
||||||
|
const watchdog = watchdogRef.current;
|
||||||
|
if (!watchdog) return;
|
||||||
|
|
||||||
|
await watchdog.destroy();
|
||||||
|
watchdogRef.current = null;
|
||||||
|
});
|
||||||
|
|
||||||
async function waitForEditor() {
|
async function waitForEditor() {
|
||||||
await initialized.current;
|
await initialized.current;
|
||||||
const editor = watchdogRef.current?.editor;
|
const editor = watchdogRef.current?.editor;
|
||||||
|
|||||||
@ -51,6 +51,15 @@ export default function ReadOnlyText({ note, noteContext, ntxId }: TypeWidgetPro
|
|||||||
resolve($(contentRef.current));
|
resolve($(contentRef.current));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useTriliumEvent("noteContextRemoved", ({ ntxIds: eventNtxIds }) => {
|
||||||
|
if (!ntxId || !eventNtxIds.includes(ntxId)) return;
|
||||||
|
|
||||||
|
if (contentRef.current) {
|
||||||
|
contentRef.current.innerHTML = "";
|
||||||
|
}
|
||||||
|
contentRef.current = null;
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RawHtmlBlock
|
<RawHtmlBlock
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user