mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-04 13:22:41 +02:00
feat: implement editor panel functionality and integrate with existing components
- Added editor panel state management using Jotai atoms. - Integrated editor panel into the right panel and documents sidebar. - Updated DocumentsTableShell to open the editor panel on edit action. - Enhanced NewChatPage to close the editor panel when navigating away. - Improved context menu actions for document editing and deletion.
This commit is contained in:
parent
0d56cfb663
commit
f617ae8742
7 changed files with 414 additions and 38 deletions
57
surfsense_web/atoms/editor/editor-panel.atom.ts
Normal file
57
surfsense_web/atoms/editor/editor-panel.atom.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { atom } from "jotai";
|
||||
import { rightPanelCollapsedAtom, rightPanelTabAtom } from "@/atoms/layout/right-panel.atom";
|
||||
|
||||
interface EditorPanelState {
|
||||
isOpen: boolean;
|
||||
documentId: number | null;
|
||||
searchSpaceId: number | null;
|
||||
title: string | null;
|
||||
}
|
||||
|
||||
const initialState: EditorPanelState = {
|
||||
isOpen: false,
|
||||
documentId: null,
|
||||
searchSpaceId: null,
|
||||
title: null,
|
||||
};
|
||||
|
||||
export const editorPanelAtom = atom<EditorPanelState>(initialState);
|
||||
|
||||
export const editorPanelOpenAtom = atom((get) => get(editorPanelAtom).isOpen);
|
||||
|
||||
const preEditorCollapsedAtom = atom<boolean | null>(null);
|
||||
|
||||
export const openEditorPanelAtom = atom(
|
||||
null,
|
||||
(
|
||||
get,
|
||||
set,
|
||||
{
|
||||
documentId,
|
||||
searchSpaceId,
|
||||
title,
|
||||
}: { documentId: number; searchSpaceId: number; title?: string }
|
||||
) => {
|
||||
if (!get(editorPanelAtom).isOpen) {
|
||||
set(preEditorCollapsedAtom, get(rightPanelCollapsedAtom));
|
||||
}
|
||||
set(editorPanelAtom, {
|
||||
isOpen: true,
|
||||
documentId,
|
||||
searchSpaceId,
|
||||
title: title ?? null,
|
||||
});
|
||||
set(rightPanelTabAtom, "editor");
|
||||
set(rightPanelCollapsedAtom, false);
|
||||
}
|
||||
);
|
||||
|
||||
export const closeEditorPanelAtom = atom(null, (get, set) => {
|
||||
set(editorPanelAtom, initialState);
|
||||
set(rightPanelTabAtom, "sources");
|
||||
const prev = get(preEditorCollapsedAtom);
|
||||
if (prev !== null) {
|
||||
set(rightPanelCollapsedAtom, prev);
|
||||
set(preEditorCollapsedAtom, null);
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue