Merge 9004b724e7e54850026a071287a972297dd4a261 into 64662d5215ea01f6634fd72b5ff7a77dbc7e9e7d

This commit is contained in:
SngAbc 2025-12-01 14:34:16 +00:00 committed by GitHub
commit 55285bab5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 0 deletions

View File

@ -165,9 +165,20 @@ export function CodeEditor({ parentComponent, ntxId, containerRef: externalConta
useTriliumEvent("executeWithCodeEditor", async ({ resolve, ntxId: eventNtxId }) => {
if (eventNtxId !== ntxId) return;
await initialized.current.promise();
if (!codeEditorRef.current) return;
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}) => {
if (eventNtxId !== ntxId) return;
await initialized.current.promise();

View File

@ -188,6 +188,16 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext
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() {
await initialized.current;
const editor = watchdogRef.current?.editor;

View File

@ -51,6 +51,15 @@ export default function ReadOnlyText({ note, noteContext, ntxId }: TypeWidgetPro
resolve($(contentRef.current));
});
useTriliumEvent("noteContextRemoved", ({ ntxIds: eventNtxIds }) => {
if (!ntxId || !eventNtxIds.includes(ntxId)) return;
if (contentRef.current) {
contentRef.current.innerHTML = "";
}
contentRef.current = null;
});
return (
<>
<RawHtmlBlock