mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
feat: improve document editor panel behavior
This commit is contained in:
parent
89a8438864
commit
cb1cf26ef3
8 changed files with 380 additions and 81 deletions
|
|
@ -3,10 +3,11 @@ import { rightPanelCollapsedAtom, rightPanelTabAtom } from "@/atoms/layout/right
|
|||
|
||||
interface EditorPanelState {
|
||||
isOpen: boolean;
|
||||
kind: "document" | "local_file";
|
||||
kind: "document" | "local_file" | "memory";
|
||||
documentId: number | null;
|
||||
localFilePath: string | null;
|
||||
searchSpaceId: number | null;
|
||||
memoryScope: "user" | "team" | null;
|
||||
title: string | null;
|
||||
}
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ const initialState: EditorPanelState = {
|
|||
documentId: null,
|
||||
localFilePath: null,
|
||||
searchSpaceId: null,
|
||||
memoryScope: null,
|
||||
title: null,
|
||||
};
|
||||
|
||||
|
|
@ -38,6 +40,12 @@ export const openEditorPanelAtom = atom(
|
|||
title?: string;
|
||||
searchSpaceId?: number;
|
||||
}
|
||||
| {
|
||||
kind: "memory";
|
||||
memoryScope: "user" | "team";
|
||||
title?: string;
|
||||
searchSpaceId?: number;
|
||||
}
|
||||
) => {
|
||||
if (!get(editorPanelAtom).isOpen) {
|
||||
set(preEditorCollapsedAtom, get(rightPanelCollapsedAtom));
|
||||
|
|
@ -49,6 +57,21 @@ export const openEditorPanelAtom = atom(
|
|||
documentId: null,
|
||||
localFilePath: payload.localFilePath,
|
||||
searchSpaceId: payload.searchSpaceId ?? null,
|
||||
memoryScope: null,
|
||||
title: payload.title ?? null,
|
||||
});
|
||||
set(rightPanelTabAtom, "editor");
|
||||
set(rightPanelCollapsedAtom, false);
|
||||
return;
|
||||
}
|
||||
if (payload.kind === "memory") {
|
||||
set(editorPanelAtom, {
|
||||
isOpen: true,
|
||||
kind: "memory",
|
||||
documentId: null,
|
||||
localFilePath: null,
|
||||
searchSpaceId: payload.searchSpaceId ?? null,
|
||||
memoryScope: payload.memoryScope,
|
||||
title: payload.title ?? null,
|
||||
});
|
||||
set(rightPanelTabAtom, "editor");
|
||||
|
|
@ -61,6 +84,7 @@ export const openEditorPanelAtom = atom(
|
|||
documentId: payload.documentId,
|
||||
localFilePath: null,
|
||||
searchSpaceId: payload.searchSpaceId,
|
||||
memoryScope: null,
|
||||
title: payload.title ?? null,
|
||||
});
|
||||
set(rightPanelTabAtom, "editor");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue