fix: do not render sections outside workspace

This commit is contained in:
windingwind 2024-08-04 12:51:47 +08:00
parent d1e02bf42d
commit 172b6418ba
3 changed files with 12 additions and 7 deletions

View File

@ -68,7 +68,8 @@ export function registerNoteLinkSection(type: "inbound" | "outbound") {
setEnabled(false);
},
onRender: () => {},
onAsyncRender: async ({ body, item, setL10nArgs }) => {
onAsyncRender: async ({ body, item, setL10nArgs, tabType }) => {
if (!item?.isNote()) return;
await renderSection(type, {
body,
item,

View File

@ -85,7 +85,8 @@ export function openNotePreview(
onRender: ({ setSectionSummary }) => {
setSectionSummary(noteItem.getNoteTitle());
},
onAsyncRender: async ({ body }) => {
onAsyncRender: async ({ body, item }) => {
if (!item?.isNote()) return;
const editorElement = body.querySelector("note-editor")! as EditorElement;
await waitUtilAsync(() => Boolean(editorElement._initialized));
if (!editorElement._initialized) {

View File

@ -20,11 +20,7 @@ export function registerNoteRelation() {
rel="stylesheet"
href="chrome://${config.addonRef}/content/styles/workspace/relation.css"
></html:link>
</linkset>
<iframe
src="chrome://${config.addonRef}/content/relationGraph.html"
id="bn-relation-graph"
></iframe>`,
</linkset>`,
sectionButtons: [
{
type: "refreshGraph",
@ -83,6 +79,13 @@ export function registerNoteRelation() {
},
onRender: () => {},
onAsyncRender: async ({ body, item }) => {
if (!item?.isNote()) return;
if (!body.querySelector("#bn-relation-graph")) {
const iframe = body.ownerDocument.createXULElement("iframe") as HTMLIFrameElement;
iframe.src = `chrome://${config.addonRef}/content/relationGraph.html`;
iframe.id = "bn-relation-graph";
body.appendChild(iframe);
}
await renderGraph(body, item);
},
});