From 35afd60d0083e7d8cbb32a358c3112bc2855bb7b Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 20 Dec 2025 12:17:14 +0200 Subject: [PATCH] feat(right_pane): respect position --- .../widgets/sidebar/RightPanelContainer.tsx | 47 +++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx index c49dc15cf..c79560457 100644 --- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx +++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx @@ -2,6 +2,7 @@ import "./RightPanelContainer.css"; import Split from "@triliumnext/split.js"; +import { VNode } from "preact"; import { useEffect, useRef } from "preact/hooks"; import appContext from "../../components/app_context"; @@ -19,19 +20,17 @@ import TableOfContents from "./TableOfContents"; const MIN_WIDTH_PERCENT = 5; +interface RightPanelWidgetDefinition { + el: VNode; + enabled: boolean; + position: number; +} + export default function RightPanelContainer({ customWidgets }: { customWidgets: BasicWidget[] }) { const [ rightPaneVisible, setRightPaneVisible ] = useTriliumOptionBool("rightPaneVisible"); - const [ highlightsList ] = useTriliumOptionJson("highlightsList"); + const items = useItems(rightPaneVisible, customWidgets); useSplit(rightPaneVisible); - const { note } = useActiveNoteContext(); - const noteType = useNoteProperty(note, "type"); - const items = (rightPaneVisible ? [ - (noteType === "text" || noteType === "doc") && , - noteType === "text" && highlightsList.length > 0 && , - ...customWidgets.map((w) => ) - ] : []).filter(Boolean); - return (
{rightPaneVisible && ( @@ -52,6 +51,36 @@ export default function RightPanelContainer({ customWidgets }: { customWidgets: ); } +function useItems(rightPaneVisible: boolean, customWidgets: BasicWidget[]) { + const { note } = useActiveNoteContext(); + const noteType = useNoteProperty(note, "type"); + const [ highlightsList ] = useTriliumOptionJson("highlightsList"); + + if (!rightPaneVisible) return []; + const definitions: RightPanelWidgetDefinition[] = [ + { + el: , + enabled: (noteType === "text" || noteType === "doc"), + position: 10, + }, + { + el: , + enabled: noteType === "text" && highlightsList.length > 0, + position: 20, + }, + ...customWidgets.map((w, i) => ({ + el: , + enabled: true, + position: w.position ?? 30 + i * 10 + })) + ]; + + return definitions + .filter(e => e.enabled) + .toSorted((a, b) => a.position - b.position) + .map(e => e.el); +} + function useSplit(visible: boolean) { // Split between right pane and the content pane. useEffect(() => {