mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-15 19:10:47 +02:00
feat: add Agents UI to proprietary right sidebar (#6454)
Update UI to include agents Run `task dev:all` to test
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { generateId } from "@app/utils/generateId";
|
||||
import {
|
||||
signatureStorageService,
|
||||
type StorageType,
|
||||
@@ -28,16 +29,6 @@ export type AddSignatureResult =
|
||||
const isSupportedEnvironment = () =>
|
||||
typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
||||
|
||||
const generateId = () => {
|
||||
if (
|
||||
typeof crypto !== "undefined" &&
|
||||
typeof crypto.randomUUID === "function"
|
||||
) {
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
return `sig_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
||||
};
|
||||
|
||||
export const useSavedSignatures = () => {
|
||||
const [savedSignatures, setSavedSignatures] = useState<SavedSignature[]>([]);
|
||||
const [storageType, setStorageType] = useState<StorageType | null>(null);
|
||||
|
||||
@@ -13,6 +13,31 @@ interface UseToolPanelGeometryOptions {
|
||||
quickAccessRef: RefObject<HTMLDivElement | null>;
|
||||
}
|
||||
|
||||
function computeGeometry(
|
||||
panelEl: HTMLDivElement,
|
||||
quickAccessRef: RefObject<HTMLDivElement | null>,
|
||||
): ToolPanelGeometry {
|
||||
const rect = panelEl.getBoundingClientRect();
|
||||
const isRTL =
|
||||
typeof document !== "undefined" && document.documentElement.dir === "rtl";
|
||||
let width: number;
|
||||
let left: number;
|
||||
|
||||
if (isRTL) {
|
||||
// RTL: panel is on the left, expands rightward
|
||||
width = Math.max(360, window.innerWidth - rect.right);
|
||||
left = rect.right;
|
||||
} else {
|
||||
// LTR: panel is on the right, expands leftward to the file sidebar
|
||||
const quickAccessRect = quickAccessRef.current?.getBoundingClientRect();
|
||||
const leftOffset = quickAccessRect ? quickAccessRect.right : 0;
|
||||
width = Math.max(360, rect.right - leftOffset);
|
||||
left = leftOffset;
|
||||
}
|
||||
const height = Math.max(rect.height, window.innerHeight - rect.top);
|
||||
return { left, top: rect.top, width, height };
|
||||
}
|
||||
|
||||
export function useToolPanelGeometry({
|
||||
enabled,
|
||||
toolPanelRef,
|
||||
@@ -36,31 +61,7 @@ export function useToolPanelGeometry({
|
||||
let rafId: number | null = null;
|
||||
|
||||
const computeAndSetGeometry = () => {
|
||||
const rect = panelEl.getBoundingClientRect();
|
||||
const isRTL =
|
||||
typeof document !== "undefined" &&
|
||||
document.documentElement.dir === "rtl";
|
||||
let width: number;
|
||||
let left: number;
|
||||
|
||||
if (isRTL) {
|
||||
// RTL: panel is on the left, expands rightward
|
||||
width = Math.max(360, window.innerWidth - rect.right);
|
||||
left = rect.right;
|
||||
} else {
|
||||
// LTR: panel is on the right, expands leftward to the file sidebar
|
||||
const quickAccessRect = quickAccessRef.current?.getBoundingClientRect();
|
||||
const leftOffset = quickAccessRect ? quickAccessRect.right : 0;
|
||||
width = Math.max(360, rect.right - leftOffset);
|
||||
left = leftOffset;
|
||||
}
|
||||
const height = Math.max(rect.height, window.innerHeight - rect.top);
|
||||
setGeometry({
|
||||
left,
|
||||
top: rect.top,
|
||||
width,
|
||||
height,
|
||||
});
|
||||
setGeometry(computeGeometry(panelEl, quickAccessRef));
|
||||
};
|
||||
|
||||
const scheduleUpdate = () => {
|
||||
|
||||
Reference in New Issue
Block a user