Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(script/jsx): get right panel widgets to actually render
Elian Doran644ff07a50f4
diff --git a/apps/client/src/services/bundle.ts b/apps/client/src/services/bundle.tsindex 9c569f0be6..649b9a9fd6 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<Bundle>(`script/bundle/${noteId}`, {diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsxindex c795604575..f7a9a8f519 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<string[]>("highlightsList");@@ -69,7 +70,7 @@ function useItems(rightPaneVisible: boolean, customWidgets: BasicWidget[]) {position: 20,},...customWidgets.map((w, i) => ({- el: <CustomWidget key={w._noteId} originalWidget={w as LegacyRightPanelWidget} />,+ el: isValidElement(w) ? w : <CustomLegacyWidget key={w._noteId} originalWidget={w as LegacyRightPanelWidget} />,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<HTMLDivElement>(null);return (