mirror of
https://github.com/docmost/docmost.git
synced 2026-05-18 15:34:05 +08:00
57efb91bd3
* feat: ai chat * feat: ai chat * sync * cleanup * view space button
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
import { Box, ScrollArea, Text } from "@mantine/core";
|
|
import CommentListWithTabs from "@/features/comment/components/comment-list-with-tabs.tsx";
|
|
import { useAtom } from "jotai";
|
|
import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
|
import React, { ReactNode } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { TableOfContents } from "@/features/editor/components/table-of-contents/table-of-contents.tsx";
|
|
import { useAtomValue } from "jotai";
|
|
import { pageEditorAtom } from "@/features/editor/atoms/editor-atoms.ts";
|
|
import AsideChatPanel from "@/ee/ai-chat/components/aside-chat-panel";
|
|
|
|
export default function Aside() {
|
|
const [{ tab }] = useAtom(asideStateAtom);
|
|
const { t } = useTranslation();
|
|
const pageEditor = useAtomValue(pageEditorAtom);
|
|
|
|
let title: string;
|
|
let component: ReactNode;
|
|
|
|
switch (tab) {
|
|
case "comments":
|
|
component = <CommentListWithTabs />;
|
|
title = "Comments";
|
|
break;
|
|
case "toc":
|
|
component = <TableOfContents editor={pageEditor} />;
|
|
title = "Table of contents";
|
|
break;
|
|
case "chat":
|
|
component = <AsideChatPanel />;
|
|
title = "AI Chat";
|
|
break;
|
|
default:
|
|
component = null;
|
|
title = null;
|
|
}
|
|
|
|
return (
|
|
<Box p="md" style={{ height: "100%", display: "flex", flexDirection: "column" }}>
|
|
{component && (
|
|
<>
|
|
{tab !== "chat" && (
|
|
<Text mb="md" fw={500}>
|
|
{t(title)}
|
|
</Text>
|
|
)}
|
|
|
|
{tab === "comments" || tab === "chat" ? (
|
|
component
|
|
) : (
|
|
<ScrollArea
|
|
style={{ height: "85vh" }}
|
|
scrollbarSize={5}
|
|
type="scroll"
|
|
>
|
|
<div style={{ paddingBottom: "200px" }}>{component}</div>
|
|
</ScrollArea>
|
|
)}
|
|
</>
|
|
)}
|
|
</Box>
|
|
);
|
|
}
|