diff --git a/apps/client/src/services/bundle.ts b/apps/client/src/services/bundle.ts index 9c569f0be..649b9a9fd 100644 --- a/apps/client/src/services/bundle.ts +++ b/apps/client/src/services/bundle.ts @@ -6,7 +6,7 @@ import { t } from "./i18n.js"; import ScriptContext from "./script_context.js"; import server from "./server.js"; import toast from "./toast.js"; -import toastService, { showError } from "./toast.js"; +import toastService from "./toast.js"; import utils, { getErrorMessage } from "./utils.js"; // TODO: Deduplicate with server. @@ -20,7 +20,9 @@ export interface Bundle { type LegacyWidget = (BasicWidget | RightPanelWidget) & { parentWidget?: string; }; -type Widget = LegacyWidget | WidgetDefinition; +export type Widget = (LegacyWidget | WidgetDefinition) & { + _noteId: string; +}; async function getAndExecuteBundle(noteId: string, originEntity = null, script = null, params = null) { const bundle = await server.post(`script/bundle/${noteId}`, { diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx index c79560457..f7a9a8f51 100644 --- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx +++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx @@ -2,10 +2,11 @@ import "./RightPanelContainer.css"; import Split from "@triliumnext/split.js"; -import { VNode } from "preact"; +import { isValidElement, VNode } from "preact"; import { useEffect, useRef } from "preact/hooks"; import appContext from "../../components/app_context"; +import { Widget } from "../../services/bundle"; import { t } from "../../services/i18n"; import options from "../../services/options"; import { DEFAULT_GUTTER_SIZE } from "../../services/resizer"; @@ -51,7 +52,7 @@ export default function RightPanelContainer({ customWidgets }: { customWidgets: ); } -function useItems(rightPaneVisible: boolean, customWidgets: BasicWidget[]) { +function useItems(rightPaneVisible: boolean, customWidgets: Widget[]) { const { note } = useActiveNoteContext(); const noteType = useNoteProperty(note, "type"); const [ highlightsList ] = useTriliumOptionJson("highlightsList"); @@ -69,7 +70,7 @@ function useItems(rightPaneVisible: boolean, customWidgets: BasicWidget[]) { position: 20, }, ...customWidgets.map((w, i) => ({ - el: , + el: isValidElement(w) ? w : , enabled: true, position: w.position ?? 30 + i * 10 })) @@ -99,7 +100,7 @@ function useSplit(visible: boolean) { }, [ visible ]); } -function CustomWidget({ originalWidget }: { originalWidget: LegacyRightPanelWidget }) { +function CustomLegacyWidget({ originalWidget }: { originalWidget: LegacyRightPanelWidget }) { const containerRef = useRef(null); return (