mirror of
https://github.com/docmost/docmost.git
synced 2026-08-23 04:21:05 +08:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8769968141 | ||
|
|
bf3d1bf3c0 | ||
|
|
9ba93c87c0 | ||
|
|
b77b84602d | ||
|
|
ea012f9430 | ||
|
|
add1d7bf61 | ||
|
|
81eb6157bc | ||
|
|
166dcdbb05 | ||
|
|
1e2184c021 |
+1
-1
@@ -42,7 +42,7 @@ RUN chown -R node:node /app
|
|||||||
|
|
||||||
USER node
|
USER node
|
||||||
|
|
||||||
RUN pnpm install --frozen-lockfile --prod && rm -rf /home/node/.cache/pnpm
|
RUN pnpm install --frozen-lockfile --prod
|
||||||
|
|
||||||
RUN mkdir -p /app/data/storage
|
RUN mkdir -p /app/data/storage
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"version": "0.95.0",
|
"version": "0.95.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build && node scripts/compress-dist.mjs",
|
"build": "tsc && vite build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"format": "prettier --write \"src/**/*.tsx\" \"src/**/*.ts\"",
|
"format": "prettier --write \"src/**/*.tsx\" \"src/**/*.ts\"",
|
||||||
@@ -50,9 +50,9 @@
|
|||||||
"katex": "0.16.40",
|
"katex": "0.16.40",
|
||||||
"lowlight": "3.3.0",
|
"lowlight": "3.3.0",
|
||||||
"mantine-form-zod-resolver": "1.3.0",
|
"mantine-form-zod-resolver": "1.3.0",
|
||||||
"mermaid": "11.16.1",
|
"mermaid": "11.15.0",
|
||||||
"mitt": "3.0.1",
|
"mitt": "3.0.1",
|
||||||
"nanoid": "3.3.18",
|
"nanoid": "3.3.8",
|
||||||
"posthog-js": "1.391.2",
|
"posthog-js": "1.391.2",
|
||||||
"react": "19.2.7",
|
"react": "19.2.7",
|
||||||
"react-clear-modal": "^2.0.18",
|
"react-clear-modal": "^2.0.18",
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
"react-error-boundary": "6.1.1",
|
"react-error-boundary": "6.1.1",
|
||||||
"react-helmet-async": "3.0.0",
|
"react-helmet-async": "3.0.0",
|
||||||
"react-i18next": "16.5.8",
|
"react-i18next": "16.5.8",
|
||||||
"react-router-dom": "7.18.2",
|
"react-router-dom": "7.18.0",
|
||||||
"semver": "7.7.4",
|
"semver": "7.7.4",
|
||||||
"socket.io-client": "4.8.3",
|
"socket.io-client": "4.8.3",
|
||||||
"zod": "4.3.6"
|
"zod": "4.3.6"
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
"globals": "15.13.0",
|
"globals": "15.13.0",
|
||||||
"jsdom": "25.0.0",
|
"jsdom": "25.0.0",
|
||||||
"optics-ts": "2.4.1",
|
"optics-ts": "2.4.1",
|
||||||
"postcss": "8.5.25",
|
"postcss": "8.5.14",
|
||||||
"postcss-preset-mantine": "1.18.0",
|
"postcss-preset-mantine": "1.18.0",
|
||||||
"postcss-simple-vars": "7.0.1",
|
"postcss-simple-vars": "7.0.1",
|
||||||
"prettier": "3.8.1",
|
"prettier": "3.8.1",
|
||||||
|
|||||||
@@ -387,8 +387,6 @@
|
|||||||
"Insert horizontal rule divider": "Insert horizontal rule divider",
|
"Insert horizontal rule divider": "Insert horizontal rule divider",
|
||||||
"Page break": "Page break",
|
"Page break": "Page break",
|
||||||
"Insert a page break for printing.": "Insert a page break for printing.",
|
"Insert a page break for printing.": "Insert a page break for printing.",
|
||||||
"Footnote": "Footnote",
|
|
||||||
"Insert a footnote reference.": "Insert a footnote reference.",
|
|
||||||
"Upload any image from your device.": "Upload any image from your device.",
|
"Upload any image from your device.": "Upload any image from your device.",
|
||||||
"Upload any video from your device.": "Upload any video from your device.",
|
"Upload any video from your device.": "Upload any video from your device.",
|
||||||
"Upload any audio from your device.": "Upload any audio from your device.",
|
"Upload any audio from your device.": "Upload any audio from your device.",
|
||||||
@@ -1291,16 +1289,5 @@
|
|||||||
"{{count}} rows deleted_one": "1 row deleted",
|
"{{count}} rows deleted_one": "1 row deleted",
|
||||||
"{{count}} rows deleted_other": "{{count}} rows deleted",
|
"{{count}} rows deleted_other": "{{count}} rows deleted",
|
||||||
"{{count}} selected_one": "1 selected",
|
"{{count}} selected_one": "1 selected",
|
||||||
"{{count}} selected_other": "{{count}} selected",
|
"{{count}} selected_other": "{{count}} selected"
|
||||||
"Compare": "Compare",
|
|
||||||
"Compare versions": "Compare versions",
|
|
||||||
"Select version from {{date}}": "Select version from {{date}}",
|
|
||||||
"Version actions for {{date}}": "Version actions for {{date}}",
|
|
||||||
"Comparing {{newer}} and {{older}}": "Comparing {{newer}} and {{older}}",
|
|
||||||
"Exit compare": "Exit compare",
|
|
||||||
"Search attachments...": "Search attachments...",
|
|
||||||
"Error loading attachments.": "Error loading attachments.",
|
|
||||||
"No attachments on this page yet.": "No attachments on this page yet.",
|
|
||||||
"Uploaded by {{name}}": "Uploaded by {{name}}",
|
|
||||||
"Download {{name}}": "Download {{name}}"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
import { promises as fs } from "node:fs";
|
|
||||||
import { join, extname } from "node:path";
|
|
||||||
import { promisify } from "node:util";
|
|
||||||
import zlib from "node:zlib";
|
|
||||||
|
|
||||||
const gzip = promisify(zlib.gzip);
|
|
||||||
const brotli = promisify(zlib.brotliCompress);
|
|
||||||
|
|
||||||
const DIST = new URL("../dist", import.meta.url).pathname;
|
|
||||||
// index.html is rewritten by the server at boot, so html must not be precompressed
|
|
||||||
const COMPRESSIBLE = new Set([".js", ".css", ".svg", ".json", ".txt", ".map"]);
|
|
||||||
const MIN_SIZE = 1024;
|
|
||||||
|
|
||||||
async function* walk(dir) {
|
|
||||||
for (const entry of await fs.readdir(dir, { withFileTypes: true })) {
|
|
||||||
const path = join(dir, entry.name);
|
|
||||||
if (entry.isDirectory()) yield* walk(path);
|
|
||||||
else yield path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const files = [];
|
|
||||||
for await (const file of walk(DIST)) {
|
|
||||||
if (!COMPRESSIBLE.has(extname(file))) continue;
|
|
||||||
const { size } = await fs.stat(file);
|
|
||||||
if (size >= MIN_SIZE) files.push(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(
|
|
||||||
files.map(async (file) => {
|
|
||||||
const content = await fs.readFile(file);
|
|
||||||
const [gz, br] = await Promise.all([
|
|
||||||
gzip(content, { level: 9 }),
|
|
||||||
brotli(content, {
|
|
||||||
params: {
|
|
||||||
[zlib.constants.BROTLI_PARAM_QUALITY]: 11,
|
|
||||||
[zlib.constants.BROTLI_PARAM_SIZE_HINT]: content.length,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
await Promise.all([
|
|
||||||
fs.writeFile(`${file}.gz`, gz),
|
|
||||||
fs.writeFile(`${file}.br`, br),
|
|
||||||
]);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`precompressed ${files.length} assets (.gz/.br)`);
|
|
||||||
+45
-77
@@ -1,92 +1,60 @@
|
|||||||
import { lazy, Suspense, useEffect } from "react";
|
|
||||||
import { Navigate, Route, Routes } from "react-router-dom";
|
import { Navigate, Route, Routes } from "react-router-dom";
|
||||||
import Layout from "@/components/layouts/global/layout.tsx";
|
import SetupWorkspace from "@/pages/auth/setup-workspace.tsx";
|
||||||
|
import LoginPage from "@/pages/auth/login";
|
||||||
|
import Home from "@/pages/dashboard/home";
|
||||||
|
import Page from "@/pages/page/page";
|
||||||
|
import AccountSettings from "@/pages/settings/account/account-settings";
|
||||||
|
import WorkspaceMembers from "@/pages/settings/workspace/workspace-members";
|
||||||
|
import WorkspaceSettings from "@/pages/settings/workspace/workspace-settings";
|
||||||
|
import Groups from "@/pages/settings/group/groups";
|
||||||
|
import GroupInfo from "./pages/settings/group/group-info";
|
||||||
|
import Spaces from "@/pages/settings/space/spaces.tsx";
|
||||||
import { Error404 } from "@/components/ui/error-404.tsx";
|
import { Error404 } from "@/components/ui/error-404.tsx";
|
||||||
|
import AccountPreferences from "@/pages/settings/account/account-preferences.tsx";
|
||||||
|
import SpaceHome from "@/pages/space/space-home.tsx";
|
||||||
|
import PageRedirect from "@/pages/page/page-redirect.tsx";
|
||||||
|
import Layout from "@/components/layouts/global/layout.tsx";
|
||||||
|
import InviteSignup from "@/pages/auth/invite-signup.tsx";
|
||||||
|
import ForgotPassword from "@/pages/auth/forgot-password.tsx";
|
||||||
|
import PasswordReset from "./pages/auth/password-reset";
|
||||||
|
import Billing from "@/ee/billing/pages/billing.tsx";
|
||||||
|
import CloudLogin from "@/ee/pages/cloud-login.tsx";
|
||||||
|
import CreateWorkspace from "@/ee/pages/create-workspace.tsx";
|
||||||
import { isCloud } from "@/lib/config.ts";
|
import { isCloud } from "@/lib/config.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import Security from "@/ee/security/pages/security.tsx";
|
||||||
|
import License from "@/ee/licence/pages/license.tsx";
|
||||||
import { useRedirectToCloudSelect } from "@/ee/hooks/use-redirect-to-cloud-select.tsx";
|
import { useRedirectToCloudSelect } from "@/ee/hooks/use-redirect-to-cloud-select.tsx";
|
||||||
|
import SharedPage from "@/pages/share/shared-page.tsx";
|
||||||
|
import PdfRenderPage from "@/ee/pdf-export/pdf-render-page.tsx";
|
||||||
|
import Shares from "@/pages/settings/shares/shares.tsx";
|
||||||
|
import ShareLayout from "@/features/share/components/share-layout.tsx";
|
||||||
|
import ShareRedirect from "@/pages/share/share-redirect.tsx";
|
||||||
import { useTrackOrigin } from "@/hooks/use-track-origin";
|
import { useTrackOrigin } from "@/hooks/use-track-origin";
|
||||||
|
import SpacesPage from "@/pages/spaces/spaces.tsx";
|
||||||
const SetupWorkspace = lazy(() => import("@/pages/auth/setup-workspace.tsx"));
|
import { MfaChallengePage } from "@/ee/mfa/pages/mfa-challenge-page";
|
||||||
const LoginPage = lazy(() => import("@/pages/auth/login"));
|
import { MfaSetupRequiredPage } from "@/ee/mfa/pages/mfa-setup-required-page";
|
||||||
const Home = lazy(() => import("@/pages/dashboard/home"));
|
import SpaceTrash from "@/pages/space/space-trash.tsx";
|
||||||
const Page = lazy(() => import("@/pages/page/page"));
|
import UserApiKeys from "@/ee/api-key/pages/user-api-keys";
|
||||||
const AccountSettings = lazy(
|
import WorkspaceApiKeys from "@/ee/api-key/pages/workspace-api-keys";
|
||||||
() => import("@/pages/settings/account/account-settings"),
|
import AiSettings from "@/ee/ai/pages/ai-settings.tsx";
|
||||||
);
|
import BasePage from "@/ee/base/pages/base-page.tsx";
|
||||||
const WorkspaceMembers = lazy(
|
import AuditLogs from "@/ee/audit/pages/audit-logs.tsx";
|
||||||
() => import("@/pages/settings/workspace/workspace-members"),
|
import VerifiedPages from "@/ee/page-verification/pages/verified-pages.tsx";
|
||||||
);
|
import TemplateList from "@/ee/template/pages/template-list";
|
||||||
const WorkspaceSettings = lazy(
|
import TemplateEditor from "@/ee/template/pages/template-editor";
|
||||||
() => import("@/pages/settings/workspace/workspace-settings"),
|
import FavoritesPage from "@/pages/favorites/favorites-page";
|
||||||
);
|
import AiChat from "@/ee/ai-chat/pages/ai-chat.tsx";
|
||||||
const Groups = lazy(() => import("@/pages/settings/group/groups"));
|
import VerifyEmail from "@/ee/pages/verify-email.tsx";
|
||||||
const GroupInfo = lazy(() => import("./pages/settings/group/group-info"));
|
import LabelPage from "@/pages/label/label-page";
|
||||||
const Spaces = lazy(() => import("@/pages/settings/space/spaces.tsx"));
|
|
||||||
const AccountPreferences = lazy(
|
|
||||||
() => import("@/pages/settings/account/account-preferences.tsx"),
|
|
||||||
);
|
|
||||||
const SpaceHome = lazy(() => import("@/pages/space/space-home.tsx"));
|
|
||||||
const PageRedirect = lazy(() => import("@/pages/page/page-redirect.tsx"));
|
|
||||||
const InviteSignup = lazy(() => import("@/pages/auth/invite-signup.tsx"));
|
|
||||||
const ForgotPassword = lazy(() => import("@/pages/auth/forgot-password.tsx"));
|
|
||||||
const PasswordReset = lazy(() => import("./pages/auth/password-reset"));
|
|
||||||
const Billing = lazy(() => import("@/ee/billing/pages/billing.tsx"));
|
|
||||||
const CloudLogin = lazy(() => import("@/ee/pages/cloud-login.tsx"));
|
|
||||||
const CreateWorkspace = lazy(() => import("@/ee/pages/create-workspace.tsx"));
|
|
||||||
const Security = lazy(() => import("@/ee/security/pages/security.tsx"));
|
|
||||||
const License = lazy(() => import("@/ee/licence/pages/license.tsx"));
|
|
||||||
const SharedPage = lazy(() => import("@/pages/share/shared-page.tsx"));
|
|
||||||
const PdfRenderPage = lazy(() => import("@/ee/pdf-export/pdf-render-page.tsx"));
|
|
||||||
const Shares = lazy(() => import("@/pages/settings/shares/shares.tsx"));
|
|
||||||
const ShareLayout = lazy(
|
|
||||||
() => import("@/features/share/components/share-layout.tsx"),
|
|
||||||
);
|
|
||||||
const ShareRedirect = lazy(() => import("@/pages/share/share-redirect.tsx"));
|
|
||||||
const SpacesPage = lazy(() => import("@/pages/spaces/spaces.tsx"));
|
|
||||||
const MfaChallengePage = lazy(() =>
|
|
||||||
import("@/ee/mfa/pages/mfa-challenge-page").then((m) => ({
|
|
||||||
default: m.MfaChallengePage,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
const MfaSetupRequiredPage = lazy(() =>
|
|
||||||
import("@/ee/mfa/pages/mfa-setup-required-page").then((m) => ({
|
|
||||||
default: m.MfaSetupRequiredPage,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
const SpaceTrash = lazy(() => import("@/pages/space/space-trash.tsx"));
|
|
||||||
const UserApiKeys = lazy(() => import("@/ee/api-key/pages/user-api-keys"));
|
|
||||||
const WorkspaceApiKeys = lazy(
|
|
||||||
() => import("@/ee/api-key/pages/workspace-api-keys"),
|
|
||||||
);
|
|
||||||
const AiSettings = lazy(() => import("@/ee/ai/pages/ai-settings.tsx"));
|
|
||||||
const BasePage = lazy(() => import("@/ee/base/pages/base-page.tsx"));
|
|
||||||
const AuditLogs = lazy(() => import("@/ee/audit/pages/audit-logs.tsx"));
|
|
||||||
const VerifiedPages = lazy(
|
|
||||||
() => import("@/ee/page-verification/pages/verified-pages.tsx"),
|
|
||||||
);
|
|
||||||
const TemplateList = lazy(() => import("@/ee/template/pages/template-list"));
|
|
||||||
const TemplateEditor = lazy(
|
|
||||||
() => import("@/ee/template/pages/template-editor"),
|
|
||||||
);
|
|
||||||
const FavoritesPage = lazy(() => import("@/pages/favorites/favorites-page"));
|
|
||||||
const AiChat = lazy(() => import("@/ee/ai-chat/pages/ai-chat.tsx"));
|
|
||||||
const VerifyEmail = lazy(() => import("@/ee/pages/verify-email.tsx"));
|
|
||||||
const LabelPage = lazy(() => import("@/pages/label/label-page"));
|
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
useRedirectToCloudSelect();
|
useRedirectToCloudSelect();
|
||||||
useTrackOrigin();
|
useTrackOrigin();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// warm the editor chunk so opening a page doesn't wait on the network
|
|
||||||
const timer = setTimeout(() => import("@/pages/page/page"), 3000);
|
|
||||||
return () => clearTimeout(timer);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={null}>
|
<>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route index element={<Navigate to="/home" />} />
|
<Route index element={<Navigate to="/home" />} />
|
||||||
<Route path={"/login"} element={<LoginPage />} />
|
<Route path={"/login"} element={<LoginPage />} />
|
||||||
@@ -167,6 +135,6 @@ export default function App() {
|
|||||||
|
|
||||||
<Route path="*" element={<Error404 />} />
|
<Route path="*" element={<Error404 />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</Suspense>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,17 @@
|
|||||||
import { ActionIcon, Box, Group, ScrollArea, Title, Tooltip } from "@mantine/core";
|
import { ActionIcon, Box, Group, ScrollArea, Title, Tooltip } from "@mantine/core";
|
||||||
import { IconX } from "@tabler/icons-react";
|
import { IconX } from "@tabler/icons-react";
|
||||||
|
import CommentListWithTabs from "@/features/comment/components/comment-list-with-tabs.tsx";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
||||||
import React, { lazy, ReactNode, Suspense, useEffect } from "react";
|
import React, { ReactNode, useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { TableOfContents } from "@/features/editor/components/table-of-contents/table-of-contents.tsx";
|
||||||
import { useAtomValue } from "jotai";
|
import { useAtomValue } from "jotai";
|
||||||
import { pageEditorAtom } from "@/features/editor/atoms/editor-atoms.ts";
|
import { pageEditorAtom } from "@/features/editor/atoms/editor-atoms.ts";
|
||||||
|
import AsideChatPanel from "@/ee/ai-chat/components/aside-chat-panel";
|
||||||
|
import { PageDetailsAside } from "@/features/page-details/components/page-details-aside.tsx";
|
||||||
import { ASIDE_PANEL_ID } from "@/hooks/use-toggle-aside.tsx";
|
import { ASIDE_PANEL_ID } from "@/hooks/use-toggle-aside.tsx";
|
||||||
|
|
||||||
const CommentListWithTabs = lazy(
|
|
||||||
() => import("@/features/comment/components/comment-list-with-tabs.tsx"),
|
|
||||||
);
|
|
||||||
const TableOfContents = lazy(() =>
|
|
||||||
import(
|
|
||||||
"@/features/editor/components/table-of-contents/table-of-contents.tsx"
|
|
||||||
).then((m) => ({ default: m.TableOfContents })),
|
|
||||||
);
|
|
||||||
const AsideChatPanel = lazy(
|
|
||||||
() => import("@/ee/ai-chat/components/aside-chat-panel"),
|
|
||||||
);
|
|
||||||
const PageDetailsAside = lazy(() =>
|
|
||||||
import("@/features/page-details/components/page-details-aside.tsx").then(
|
|
||||||
(m) => ({ default: m.PageDetailsAside }),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
export default function Aside() {
|
export default function Aside() {
|
||||||
const [{ tab, isAsideOpen }, setAsideState] = useAtom(asideStateAtom);
|
const [{ tab, isAsideOpen }, setAsideState] = useAtom(asideStateAtom);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -81,19 +68,17 @@ export default function Aside() {
|
|||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Suspense fallback={null}>
|
{tab === "comments" || tab === "chat" ? (
|
||||||
{tab === "comments" || tab === "chat" ? (
|
component
|
||||||
component
|
) : (
|
||||||
) : (
|
<ScrollArea
|
||||||
<ScrollArea
|
style={{ height: "85vh" }}
|
||||||
style={{ height: "85vh" }}
|
scrollbarSize={5}
|
||||||
scrollbarSize={5}
|
type="scroll"
|
||||||
type="scroll"
|
>
|
||||||
>
|
<div style={{ paddingBottom: "200px" }}>{component}</div>
|
||||||
<div style={{ paddingBottom: "200px" }}>{component}</div>
|
</ScrollArea>
|
||||||
</ScrollArea>
|
)}
|
||||||
)}
|
|
||||||
</Suspense>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ import {
|
|||||||
sidebarWidthAtom,
|
sidebarWidthAtom,
|
||||||
} from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
} from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
||||||
import { SpaceSidebar } from "@/features/space/components/sidebar/space-sidebar.tsx";
|
import { SpaceSidebar } from "@/features/space/components/sidebar/space-sidebar.tsx";
|
||||||
|
import AiChatSidebar from "@/ee/ai-chat/components/ai-chat-sidebar.tsx";
|
||||||
const AiChatSidebar = React.lazy(
|
|
||||||
() => import("@/ee/ai-chat/components/ai-chat-sidebar.tsx"),
|
|
||||||
);
|
|
||||||
import { AppHeader } from "@/components/layouts/global/app-header.tsx";
|
import { AppHeader } from "@/components/layouts/global/app-header.tsx";
|
||||||
import Aside from "@/components/layouts/global/aside.tsx";
|
import Aside from "@/components/layouts/global/aside.tsx";
|
||||||
import classes from "./app-shell.module.css";
|
import classes from "./app-shell.module.css";
|
||||||
@@ -129,11 +126,7 @@ export default function GlobalAppShell({
|
|||||||
)}
|
)}
|
||||||
{isSpaceRoute && <SpaceSidebar />}
|
{isSpaceRoute && <SpaceSidebar />}
|
||||||
{isSettingsRoute && <SettingsSidebar />}
|
{isSettingsRoute && <SettingsSidebar />}
|
||||||
{isAiRoute && (
|
{isAiRoute && <AiChatSidebar />}
|
||||||
<React.Suspense fallback={null}>
|
|
||||||
<AiChatSidebar />
|
|
||||||
</React.Suspense>
|
|
||||||
)}
|
|
||||||
{showGlobalSidebar && <GlobalSidebar />}
|
{showGlobalSidebar && <GlobalSidebar />}
|
||||||
</AppShell.Navbar>
|
</AppShell.Navbar>
|
||||||
<AppShell.Main id={MAIN_CONTENT_ID} tabIndex={-1}>
|
<AppShell.Main id={MAIN_CONTENT_ID} tabIndex={-1}>
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
import { describe, expect, it, beforeEach } from "vitest";
|
|
||||||
import { render } from "@testing-library/react";
|
|
||||||
import { HelmetProvider } from "react-helmet-async";
|
|
||||||
import { DocumentTitle } from "./document-title.tsx";
|
|
||||||
|
|
||||||
const renderTitle = (ui: React.ReactNode) =>
|
|
||||||
render(<HelmetProvider>{ui}</HelmetProvider>);
|
|
||||||
|
|
||||||
describe("DocumentTitle", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
document.head.innerHTML = "<title>Docmost</title>";
|
|
||||||
});
|
|
||||||
|
|
||||||
it("appends the app name", () => {
|
|
||||||
renderTitle(<DocumentTitle title="Home" />);
|
|
||||||
expect(document.title).toBe("Home - Docmost");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("omits the app name when asked", () => {
|
|
||||||
renderTitle(<DocumentTitle title="My page" withAppName={false} />);
|
|
||||||
expect(document.title).toBe("My page");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("falls back to the app name without a title", () => {
|
|
||||||
renderTitle(<DocumentTitle />);
|
|
||||||
expect(document.title).toBe("Docmost");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("never renders an empty title", () => {
|
|
||||||
renderTitle(<DocumentTitle title="Spaces" />);
|
|
||||||
const titles = Array.from(document.querySelectorAll("head > title"));
|
|
||||||
expect(titles.every((node) => node.textContent !== "")).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders extra head children", () => {
|
|
||||||
renderTitle(
|
|
||||||
<DocumentTitle title="Shared">
|
|
||||||
<meta name="robots" content="noindex" />
|
|
||||||
</DocumentTitle>,
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
document.querySelector('head > meta[name="robots"]')?.getAttribute("content"),
|
|
||||||
).toBe("noindex");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { Helmet } from "react-helmet-async";
|
|
||||||
import { getAppName } from "@/lib/config.ts";
|
|
||||||
|
|
||||||
type DocumentTitleProps = {
|
|
||||||
title?: string;
|
|
||||||
withAppName?: boolean;
|
|
||||||
children?: React.ReactNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function DocumentTitle({
|
|
||||||
title,
|
|
||||||
withAppName = true,
|
|
||||||
children,
|
|
||||||
}: DocumentTitleProps) {
|
|
||||||
const appName = getAppName();
|
|
||||||
|
|
||||||
let documentTitle = appName;
|
|
||||||
if (title) {
|
|
||||||
documentTitle = withAppName ? `${title} - ${appName}` : title;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Helmet>
|
|
||||||
<title>{documentTitle}</title>
|
|
||||||
{children}
|
|
||||||
</Helmet>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,17 @@
|
|||||||
import { Title, Text, Button, Container, Group } from "@mantine/core";
|
import { Title, Text, Button, Container, Group } from "@mantine/core";
|
||||||
import classes from "./error-404.module.css";
|
import classes from "./error-404.module.css";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export function Error404() {
|
export function Error404() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("404 page not found")} />
|
<Helmet>
|
||||||
|
<title>{t("404 page not found")} - Docmost</title>
|
||||||
|
</Helmet>
|
||||||
<Container className={classes.root}>
|
<Container className={classes.root}>
|
||||||
<Title className={classes.title}>{t("404 page not found")}</Title>
|
<Title className={classes.title}>{t("404 page not found")}</Title>
|
||||||
<Text c="dimmed" size="lg" ta="center" className={classes.description}>
|
<Text c="dimmed" size="lg" ta="center" className={classes.description}>
|
||||||
|
|||||||
@@ -255,7 +255,6 @@ export default function ChatInput({
|
|||||||
},
|
},
|
||||||
content: "",
|
content: "",
|
||||||
editable: true,
|
editable: true,
|
||||||
textDirection: "auto",
|
|
||||||
immediatelyRender: true,
|
immediatelyRender: true,
|
||||||
shouldRerenderOnTransaction: false,
|
shouldRerenderOnTransaction: false,
|
||||||
autofocus: autofocus ? "end" : false,
|
autofocus: autofocus ? "end" : false,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
@@ -13,7 +15,6 @@ import { Feature } from "@/ee/features";
|
|||||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||||
import { isCloud } from "@/lib/config.ts";
|
import { isCloud } from "@/lib/config.ts";
|
||||||
import { useLocation, useNavigate } from "react-router-dom";
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function AiSettings() {
|
export default function AiSettings() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -39,7 +40,9 @@ export default function AiSettings() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title="AI settings" />
|
<Helmet>
|
||||||
|
<title>AI settings - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title={t("AI settings")} />
|
<SettingsTitle title={t("AI settings")} />
|
||||||
|
|
||||||
<Tabs color="dark" value={activeTab} onChange={handleTabChange}>
|
<Tabs color="dark" value={activeTab} onChange={handleTabChange}>
|
||||||
|
|||||||
@@ -15,14 +15,6 @@ export interface IAiSearchResponse {
|
|||||||
}>;
|
}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function hintVectorCache(): Promise<void> {
|
|
||||||
try {
|
|
||||||
await api.post("/ai/vector-cache-hint");
|
|
||||||
} catch {
|
|
||||||
// best-effort cache hint
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function aiAnswers(
|
export async function aiAnswers(
|
||||||
params: IPageSearchParams,
|
params: IPageSearchParams,
|
||||||
onChunk?: (chunk: { content?: string; sources?: any[] }) => void,
|
onChunk?: (chunk: { content?: string; sources?: any[] }) => void,
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Anchor, Alert, Button, Group, Space, Text } from "@mantine/core";
|
import { Anchor, Alert, Button, Group, Space, Text } from "@mantine/core";
|
||||||
import { IconInfoCircle } from "@tabler/icons-react";
|
import { IconInfoCircle } from "@tabler/icons-react";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { Trans, useTranslation } from "react-i18next";
|
import { Trans, useTranslation } from "react-i18next";
|
||||||
import SettingsTitle from "@/components/settings/settings-title";
|
import SettingsTitle from "@/components/settings/settings-title";
|
||||||
import { getAppUrl } from "@/lib/config";
|
import { getAppName, getAppUrl } from "@/lib/config";
|
||||||
import { ApiKeyTable } from "@/ee/api-key/components/api-key-table";
|
import { ApiKeyTable } from "@/ee/api-key/components/api-key-table";
|
||||||
import { CreateApiKeyModal } from "@/ee/api-key/components/create-api-key-modal";
|
import { CreateApiKeyModal } from "@/ee/api-key/components/create-api-key-modal";
|
||||||
import { ApiKeyCreatedModal } from "@/ee/api-key/components/api-key-created-modal";
|
import { ApiKeyCreatedModal } from "@/ee/api-key/components/api-key-created-modal";
|
||||||
@@ -16,7 +17,6 @@ import { IApiKey } from "@/ee/api-key";
|
|||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function UserApiKeys() {
|
export default function UserApiKeys() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -49,7 +49,11 @@ export default function UserApiKeys() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("API keys")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("API keys")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
<SettingsTitle title={t("API keys")} />
|
<SettingsTitle title={t("API keys")} />
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Anchor, Button, Divider, Group, Space, Text } from "@mantine/core";
|
import { Anchor, Button, Divider, Group, Space, Text } from "@mantine/core";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { Trans, useTranslation } from "react-i18next";
|
import { Trans, useTranslation } from "react-i18next";
|
||||||
import SettingsTitle from "@/components/settings/settings-title";
|
import SettingsTitle from "@/components/settings/settings-title";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
import { ApiKeyTable } from "@/ee/api-key/components/api-key-table";
|
import { ApiKeyTable } from "@/ee/api-key/components/api-key-table";
|
||||||
import { CreateApiKeyModal } from "@/ee/api-key/components/create-api-key-modal";
|
import { CreateApiKeyModal } from "@/ee/api-key/components/create-api-key-modal";
|
||||||
import { ApiKeyCreatedModal } from "@/ee/api-key/components/api-key-created-modal";
|
import { ApiKeyCreatedModal } from "@/ee/api-key/components/api-key-created-modal";
|
||||||
@@ -13,7 +15,6 @@ import { useGetApiKeysQuery } from "@/ee/api-key/queries/api-key-query.ts";
|
|||||||
import { IApiKey } from "@/ee/api-key";
|
import { IApiKey } from "@/ee/api-key";
|
||||||
import useUserRole from '@/hooks/use-user-role.tsx';
|
import useUserRole from '@/hooks/use-user-role.tsx';
|
||||||
import RestrictApiToAdmins from "@/ee/api-key/components/restrict-api-to-admins";
|
import RestrictApiToAdmins from "@/ee/api-key/components/restrict-api-to-admins";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function WorkspaceApiKeys() {
|
export default function WorkspaceApiKeys() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -46,7 +47,11 @@ export default function WorkspaceApiKeys() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("API management")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("API management")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
<SettingsTitle title={t("API management")} />
|
<SettingsTitle title={t("API management")} />
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { IconSettings } from "@tabler/icons-react";
|
import { IconSettings } from "@tabler/icons-react";
|
||||||
import SettingsTitle from "@/components/settings/settings-title";
|
import SettingsTitle from "@/components/settings/settings-title";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
import Paginate from "@/components/common/paginate";
|
import Paginate from "@/components/common/paginate";
|
||||||
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
||||||
import {
|
import {
|
||||||
@@ -24,7 +26,6 @@ import { IAuditLogParams } from "@/ee/audit/types/audit.types";
|
|||||||
import { eventFilterOptions } from "@/ee/audit/lib/audit-event-labels";
|
import { eventFilterOptions } from "@/ee/audit/lib/audit-event-labels";
|
||||||
import AuditLogsTable from "@/ee/audit/components/audit-logs-table";
|
import AuditLogsTable from "@/ee/audit/components/audit-logs-table";
|
||||||
import useUserRole from "@/hooks/use-user-role";
|
import useUserRole from "@/hooks/use-user-role";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
type RetentionUnit = "days" | "months" | "years";
|
type RetentionUnit = "days" | "months" | "years";
|
||||||
|
|
||||||
@@ -96,7 +97,11 @@ export default function AuditLogs() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Audit log")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Audit log")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
<SettingsTitle title={t("Audit log")} />
|
<SettingsTitle title={t("Audit log")} />
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||||
import BillingPlans from "@/ee/billing/components/billing-plans.tsx";
|
import BillingPlans from "@/ee/billing/components/billing-plans.tsx";
|
||||||
import BillingTrial from "@/ee/billing/components/billing-trial.tsx";
|
import BillingTrial from "@/ee/billing/components/billing-trial.tsx";
|
||||||
@@ -7,7 +9,6 @@ import React from "react";
|
|||||||
import BillingDetails from "@/ee/billing/components/billing-details.tsx";
|
import BillingDetails from "@/ee/billing/components/billing-details.tsx";
|
||||||
import { useBillingQuery } from "@/ee/billing/queries/billing-query.ts";
|
import { useBillingQuery } from "@/ee/billing/queries/billing-query.ts";
|
||||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function Billing() {
|
export default function Billing() {
|
||||||
const { data: billing, isError: isBillingError } = useBillingQuery();
|
const { data: billing, isError: isBillingError } = useBillingQuery();
|
||||||
@@ -19,7 +20,9 @@ export default function Billing() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title="Billing" />
|
<Helmet>
|
||||||
|
<title>Billing - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title="Billing" />
|
<SettingsTitle title="Billing" />
|
||||||
|
|
||||||
<BillingTrial />
|
<BillingTrial />
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
@@ -7,7 +9,6 @@ import InstallationDetails from "@/ee/licence/components/installation-details.ts
|
|||||||
import OssDetails from "@/ee/licence/components/oss-details.tsx";
|
import OssDetails from "@/ee/licence/components/oss-details.tsx";
|
||||||
import { useAtom } from "jotai/index";
|
import { useAtom } from "jotai/index";
|
||||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function License() {
|
export default function License() {
|
||||||
const [entitlements] = useAtom(entitlementAtom);
|
const [entitlements] = useAtom(entitlementAtom);
|
||||||
@@ -20,7 +21,9 @@ export default function License() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title="License" />
|
<Helmet>
|
||||||
|
<title>License - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title="License" />
|
<SettingsTitle title="License" />
|
||||||
|
|
||||||
<ActivateLicenseForm />
|
<ActivateLicenseForm />
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
import { useState, useMemo } from "react";
|
import { useState, useMemo } from "react";
|
||||||
import { Group, MultiSelect, Select, Space, TextInput } from "@mantine/core";
|
import { Group, MultiSelect, Select, Space, TextInput } from "@mantine/core";
|
||||||
import { useDebouncedValue } from "@mantine/hooks";
|
import { useDebouncedValue } from "@mantine/hooks";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { IconSearch } from "@tabler/icons-react";
|
import { IconSearch } from "@tabler/icons-react";
|
||||||
import SettingsTitle from "@/components/settings/settings-title";
|
import SettingsTitle from "@/components/settings/settings-title";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
import Paginate from "@/components/common/paginate";
|
import Paginate from "@/components/common/paginate";
|
||||||
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
||||||
import { useVerificationListQuery } from "@/ee/page-verification/queries/page-verification-query";
|
import { useVerificationListQuery } from "@/ee/page-verification/queries/page-verification-query";
|
||||||
import { IVerificationListParams } from "@/ee/page-verification/types/page-verification.types";
|
import { IVerificationListParams } from "@/ee/page-verification/types/page-verification.types";
|
||||||
import VerificationListTable from "@/ee/page-verification/components/verification-list-table";
|
import VerificationListTable from "@/ee/page-verification/components/verification-list-table";
|
||||||
import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function VerifiedPages() {
|
export default function VerifiedPages() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -67,7 +68,11 @@ export default function VerifiedPages() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Verified pages")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Verified pages")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
<SettingsTitle title={t("Verified pages")} />
|
<SettingsTitle title={t("Verified pages")} />
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import { CloudLoginForm } from "@/ee/components/cloud-login-form.tsx";
|
import { CloudLoginForm } from "@/ee/components/cloud-login-form.tsx";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function CloudLogin() {
|
export default function CloudLogin() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Login")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Login")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
<CloudLoginForm />
|
<CloudLoginForm />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import { SetupWorkspaceForm } from "@/features/auth/components/setup-workspace-form.tsx";
|
import { SetupWorkspaceForm } from "@/features/auth/components/setup-workspace-form.tsx";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
import { getAppName } from "@/lib/config.ts";
|
||||||
|
|
||||||
export default function CreateWorkspace() {
|
export default function CreateWorkspace() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title="Create Workspace" />
|
<Helmet>
|
||||||
|
<title>Create Workspace - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
<SetupWorkspaceForm />
|
<SetupWorkspaceForm />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { isCloud } from "@/lib/config.ts";
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName, isCloud } from "@/lib/config.ts";
|
||||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
@@ -36,7 +37,6 @@ import EnableScim from "@/ee/scim/components/enable-scim";
|
|||||||
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
||||||
import Paginate from "@/components/common/paginate";
|
import Paginate from "@/components/common/paginate";
|
||||||
import { IScimToken } from "@/ee/scim/types/scim-token.types";
|
import { IScimToken } from "@/ee/scim/types/scim-token.types";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
const SCIM_TOKEN_LIMIT = 5;
|
const SCIM_TOKEN_LIMIT = 5;
|
||||||
|
|
||||||
@@ -64,7 +64,9 @@ export default function Security() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title="Security" />
|
<Helmet>
|
||||||
|
<title>Security - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title={t("Security")} />
|
<SettingsTitle title={t("Security")} />
|
||||||
|
|
||||||
<EnforceMfa />
|
<EnforceMfa />
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ export default function ReadonlyTemplateEditor({
|
|||||||
<EditorProvider
|
<EditorProvider
|
||||||
editable={false}
|
editable={false}
|
||||||
immediatelyRender={true}
|
immediatelyRender={true}
|
||||||
textDirection="auto"
|
|
||||||
extensions={extensions}
|
extensions={extensions}
|
||||||
content={template.content}
|
content={template.content}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { useDisclosure, useWindowEvent } from "@mantine/hooks";
|
import { useDisclosure, useWindowEvent } from "@mantine/hooks";
|
||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
import { Link, useParams } from "react-router-dom";
|
import { Link, useParams } from "react-router-dom";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
import { useEditor, EditorContent } from "@tiptap/react";
|
import { useEditor, EditorContent } from "@tiptap/react";
|
||||||
import { templateExtensions } from "@/features/editor/extensions/extensions";
|
import { templateExtensions } from "@/features/editor/extensions/extensions";
|
||||||
import {
|
import {
|
||||||
@@ -42,7 +44,6 @@ import CalloutMenu from "@/features/editor/components/callout/callout-menu.tsx";
|
|||||||
import ColumnsMenu from "@/features/editor/components/columns/columns-menu.tsx";
|
import ColumnsMenu from "@/features/editor/components/columns/columns-menu.tsx";
|
||||||
|
|
||||||
import classes from "./template-editor.module.css";
|
import classes from "./template-editor.module.css";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function TemplateEditor() {
|
export default function TemplateEditor() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -87,7 +88,6 @@ export default function TemplateEditor() {
|
|||||||
const editor = useEditor({
|
const editor = useEditor({
|
||||||
extensions: templateExtensions,
|
extensions: templateExtensions,
|
||||||
content: "",
|
content: "",
|
||||||
textDirection: "auto",
|
|
||||||
editorProps: {
|
editorProps: {
|
||||||
scrollThreshold: 80,
|
scrollThreshold: 80,
|
||||||
scrollMargin: 80,
|
scrollMargin: 80,
|
||||||
@@ -247,7 +247,11 @@ export default function TemplateEditor() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Edit template")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Edit template")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
{editorToolbarEnabled && editor && (
|
{editorToolbarEnabled && editor && (
|
||||||
<FixedToolbar editor={editor} templateMode />
|
<FixedToolbar editor={editor} templateMode />
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ import {
|
|||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { modals } from "@mantine/modals";
|
import { modals } from "@mantine/modals";
|
||||||
import { IconPlus } from "@tabler/icons-react";
|
import { IconPlus } from "@tabler/icons-react";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
import {
|
import {
|
||||||
useGetTemplatesQuery,
|
useGetTemplatesQuery,
|
||||||
useDeleteTemplateMutation,
|
useDeleteTemplateMutation,
|
||||||
@@ -29,7 +31,6 @@ import useUserRole from "@/hooks/use-user-role";
|
|||||||
import CreateTemplateModal from "@/ee/template/components/create-template-modal";
|
import CreateTemplateModal from "@/ee/template/components/create-template-modal";
|
||||||
import { useAtomValue } from "jotai";
|
import { useAtomValue } from "jotai";
|
||||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom";
|
import { workspaceAtom } from "@/features/user/atoms/current-user-atom";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function TemplateList() {
|
export default function TemplateList() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -101,7 +102,11 @@ export default function TemplateList() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Templates")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Templates")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
<Container size="900" pt="xl">
|
<Container size="900" pt="xl">
|
||||||
<Group justify="space-between" mb="xl">
|
<Group justify="space-between" mb="xl">
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
import { ThemeIcon } from "@mantine/core";
|
|
||||||
import {
|
|
||||||
IconFile,
|
|
||||||
IconFileTypeCsv,
|
|
||||||
IconFileTypeDocx,
|
|
||||||
IconFileTypePdf,
|
|
||||||
IconFileTypePpt,
|
|
||||||
IconFileTypeXls,
|
|
||||||
IconFileZip,
|
|
||||||
IconMovie,
|
|
||||||
IconMusic,
|
|
||||||
IconPhoto,
|
|
||||||
type Icon,
|
|
||||||
} from "@tabler/icons-react";
|
|
||||||
|
|
||||||
const EXT_ICONS: Record<string, { icon: Icon; color: string }> = {
|
|
||||||
".pdf": { icon: IconFileTypePdf, color: "red" },
|
|
||||||
".doc": { icon: IconFileTypeDocx, color: "blue" },
|
|
||||||
".docx": { icon: IconFileTypeDocx, color: "blue" },
|
|
||||||
".xls": { icon: IconFileTypeXls, color: "teal" },
|
|
||||||
".xlsx": { icon: IconFileTypeXls, color: "teal" },
|
|
||||||
".csv": { icon: IconFileTypeCsv, color: "teal" },
|
|
||||||
".ppt": { icon: IconFileTypePpt, color: "orange" },
|
|
||||||
".pptx": { icon: IconFileTypePpt, color: "orange" },
|
|
||||||
".zip": { icon: IconFileZip, color: "gray" },
|
|
||||||
".rar": { icon: IconFileZip, color: "gray" },
|
|
||||||
".7z": { icon: IconFileZip, color: "gray" },
|
|
||||||
".tar": { icon: IconFileZip, color: "gray" },
|
|
||||||
".gz": { icon: IconFileZip, color: "gray" },
|
|
||||||
};
|
|
||||||
|
|
||||||
const MIME_ICONS: Array<{ prefix: string; icon: Icon; color: string }> = [
|
|
||||||
{ prefix: "image/", icon: IconPhoto, color: "grape" },
|
|
||||||
{ prefix: "video/", icon: IconMovie, color: "violet" },
|
|
||||||
{ prefix: "audio/", icon: IconMusic, color: "pink" },
|
|
||||||
];
|
|
||||||
|
|
||||||
interface AttachmentFileIconProps {
|
|
||||||
fileExt?: string;
|
|
||||||
mimeType?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AttachmentFileIcon({
|
|
||||||
fileExt,
|
|
||||||
mimeType,
|
|
||||||
}: AttachmentFileIconProps) {
|
|
||||||
const byExt = fileExt ? EXT_ICONS[fileExt.toLowerCase()] : undefined;
|
|
||||||
const byMime = mimeType
|
|
||||||
? MIME_ICONS.find((entry) => mimeType.startsWith(entry.prefix))
|
|
||||||
: undefined;
|
|
||||||
const { icon: FileIcon, color } = byExt ??
|
|
||||||
byMime ?? { icon: IconFile, color: "gray" };
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ThemeIcon variant="light" color={color} size={40} radius="md">
|
|
||||||
<FileIcon size={22} stroke={1.5} />
|
|
||||||
</ThemeIcon>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
||||||
import {
|
|
||||||
ActionIcon,
|
|
||||||
Anchor,
|
|
||||||
Center,
|
|
||||||
Group,
|
|
||||||
Loader,
|
|
||||||
Modal,
|
|
||||||
ScrollArea,
|
|
||||||
Text,
|
|
||||||
Tooltip,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconDownload } from "@tabler/icons-react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { SearchInput } from "@/components/common/search-input.tsx";
|
|
||||||
import { CustomAvatar } from "@/components/ui/custom-avatar.tsx";
|
|
||||||
import { usePageAttachmentsQuery } from "@/features/attachments/queries/attachment-query.ts";
|
|
||||||
import { IPageAttachment } from "@/features/attachments/types/attachment.types.ts";
|
|
||||||
import { AttachmentFileIcon } from "@/features/attachments/components/attachment-file-icon.tsx";
|
|
||||||
import { formatBytes } from "@/lib";
|
|
||||||
import { getFileUrl } from "@/lib/config.ts";
|
|
||||||
import { formattedDate } from "@/lib/time.ts";
|
|
||||||
|
|
||||||
interface PageAttachmentsModalProps {
|
|
||||||
pageId: string;
|
|
||||||
open: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function PageAttachmentsModal({
|
|
||||||
pageId,
|
|
||||||
open,
|
|
||||||
onClose,
|
|
||||||
}: PageAttachmentsModalProps) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
opened={open}
|
|
||||||
onClose={onClose}
|
|
||||||
title={t("Attachments")}
|
|
||||||
size={800}
|
|
||||||
closeButtonProps={{ "aria-label": t("Close") }}
|
|
||||||
>
|
|
||||||
<PageAttachmentsList pageId={pageId} />
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function PageAttachmentsList({ pageId }: { pageId: string }) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const [search, setSearch] = useState("");
|
|
||||||
const {
|
|
||||||
data,
|
|
||||||
isLoading,
|
|
||||||
isError,
|
|
||||||
isFetching,
|
|
||||||
fetchNextPage,
|
|
||||||
hasNextPage,
|
|
||||||
isFetchingNextPage,
|
|
||||||
} = usePageAttachmentsQuery(pageId, search);
|
|
||||||
|
|
||||||
const attachments = useMemo(
|
|
||||||
() => data?.pages.flatMap((page) => page.items) ?? [],
|
|
||||||
[data],
|
|
||||||
);
|
|
||||||
|
|
||||||
const loadMoreRef = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const sentinel = loadMoreRef.current;
|
|
||||||
if (!sentinel || !hasNextPage) return;
|
|
||||||
|
|
||||||
const observer = new IntersectionObserver(
|
|
||||||
(entries) => {
|
|
||||||
if (entries[0].isIntersecting && !isFetching) {
|
|
||||||
fetchNextPage();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ threshold: 0.1 },
|
|
||||||
);
|
|
||||||
|
|
||||||
observer.observe(sentinel);
|
|
||||||
return () => observer.disconnect();
|
|
||||||
}, [fetchNextPage, hasNextPage, isFetching]);
|
|
||||||
|
|
||||||
const handleSearch = useCallback((value: string) => setSearch(value), []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<SearchInput
|
|
||||||
onSearch={handleSearch}
|
|
||||||
placeholder={t("Search attachments...")}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{isLoading ? (
|
|
||||||
<Center py="xl">
|
|
||||||
<Loader size="sm" />
|
|
||||||
</Center>
|
|
||||||
) : isError ? (
|
|
||||||
<Center py="xl">
|
|
||||||
<Text size="sm" c="dimmed">
|
|
||||||
{t("Error loading attachments.")}
|
|
||||||
</Text>
|
|
||||||
</Center>
|
|
||||||
) : attachments.length === 0 ? (
|
|
||||||
<Center py="xl">
|
|
||||||
<Text size="sm" c="dimmed">
|
|
||||||
{search
|
|
||||||
? t("No results found")
|
|
||||||
: t("No attachments on this page yet.")}
|
|
||||||
</Text>
|
|
||||||
</Center>
|
|
||||||
) : (
|
|
||||||
<ScrollArea.Autosize mah={480} type="scroll" scrollbarSize={5}>
|
|
||||||
{attachments.map((attachment) => (
|
|
||||||
<AttachmentRow key={attachment.id} attachment={attachment} />
|
|
||||||
))}
|
|
||||||
{hasNextPage && <div ref={loadMoreRef} style={{ height: 1 }} />}
|
|
||||||
{isFetchingNextPage && (
|
|
||||||
<Center py="sm">
|
|
||||||
<Loader size="sm" />
|
|
||||||
</Center>
|
|
||||||
)}
|
|
||||||
</ScrollArea.Autosize>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function AttachmentRow({ attachment }: { attachment: IPageAttachment }) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const fileUrl = getFileUrl(attachment.url);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Group wrap="nowrap" gap="md" py="sm" pr="xs">
|
|
||||||
<AttachmentFileIcon
|
|
||||||
fileExt={attachment.fileExt}
|
|
||||||
mimeType={attachment.mimeType}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
|
||||||
<Anchor
|
|
||||||
href={fileUrl}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
size="sm"
|
|
||||||
fw={500}
|
|
||||||
c="inherit"
|
|
||||||
truncate="end"
|
|
||||||
style={{ display: "block" }}
|
|
||||||
>
|
|
||||||
{attachment.fileName}
|
|
||||||
</Anchor>
|
|
||||||
<Text size="xs" c="dimmed" mt={2} truncate="end">
|
|
||||||
{formatBytes(Number(attachment.fileSize))}
|
|
||||||
{" · "}
|
|
||||||
{formattedDate(new Date(attachment.createdAt))}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{attachment.creator && (
|
|
||||||
<Tooltip
|
|
||||||
label={t("Uploaded by {{name}}", { name: attachment.creator.name })}
|
|
||||||
withArrow
|
|
||||||
>
|
|
||||||
<CustomAvatar
|
|
||||||
avatarUrl={attachment.creator.avatarUrl}
|
|
||||||
name={attachment.creator.name}
|
|
||||||
size="sm"
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Tooltip label={t("Download attachment")} withArrow>
|
|
||||||
<ActionIcon
|
|
||||||
component="a"
|
|
||||||
href={fileUrl}
|
|
||||||
download={attachment.fileName}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
variant="subtle"
|
|
||||||
color="gray"
|
|
||||||
aria-label={t("Download {{name}}", { name: attachment.fileName })}
|
|
||||||
>
|
|
||||||
<IconDownload size={18} />
|
|
||||||
</ActionIcon>
|
|
||||||
</Tooltip>
|
|
||||||
</Group>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import {
|
|
||||||
InfiniteData,
|
|
||||||
keepPreviousData,
|
|
||||||
useInfiniteQuery,
|
|
||||||
UseInfiniteQueryResult,
|
|
||||||
} from "@tanstack/react-query";
|
|
||||||
import { getPageAttachments } from "@/features/attachments/services/attachment-service.ts";
|
|
||||||
import { IPageAttachment } from "@/features/attachments/types/attachment.types.ts";
|
|
||||||
import { IPagination } from "@/lib/types.ts";
|
|
||||||
|
|
||||||
export function usePageAttachmentsQuery(
|
|
||||||
pageId: string,
|
|
||||||
search?: string,
|
|
||||||
): UseInfiniteQueryResult<InfiniteData<IPagination<IPageAttachment>, unknown>> {
|
|
||||||
return useInfiniteQuery({
|
|
||||||
queryKey: ["page-attachments", pageId, search],
|
|
||||||
queryFn: ({ pageParam }) =>
|
|
||||||
getPageAttachments(pageId, { cursor: pageParam, query: search }),
|
|
||||||
enabled: !!pageId,
|
|
||||||
gcTime: 0,
|
|
||||||
placeholderData: keepPreviousData,
|
|
||||||
initialPageParam: undefined,
|
|
||||||
getNextPageParam: (lastPage) => lastPage.meta?.nextCursor ?? undefined,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -3,17 +3,7 @@ import loadImage from "blueimp-load-image";
|
|||||||
import {
|
import {
|
||||||
AvatarIconType,
|
AvatarIconType,
|
||||||
IAttachment,
|
IAttachment,
|
||||||
IPageAttachment,
|
|
||||||
} from "@/features/attachments/types/attachment.types.ts";
|
} from "@/features/attachments/types/attachment.types.ts";
|
||||||
import { IPagination, QueryParams } from "@/lib/types.ts";
|
|
||||||
|
|
||||||
export async function getPageAttachments(
|
|
||||||
pageId: string,
|
|
||||||
params?: QueryParams,
|
|
||||||
): Promise<IPagination<IPageAttachment>> {
|
|
||||||
const req = await api.post("/pages/attachments", { pageId, ...params });
|
|
||||||
return req.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function compressAndResizeIcon(
|
async function compressAndResizeIcon(
|
||||||
file: File,
|
file: File,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
export {
|
export {
|
||||||
getPageAttachments,
|
|
||||||
uploadIcon,
|
uploadIcon,
|
||||||
uploadUserAvatar,
|
uploadUserAvatar,
|
||||||
uploadSpaceIcon,
|
uploadSpaceIcon,
|
||||||
|
|||||||
@@ -15,15 +15,6 @@ export interface IAttachment {
|
|||||||
deletedAt: string | null;
|
deletedAt: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPageAttachment extends IAttachment {
|
|
||||||
url: string;
|
|
||||||
creator: {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
avatarUrl: string | null;
|
|
||||||
} | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum AvatarIconType {
|
export enum AvatarIconType {
|
||||||
AVATAR = "avatar",
|
AVATAR = "avatar",
|
||||||
SPACE_ICON = "space-icon",
|
SPACE_ICON = "space-icon",
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ const CommentEditor = forwardRef(
|
|||||||
},
|
},
|
||||||
content: defaultContent,
|
content: defaultContent,
|
||||||
editable,
|
editable,
|
||||||
textDirection: "auto",
|
|
||||||
immediatelyRender: true,
|
immediatelyRender: true,
|
||||||
shouldRerenderOnTransaction: false,
|
shouldRerenderOnTransaction: false,
|
||||||
autofocus: (autofocus && "end") || false,
|
autofocus: (autofocus && "end") || false,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import {
|
|||||||
IconMathFunction,
|
IconMathFunction,
|
||||||
IconRotate2,
|
IconRotate2,
|
||||||
IconSitemap,
|
IconSitemap,
|
||||||
IconSuperscript,
|
|
||||||
IconTable,
|
IconTable,
|
||||||
IconTag,
|
IconTag,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
@@ -271,12 +270,6 @@ export const MoreInsertsGroup: FC<Props> = ({ editor, templateMode }) => {
|
|||||||
>
|
>
|
||||||
{t("Math block")}
|
{t("Math block")}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item
|
|
||||||
leftSection={<IconSuperscript size={16} />}
|
|
||||||
onClick={() => editor.chain().focus().addFootnote().run()}
|
|
||||||
>
|
|
||||||
{t("Footnote")}
|
|
||||||
</Menu.Item>
|
|
||||||
</Menu.Dropdown>
|
</Menu.Dropdown>
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import {
|
|||||||
IconTag,
|
IconTag,
|
||||||
IconMoodSmile,
|
IconMoodSmile,
|
||||||
IconRotate2,
|
IconRotate2,
|
||||||
IconSuperscript,
|
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import {
|
import {
|
||||||
CommandProps,
|
CommandProps,
|
||||||
@@ -178,16 +177,6 @@ const CommandGroups: SlashMenuGroupedItemsType = {
|
|||||||
command: ({ editor, range }: CommandProps) =>
|
command: ({ editor, range }: CommandProps) =>
|
||||||
editor.chain().focus().deleteRange(range).setPageBreak().run(),
|
editor.chain().focus().deleteRange(range).setPageBreak().run(),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: "Footnote",
|
|
||||||
description: "Insert a footnote reference.",
|
|
||||||
searchTerms: ["footnote", "reference", "citation", "note"],
|
|
||||||
icon: IconSuperscript,
|
|
||||||
command: ({ editor, range }: CommandProps) => {
|
|
||||||
editor.chain().focus().deleteRange(range).run();
|
|
||||||
editor.commands.addFootnote();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: "Image",
|
title: "Image",
|
||||||
description: "Upload any image from your device.",
|
description: "Upload any image from your device.",
|
||||||
@@ -400,6 +389,14 @@ const CommandGroups: SlashMenuGroupedItemsType = {
|
|||||||
command: ({ editor, range }: CommandProps) =>
|
command: ({ editor, range }: CommandProps) =>
|
||||||
editor.chain().focus().deleteRange(range).setDetails().run(),
|
editor.chain().focus().deleteRange(range).setDetails().run(),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Tabs",
|
||||||
|
description: "Insert a multi-tab content block.",
|
||||||
|
searchTerms: ["tabs", "tabbed", "multi", "panel"],
|
||||||
|
icon: IconSitemap,
|
||||||
|
command: ({ editor, range }: CommandProps) =>
|
||||||
|
editor.chain().focus().deleteRange(range).insertTabs().run(),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Callout",
|
title: "Callout",
|
||||||
description: "Insert callout notice.",
|
description: "Insert callout notice.",
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
import { BubbleMenu } from "@tiptap/react/menus";
|
||||||
|
import React, { useCallback } from "react";
|
||||||
|
import { EditorMenuProps, ShouldShowProps } from "../table/types/types";
|
||||||
|
import { isEditorReady, isTextSelected } from "@docmost/editor-ext";
|
||||||
|
import { Node as PMNode } from "@tiptap/pm/model";
|
||||||
|
import { findParentNode, posToDOMRect } from "@tiptap/core";
|
||||||
|
import classes from "../common/toolbar-menu.module.css";
|
||||||
|
import { ActionIcon, Tooltip } from "@mantine/core";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import {
|
||||||
|
IconChevronLeft,
|
||||||
|
IconChevronRight,
|
||||||
|
IconColumnInsertLeft,
|
||||||
|
IconColumnInsertRight,
|
||||||
|
IconColumnRemove,
|
||||||
|
IconTrashX,
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
|
||||||
|
const TabsMenu = React.memo(({ editor }: EditorMenuProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const shouldShow = useCallback(
|
||||||
|
({ state }: ShouldShowProps) => {
|
||||||
|
if (!state) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isTextSelected(editor)) return false;
|
||||||
|
|
||||||
|
return editor.isActive("tabs");
|
||||||
|
},
|
||||||
|
[editor]
|
||||||
|
);
|
||||||
|
|
||||||
|
const getReferencedVirtualElement = useCallback(() => {
|
||||||
|
if (!isEditorReady(editor)) return;
|
||||||
|
const { selection } = editor.state;
|
||||||
|
const predicate = (node: PMNode) => node.type.name === "tabs";
|
||||||
|
const parent = findParentNode(predicate)(selection);
|
||||||
|
|
||||||
|
if (parent) {
|
||||||
|
const dom = editor.view.nodeDOM(parent?.pos) as HTMLElement;
|
||||||
|
const domRect = dom.getBoundingClientRect();
|
||||||
|
return {
|
||||||
|
getBoundingClientRect: () => domRect,
|
||||||
|
getClientRects: () => [domRect],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const domRect = posToDOMRect(editor.view, selection.from, selection.to);
|
||||||
|
return {
|
||||||
|
getBoundingClientRect: () => domRect,
|
||||||
|
getClientRects: () => [domRect],
|
||||||
|
};
|
||||||
|
}, [editor]);
|
||||||
|
|
||||||
|
const handleAddTabLeft = useCallback(() => {
|
||||||
|
editor.chain().focus().insertTab("left").run();
|
||||||
|
}, [editor]);
|
||||||
|
|
||||||
|
const handleAddTabRight = useCallback(() => {
|
||||||
|
editor.chain().focus().insertTab("right").run();
|
||||||
|
}, [editor]);
|
||||||
|
|
||||||
|
const handleMoveTabRight = useCallback(() => {
|
||||||
|
editor.chain().focus().moveTab("right").run();
|
||||||
|
}, [editor]);
|
||||||
|
|
||||||
|
const handleMoveTabLeft = useCallback(() => {
|
||||||
|
editor.chain().focus().moveTab("left").run();
|
||||||
|
}, [editor]);
|
||||||
|
|
||||||
|
const handleDeleteTab = useCallback(() => {
|
||||||
|
editor.chain().focus().deleteTab().run();
|
||||||
|
}, [editor]);
|
||||||
|
|
||||||
|
const handleDelete = useCallback(() => {
|
||||||
|
editor.chain().focus().deleteTabs().run();
|
||||||
|
}, [editor]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BubbleMenu
|
||||||
|
style={{ zIndex: 99 }}
|
||||||
|
editor={editor}
|
||||||
|
pluginKey="tabs-menu"
|
||||||
|
resizeDelay={0}
|
||||||
|
getReferencedVirtualElement={getReferencedVirtualElement}
|
||||||
|
shouldShow={shouldShow}
|
||||||
|
options={{
|
||||||
|
placement: "top",
|
||||||
|
offset: false,
|
||||||
|
flip: false,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className={classes.toolbar}>
|
||||||
|
<Tooltip position="top" label={t("Add left tab")} withinPortal={false}>
|
||||||
|
<ActionIcon
|
||||||
|
onClick={handleAddTabLeft}
|
||||||
|
variant="subtle"
|
||||||
|
size="lg"
|
||||||
|
aria-label={t("Add left tab")}
|
||||||
|
>
|
||||||
|
<IconColumnInsertLeft size={18} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip position="top" label={t("Add right tab")} withinPortal={false}>
|
||||||
|
<ActionIcon
|
||||||
|
onClick={handleAddTabRight}
|
||||||
|
variant="subtle"
|
||||||
|
size="lg"
|
||||||
|
aria-label={t("Add right tab")}
|
||||||
|
>
|
||||||
|
<IconColumnInsertRight size={18} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip position="top" label={t("Delete tab")} withinPortal={false}>
|
||||||
|
<ActionIcon
|
||||||
|
onClick={handleDeleteTab}
|
||||||
|
variant="subtle"
|
||||||
|
size="lg"
|
||||||
|
aria-label={t("Delete tab")}
|
||||||
|
>
|
||||||
|
<IconColumnRemove size={18} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<div className={classes.divider} />
|
||||||
|
|
||||||
|
<Tooltip position="top" label={t("Move tab left")} withinPortal={false}>
|
||||||
|
<ActionIcon
|
||||||
|
onClick={handleMoveTabLeft}
|
||||||
|
variant="subtle"
|
||||||
|
size="lg"
|
||||||
|
aria-label={t("Move tab left")}
|
||||||
|
>
|
||||||
|
<IconChevronLeft size={18} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Tooltip position="top" label={t("Move tab right")} withinPortal={false}>
|
||||||
|
<ActionIcon
|
||||||
|
onClick={handleMoveTabRight}
|
||||||
|
variant="subtle"
|
||||||
|
size="lg"
|
||||||
|
aria-label={t("Move tab right")}
|
||||||
|
>
|
||||||
|
<IconChevronRight size={18} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
<div className={classes.divider} />
|
||||||
|
|
||||||
|
<Tooltip position="top" label={t("Delete")} withinPortal={false}>
|
||||||
|
<ActionIcon
|
||||||
|
onClick={handleDelete}
|
||||||
|
variant="subtle"
|
||||||
|
size="lg"
|
||||||
|
aria-label={t("Delete")}
|
||||||
|
>
|
||||||
|
<IconTrashX size={18} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</BubbleMenu>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export default TabsMenu;
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
import React, {
|
||||||
|
ChangeEvent,
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
type KeyboardEvent,
|
||||||
|
} from "react";
|
||||||
|
import { NodeViewContent, NodeViewWrapper, type NodeViewProps } from "@tiptap/react";
|
||||||
|
import { Tabs, TextInput } from "@mantine/core";
|
||||||
|
|
||||||
|
export default function TabsView(props: NodeViewProps) {
|
||||||
|
const { node, editor, getPos } = props;
|
||||||
|
const isEditable = editor.isEditable;
|
||||||
|
const allowFocusRef = useRef(false);
|
||||||
|
|
||||||
|
const tabs = useMemo(() => {
|
||||||
|
return Array.from({ length: node.childCount }, (_, index) => {
|
||||||
|
const labelNode = node.child(index)?.child(0);
|
||||||
|
const labelText = labelNode?.textContent;
|
||||||
|
const labelId = node.child(index)?.attrs?.id;
|
||||||
|
|
||||||
|
return {
|
||||||
|
label: labelText ?? "",
|
||||||
|
id: labelId ?? index,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}, [node]);
|
||||||
|
|
||||||
|
const activeTab = clampIndex(node.attrs.activeTab);
|
||||||
|
const [activeLabel, setActiveLabel] = useState(tabs[activeTab].label ?? "");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setActiveLabel(tabs[activeTab].label);
|
||||||
|
}, [activeTab, tabs]);
|
||||||
|
|
||||||
|
const handleMouseDown = useCallback((event: React.MouseEvent) => {
|
||||||
|
const previous = document.activeElement as HTMLElement | null;
|
||||||
|
const input = event.currentTarget;
|
||||||
|
|
||||||
|
if (!previous?.contains(input)) {
|
||||||
|
allowFocusRef.current = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
allowFocusRef.current = true;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleFocus = useCallback(
|
||||||
|
(event: React.FocusEvent<HTMLInputElement>) => {
|
||||||
|
if (!allowFocusRef.current || !isEditable) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.target.blur();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[isEditable]
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleBlur = useCallback(() => {
|
||||||
|
allowFocusRef.current = false;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const commitLabel = useCallback(
|
||||||
|
(event: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const label = event.currentTarget.value;
|
||||||
|
setActiveLabel(label);
|
||||||
|
|
||||||
|
if (label === tabs[activeTab].label) return;
|
||||||
|
if (typeof getPos === "function") {
|
||||||
|
editor.commands.updateTabLabel?.(activeTab, label, getPos());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[activeTab, editor, getPos, tabs]
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleLabelKeyDown = useCallback(
|
||||||
|
(event: KeyboardEvent<HTMLInputElement>) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
event.preventDefault();
|
||||||
|
event.currentTarget.blur();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<NodeViewWrapper data-type="tabs">
|
||||||
|
<Tabs value={String(activeTab)}>
|
||||||
|
<Tabs.List style={{ marginBottom: 10 }}>
|
||||||
|
{tabs.map(({ label, id }, index) => (
|
||||||
|
<Tabs.Tab
|
||||||
|
key={id}
|
||||||
|
value={index.toString()}
|
||||||
|
onFocus={(event) => event.currentTarget.blur()}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (typeof getPos === "function") {
|
||||||
|
editor.commands.setActiveTab?.(index, getPos());
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextInput
|
||||||
|
aria-label="Edit tab label"
|
||||||
|
onMouseDown={handleMouseDown}
|
||||||
|
onFocus={handleFocus}
|
||||||
|
onBlur={handleBlur}
|
||||||
|
onChange={commitLabel}
|
||||||
|
onKeyDown={handleLabelKeyDown}
|
||||||
|
variant="unstyled"
|
||||||
|
size="xs"
|
||||||
|
value={
|
||||||
|
index === activeTab && allowFocusRef.current ? activeLabel : label
|
||||||
|
}
|
||||||
|
styles={{
|
||||||
|
input: {
|
||||||
|
minWidth: 80,
|
||||||
|
padding: 0,
|
||||||
|
cursor: "pointer",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Tabs.Tab>
|
||||||
|
))}
|
||||||
|
</Tabs.List>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
<div className="dm-tabs__content">
|
||||||
|
<NodeViewContent as="div" />
|
||||||
|
</div>
|
||||||
|
</NodeViewWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const clampIndex = (value: unknown, length = Number.MAX_SAFE_INTEGER) => {
|
||||||
|
const parsed = Number(value ?? 0);
|
||||||
|
if (!Number.isFinite(parsed) || length <= 0) return 0;
|
||||||
|
return Math.max(0, Math.min(Math.trunc(parsed), length - 1));
|
||||||
|
};
|
||||||
@@ -40,7 +40,6 @@ export default function TransclusionContent({ content }: Props) {
|
|||||||
<EditorProvider
|
<EditorProvider
|
||||||
editable={false}
|
editable={false}
|
||||||
immediatelyRender={true}
|
immediatelyRender={true}
|
||||||
textDirection="auto"
|
|
||||||
extensions={extensions}
|
extensions={extensions}
|
||||||
content={content as any}
|
content={content as any}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ import {
|
|||||||
PluginKey,
|
PluginKey,
|
||||||
TextSelection,
|
TextSelection,
|
||||||
} from "@tiptap/pm/state";
|
} from "@tiptap/pm/state";
|
||||||
import { Fragment, Slice, Node } from "@tiptap/pm/model";
|
import { Fragment, Slice } from "@tiptap/pm/model";
|
||||||
import { EditorView } from "@tiptap/pm/view";
|
import type { Node, ResolvedPos } from "@tiptap/pm/model";
|
||||||
|
import type { EditorView } from "@tiptap/pm/view";
|
||||||
|
|
||||||
export interface GlobalDragHandleOptions {
|
export interface GlobalDragHandleOptions {
|
||||||
/**
|
/**
|
||||||
@@ -150,9 +151,126 @@ function isCustomNodeDOM(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDirectTarget($pos: ResolvedPos, ancestorDepth: number) {
|
||||||
|
const ancestor = $pos.node(ancestorDepth);
|
||||||
|
|
||||||
|
if (ancestor.childCount === 0) return null;
|
||||||
|
|
||||||
|
if ($pos.depth > ancestorDepth) {
|
||||||
|
const childDepth = ancestorDepth + 1;
|
||||||
|
return {
|
||||||
|
pos: $pos.before(childDepth),
|
||||||
|
node: $pos.node(childDepth),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const index = $pos.index(ancestorDepth);
|
||||||
|
const childIndex = Math.min(index, ancestor.childCount - 1);
|
||||||
|
if (childIndex < 0) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
pos: $pos.posAtIndex(childIndex, ancestorDepth),
|
||||||
|
node: ancestor.child(childIndex),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
type DragSource = { from: number; to: number; node: Node };
|
||||||
|
|
||||||
|
function dragSourceFromDOM(view: EditorView, dom: Element): DragSource | null {
|
||||||
|
let pos: number;
|
||||||
|
try {
|
||||||
|
pos = view.posAtDOM(dom, 0);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const $pos = view.state.doc.resolve(pos);
|
||||||
|
if ($pos.depth === 0) return null;
|
||||||
|
|
||||||
|
const from = $pos.before($pos.depth);
|
||||||
|
const node = $pos.node($pos.depth);
|
||||||
|
return { from, to: from + node.nodeSize, node };
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveMoveSource(
|
||||||
|
view: EditorView,
|
||||||
|
hint: DragSource | null,
|
||||||
|
): DragSource | null {
|
||||||
|
const { state } = view;
|
||||||
|
|
||||||
|
if (hint) {
|
||||||
|
const current = state.doc.nodeAt(hint.from);
|
||||||
|
if (current?.eq(hint.node)) return hint;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.selection instanceof NodeSelection) {
|
||||||
|
return {
|
||||||
|
from: state.selection.from,
|
||||||
|
to: state.selection.from + state.selection.node.nodeSize,
|
||||||
|
node: state.selection.node,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveNodeWithinTabPanel(
|
||||||
|
view: EditorView,
|
||||||
|
dropPos: number,
|
||||||
|
source: DragSource,
|
||||||
|
): boolean {
|
||||||
|
const { state } = view;
|
||||||
|
const { from: sourceFrom, to: sourceTo, node: sourceNode } = source;
|
||||||
|
|
||||||
|
const $drop = state.doc.resolve(dropPos);
|
||||||
|
const panelDepth = view.state.doc.resolve(dropPos).depth
|
||||||
|
if (panelDepth < 0) return false;
|
||||||
|
|
||||||
|
if (dropPos > sourceFrom && dropPos < sourceTo) return false;
|
||||||
|
|
||||||
|
let insertPos: number;
|
||||||
|
const target = getDirectTarget($drop, panelDepth);
|
||||||
|
if (!target) {
|
||||||
|
insertPos = $drop.start(panelDepth);
|
||||||
|
} else {
|
||||||
|
const targetStart = target.pos;
|
||||||
|
const targetEnd = targetStart + target.node.nodeSize;
|
||||||
|
const midpoint = (targetStart + targetEnd) / 2;
|
||||||
|
insertPos = dropPos >= midpoint ? targetEnd : targetStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Already in place.
|
||||||
|
if (insertPos === sourceFrom || insertPos === sourceTo) return false;
|
||||||
|
|
||||||
|
const tr = state.tr;
|
||||||
|
tr.delete(sourceFrom, sourceTo);
|
||||||
|
|
||||||
|
const insertAt = tr.mapping.map(insertPos, -1);
|
||||||
|
const $insert = tr.doc.resolve(insertAt);
|
||||||
|
const index = $insert.index();
|
||||||
|
|
||||||
|
if (!$insert.parent.canReplace(index, index, Fragment.from(sourceNode))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.insert(insertAt, sourceNode);
|
||||||
|
|
||||||
|
const $placed = tr.doc.resolve(
|
||||||
|
Math.min(insertAt, tr.doc.content.size),
|
||||||
|
);
|
||||||
|
tr.setSelection(NodeSelection.near($placed));
|
||||||
|
tr.scrollIntoView();
|
||||||
|
|
||||||
|
view.dispatch(tr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NON_PROMOTABLE_PARENTS = new Set(["tabs", "tab", "tabPanel"]);
|
||||||
|
|
||||||
function calcNodePos(pos: number, view: EditorView) {
|
function calcNodePos(pos: number, view: EditorView) {
|
||||||
const $pos = view.state.doc.resolve(pos);
|
const $pos = view.state.doc.resolve(pos);
|
||||||
if ($pos.depth > 1) return $pos.before($pos.depth);
|
if ($pos.depth > 1 && !NON_PROMOTABLE_PARENTS.has($pos.node($pos.depth).type.name))
|
||||||
|
return $pos.before($pos.depth);
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +278,8 @@ export function DragHandlePlugin(
|
|||||||
options: GlobalDragHandleOptions & { pluginKey: string },
|
options: GlobalDragHandleOptions & { pluginKey: string },
|
||||||
) {
|
) {
|
||||||
let listType = "";
|
let listType = "";
|
||||||
|
let dragSource: DragSource | null = null;
|
||||||
|
|
||||||
function handleDragStart(event: DragEvent, view: EditorView) {
|
function handleDragStart(event: DragEvent, view: EditorView) {
|
||||||
view.focus();
|
view.focus();
|
||||||
|
|
||||||
@@ -176,6 +296,8 @@ export function DragHandlePlugin(
|
|||||||
|
|
||||||
if (!(node instanceof Element)) return;
|
if (!(node instanceof Element)) return;
|
||||||
|
|
||||||
|
dragSource = dragSourceFromDOM(view, node);
|
||||||
|
|
||||||
let draggedNodePos = nodePosAtDOM(node, view, options);
|
let draggedNodePos = nodePosAtDOM(node, view, options);
|
||||||
if (draggedNodePos == null || draggedNodePos < 0) return;
|
if (draggedNodePos == null || draggedNodePos < 0) return;
|
||||||
draggedNodePos = calcNodePos(draggedNodePos, view);
|
draggedNodePos = calcNodePos(draggedNodePos, view);
|
||||||
@@ -401,6 +523,7 @@ export function DragHandlePlugin(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const notDragging = node?.closest(".not-draggable");
|
const notDragging = node?.closest(".not-draggable");
|
||||||
|
const notDraggingMatch = node?.matches(".not-draggable-match")
|
||||||
const excludedTagList = options.excludedTags
|
const excludedTagList = options.excludedTags
|
||||||
.concat(["ol", "ul"])
|
.concat(["ol", "ul"])
|
||||||
.join(", ");
|
.join(", ");
|
||||||
@@ -408,7 +531,8 @@ export function DragHandlePlugin(
|
|||||||
if (
|
if (
|
||||||
!(node instanceof Element) ||
|
!(node instanceof Element) ||
|
||||||
node.matches(excludedTagList) ||
|
node.matches(excludedTagList) ||
|
||||||
notDragging
|
notDragging ||
|
||||||
|
notDraggingMatch
|
||||||
) {
|
) {
|
||||||
hideDragHandle();
|
hideDragHandle();
|
||||||
return;
|
return;
|
||||||
@@ -496,6 +620,22 @@ export function DragHandlePlugin(
|
|||||||
const isDroppedInsideList =
|
const isDroppedInsideList =
|
||||||
resolvedPos.parent.type.name === "listItem";
|
resolvedPos.parent.type.name === "listItem";
|
||||||
|
|
||||||
|
const isDroppedInsideTabPanel =
|
||||||
|
resolvedPos.parent.type.name === "tabPanel";
|
||||||
|
|
||||||
|
if (isDroppedInsideTabPanel) {
|
||||||
|
const source = resolveMoveSource(view, dragSource);
|
||||||
|
const moved = source
|
||||||
|
? moveNodeWithinTabPanel(view, dropPos.pos, source)
|
||||||
|
: false;
|
||||||
|
|
||||||
|
// even when not moved swallow the drop so ProseMirror doesn't insert a copy.
|
||||||
|
event.preventDefault();
|
||||||
|
view.dragging = null;
|
||||||
|
dragSource = null;
|
||||||
|
return moved;
|
||||||
|
}
|
||||||
|
|
||||||
// If the selected node is a list item and is not dropped inside a list, we need to wrap it inside <ol> tag otherwise ol list items will be transformed into ul list item when dropped
|
// If the selected node is a list item and is not dropped inside a list, we need to wrap it inside <ol> tag otherwise ol list items will be transformed into ul list item when dropped
|
||||||
if (
|
if (
|
||||||
view.state.selection instanceof NodeSelection &&
|
view.state.selection instanceof NodeSelection &&
|
||||||
@@ -513,6 +653,7 @@ export function DragHandlePlugin(
|
|||||||
},
|
},
|
||||||
dragend: (view) => {
|
dragend: (view) => {
|
||||||
view.dom.classList.remove("dragging");
|
view.dom.classList.remove("dragging");
|
||||||
|
dragSource = null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -526,6 +667,7 @@ const GlobalDragHandle = Extension.create({
|
|||||||
return {
|
return {
|
||||||
dragHandleWidth: 20,
|
dragHandleWidth: 20,
|
||||||
scrollThreshold: 100,
|
scrollThreshold: 100,
|
||||||
|
dragHandleSelector: undefined,
|
||||||
excludedTags: [],
|
excludedTags: [],
|
||||||
customNodes: [],
|
customNodes: [],
|
||||||
atomNodes: [],
|
atomNodes: [],
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import { markInputRule } from "@tiptap/core";
|
import { markInputRule } from "@tiptap/core";
|
||||||
import { StarterKit } from "@tiptap/starter-kit";
|
import { StarterKit } from "@tiptap/starter-kit";
|
||||||
import { Document } from "@tiptap/extension-document";
|
|
||||||
import { Code } from "@tiptap/extension-code";
|
import { Code } from "@tiptap/extension-code";
|
||||||
import { TextAlign } from "@tiptap/extension-text-align";
|
import { TextAlign } from "@tiptap/extension-text-align";
|
||||||
import { TaskList, TaskItem } from "@tiptap/extension-list";
|
import { TaskList, TaskItem } from "@tiptap/extension-list";
|
||||||
import { CharacterCount, UndoRedo } from "@tiptap/extensions";
|
import { Placeholder, CharacterCount, UndoRedo } from "@tiptap/extensions";
|
||||||
import { Placeholder } from "@/features/editor/extensions/placeholder";
|
|
||||||
import { Superscript } from "@tiptap/extension-superscript";
|
import { Superscript } from "@tiptap/extension-superscript";
|
||||||
import SubScript from "@tiptap/extension-subscript";
|
import SubScript from "@tiptap/extension-subscript";
|
||||||
import { Typography } from "@tiptap/extension-typography";
|
import { Typography } from "@tiptap/extension-typography";
|
||||||
@@ -64,9 +62,10 @@ import {
|
|||||||
TransclusionReference,
|
TransclusionReference,
|
||||||
TableView,
|
TableView,
|
||||||
BaseEmbed as BaseEmbedNode,
|
BaseEmbed as BaseEmbedNode,
|
||||||
Footnotes,
|
Tabs,
|
||||||
Footnote,
|
Tab,
|
||||||
FootnoteReference,
|
TabLabel,
|
||||||
|
TabPanel,
|
||||||
} from "@docmost/editor-ext";
|
} from "@docmost/editor-ext";
|
||||||
import {
|
import {
|
||||||
randomElement,
|
randomElement,
|
||||||
@@ -95,6 +94,7 @@ import ExcalidrawView from "@/features/editor/components/excalidraw/excalidraw-v
|
|||||||
import EmbedView from "@/features/editor/components/embed/embed-view.tsx";
|
import EmbedView from "@/features/editor/components/embed/embed-view.tsx";
|
||||||
import PdfView from "@/features/editor/components/pdf/pdf-view.tsx";
|
import PdfView from "@/features/editor/components/pdf/pdf-view.tsx";
|
||||||
import SubpagesView from "@/features/editor/components/subpages/subpages-view.tsx";
|
import SubpagesView from "@/features/editor/components/subpages/subpages-view.tsx";
|
||||||
|
import TabsView from "@/features/editor/components/tabs/tabs-view.tsx";
|
||||||
import TransclusionView from "@/features/editor/components/transclusion/transclusion-view.tsx";
|
import TransclusionView from "@/features/editor/components/transclusion/transclusion-view.tsx";
|
||||||
import TransclusionReferenceView from "@/features/editor/components/transclusion/transclusion-reference-view.tsx";
|
import TransclusionReferenceView from "@/features/editor/components/transclusion/transclusion-reference-view.tsx";
|
||||||
import { BaseEmbedView } from "@/features/editor/components/base-embed/base-embed-view.tsx";
|
import { BaseEmbedView } from "@/features/editor/components/base-embed/base-embed-view.tsx";
|
||||||
@@ -136,7 +136,6 @@ lowlight.register("scala", scala);
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export const mainExtensions = [
|
export const mainExtensions = [
|
||||||
StarterKit.configure({
|
StarterKit.configure({
|
||||||
document: false,
|
|
||||||
heading: false,
|
heading: false,
|
||||||
undoRedo: false,
|
undoRedo: false,
|
||||||
link: false,
|
link: false,
|
||||||
@@ -148,9 +147,6 @@ export const mainExtensions = [
|
|||||||
codeBlock: false,
|
codeBlock: false,
|
||||||
code: false,
|
code: false,
|
||||||
}),
|
}),
|
||||||
Document.extend({
|
|
||||||
content: "block+ footnotes?",
|
|
||||||
}),
|
|
||||||
// Override TipTap's Code extension to fix the inline code input rule.
|
// Override TipTap's Code extension to fix the inline code input rule.
|
||||||
// The upstream regex /(^|[^`])`([^`]+)`(?!`)$/ captures the character
|
// The upstream regex /(^|[^`])`([^`]+)`(?!`)$/ captures the character
|
||||||
// before the opening backtick as part of the match, causing markInputRule
|
// before the opening backtick as part of the match, causing markInputRule
|
||||||
@@ -211,8 +207,7 @@ export const mainExtensions = [
|
|||||||
parentName === "tableCell" ||
|
parentName === "tableCell" ||
|
||||||
parentName === "tableHeader" ||
|
parentName === "tableHeader" ||
|
||||||
parentName === "callout" ||
|
parentName === "callout" ||
|
||||||
parentName === "blockquote" ||
|
parentName === "blockquote"
|
||||||
parentName === "footnote"
|
|
||||||
) {
|
) {
|
||||||
return i18n.t("Write...");
|
return i18n.t("Write...");
|
||||||
}
|
}
|
||||||
@@ -244,7 +239,7 @@ export const mainExtensions = [
|
|||||||
Typography,
|
Typography,
|
||||||
TrailingNode,
|
TrailingNode,
|
||||||
GlobalDragHandle.configure({
|
GlobalDragHandle.configure({
|
||||||
customNodes: ["transclusionSource", "transclusionReference"],
|
customNodes: ["transclusionSource", "transclusionReference", "tabPanel"],
|
||||||
atomNodes: ["base"],
|
atomNodes: ["base"],
|
||||||
}),
|
}),
|
||||||
TextStyle,
|
TextStyle,
|
||||||
@@ -299,6 +294,12 @@ export const mainExtensions = [
|
|||||||
Details,
|
Details,
|
||||||
DetailsSummary,
|
DetailsSummary,
|
||||||
DetailsContent,
|
DetailsContent,
|
||||||
|
Tabs.configure({
|
||||||
|
view: TabsView,
|
||||||
|
}),
|
||||||
|
Tab,
|
||||||
|
TabLabel,
|
||||||
|
TabPanel,
|
||||||
Youtube.configure({
|
Youtube.configure({
|
||||||
addPasteHandler: false,
|
addPasteHandler: false,
|
||||||
controls: true,
|
controls: true,
|
||||||
@@ -426,9 +427,6 @@ export const mainExtensions = [
|
|||||||
}).configure(),
|
}).configure(),
|
||||||
Columns,
|
Columns,
|
||||||
Column,
|
Column,
|
||||||
Footnotes,
|
|
||||||
Footnote,
|
|
||||||
FootnoteReference,
|
|
||||||
AutoJoiner.configure({
|
AutoJoiner.configure({
|
||||||
elementsToJoin: [],
|
elementsToJoin: [],
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
import { isNodeEmpty } from "@tiptap/core";
|
|
||||||
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
||||||
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
||||||
import { Placeholder as TiptapPlaceholder } from "@tiptap/extensions";
|
|
||||||
|
|
||||||
export const Placeholder = TiptapPlaceholder.extend({
|
|
||||||
addProseMirrorPlugins() {
|
|
||||||
const editor = this.editor;
|
|
||||||
const options = this.options;
|
|
||||||
const dataAttribute = `data-${options.dataAttribute || "placeholder"}`;
|
|
||||||
|
|
||||||
return [
|
|
||||||
new Plugin({
|
|
||||||
key: new PluginKey("docmostPlaceholder"),
|
|
||||||
props: {
|
|
||||||
decorations: (state) => {
|
|
||||||
if (options.showOnlyWhenEditable && !editor.isEditable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { doc, selection } = state;
|
|
||||||
const { anchor } = selection;
|
|
||||||
const decorations: Decoration[] = [];
|
|
||||||
const isEmptyDoc = editor.isEmpty;
|
|
||||||
|
|
||||||
doc.descendants((node, pos) => {
|
|
||||||
if (!node.type.isTextblock) {
|
|
||||||
return options.includeChildren;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
|
|
||||||
const isEmpty = !node.isLeaf && isNodeEmpty(node);
|
|
||||||
|
|
||||||
if ((hasAnchor || !options.showOnlyCurrent) && isEmpty) {
|
|
||||||
const emptyNodeClass =
|
|
||||||
typeof options.emptyNodeClass === "function"
|
|
||||||
? options.emptyNodeClass({ editor, node, pos, hasAnchor })
|
|
||||||
: options.emptyNodeClass;
|
|
||||||
const classes = [emptyNodeClass];
|
|
||||||
if (isEmptyDoc) {
|
|
||||||
classes.push(options.emptyEditorClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
decorations.push(
|
|
||||||
Decoration.node(pos, pos + node.nodeSize, {
|
|
||||||
class: classes.join(" "),
|
|
||||||
[dataAttribute]:
|
|
||||||
typeof options.placeholder === "function"
|
|
||||||
? options.placeholder({ editor, node, pos, hasAnchor })
|
|
||||||
: options.placeholder,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return options.includeChildren;
|
|
||||||
});
|
|
||||||
|
|
||||||
return DecorationSet.create(doc, decorations);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -82,6 +82,7 @@ import {
|
|||||||
getCollabSocket,
|
getCollabSocket,
|
||||||
releaseCollabSocket,
|
releaseCollabSocket,
|
||||||
} from "@/features/editor/collab-socket";
|
} from "@/features/editor/collab-socket";
|
||||||
|
import TabsMenu from "./components/tabs/tabs-menu";
|
||||||
|
|
||||||
interface PageEditorProps {
|
interface PageEditorProps {
|
||||||
pageId: string;
|
pageId: string;
|
||||||
@@ -249,7 +250,6 @@ function CollabPageEditor({
|
|||||||
{
|
{
|
||||||
extensions,
|
extensions,
|
||||||
editable,
|
editable,
|
||||||
textDirection: "auto",
|
|
||||||
immediatelyRender: true,
|
immediatelyRender: true,
|
||||||
shouldRerenderOnTransaction: false,
|
shouldRerenderOnTransaction: false,
|
||||||
editorProps: {
|
editorProps: {
|
||||||
@@ -454,6 +454,7 @@ function CollabPageEditor({
|
|||||||
<ExcalidrawMenu editor={editor} />
|
<ExcalidrawMenu editor={editor} />
|
||||||
<DrawioMenu editor={editor} />
|
<DrawioMenu editor={editor} />
|
||||||
<ColumnsMenu editor={editor} />
|
<ColumnsMenu editor={editor} />
|
||||||
|
<TabsMenu editor={editor} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{editor && !editorIsEditable && (editable || canComment) && (
|
{editor && !editorIsEditable && (editable || canComment) && (
|
||||||
@@ -485,7 +486,6 @@ function StaticPageEditor({
|
|||||||
<EditorProvider
|
<EditorProvider
|
||||||
editable={false}
|
editable={false}
|
||||||
immediatelyRender={true}
|
immediatelyRender={true}
|
||||||
textDirection="auto"
|
|
||||||
extensions={mainExtensions}
|
extensions={mainExtensions}
|
||||||
content={content}
|
content={content}
|
||||||
editorProps={{
|
editorProps={{
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ export default function ReadonlyPageEditor({
|
|||||||
<EditorProvider
|
<EditorProvider
|
||||||
editable={false}
|
editable={false}
|
||||||
immediatelyRender={true}
|
immediatelyRender={true}
|
||||||
textDirection="auto"
|
|
||||||
extensions={titleExtensions}
|
extensions={titleExtensions}
|
||||||
content={title}
|
content={title}
|
||||||
></EditorProvider>
|
></EditorProvider>
|
||||||
@@ -94,7 +93,6 @@ export default function ReadonlyPageEditor({
|
|||||||
<EditorProvider
|
<EditorProvider
|
||||||
editable={false}
|
editable={false}
|
||||||
immediatelyRender={true}
|
immediatelyRender={true}
|
||||||
textDirection="auto"
|
|
||||||
extensions={extensions}
|
extensions={extensions}
|
||||||
content={content}
|
content={content}
|
||||||
onCreate={({ editor }) => {
|
onCreate={({ editor }) => {
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
.ProseMirror sup a.footnote-ref {
|
|
||||||
color: var(--mantine-primary-color-filled);
|
|
||||||
text-decoration: none;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ProseMirror sup:has(a.footnote-ref) {
|
|
||||||
padding: 0 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ProseMirror ol.footnotes {
|
|
||||||
margin-top: 2rem;
|
|
||||||
padding-top: 0.75rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
color: var(--mantine-color-dimmed);
|
|
||||||
list-style-type: decimal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ProseMirror ol.footnotes:has(li) {
|
|
||||||
border-top: 1px solid var(--mantine-color-default-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ProseMirror ol.footnotes li p {
|
|
||||||
margin: 0.15rem 0;
|
|
||||||
}
|
|
||||||
@@ -17,5 +17,5 @@
|
|||||||
@import "./indent.css";
|
@import "./indent.css";
|
||||||
@import "./columns.css";
|
@import "./columns.css";
|
||||||
@import "./status.css";
|
@import "./status.css";
|
||||||
|
@import "./tabs.css";
|
||||||
@import "./base-embed.css";
|
@import "./base-embed.css";
|
||||||
@import "./footnotes.css";
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
var(--mantine-color-dark-5)
|
var(--mantine-color-dark-5)
|
||||||
);
|
);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: start;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.column-resize-handle {
|
.column-resize-handle {
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
.ProseMirror {
|
||||||
|
[data-type="tabs"] {
|
||||||
|
button {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-type="tabLabel"] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-type="tabPanel"] {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -86,7 +86,6 @@ export function TitleEditor({
|
|||||||
},
|
},
|
||||||
editable: editable,
|
editable: editable,
|
||||||
content: title,
|
content: title,
|
||||||
textDirection: "auto",
|
|
||||||
immediatelyRender: true,
|
immediatelyRender: true,
|
||||||
shouldRerenderOnTransaction: false,
|
shouldRerenderOnTransaction: false,
|
||||||
editorProps: {
|
editorProps: {
|
||||||
|
|||||||
@@ -6,13 +6,4 @@ export const activeHistoryPrevIdAtom = atom<string>("");
|
|||||||
export const highlightChangesAtom = atom<boolean>(true);
|
export const highlightChangesAtom = atom<boolean>(true);
|
||||||
|
|
||||||
export type DiffCounts = { added: number; deleted: number; total: number };
|
export type DiffCounts = { added: number; deleted: number; total: number };
|
||||||
export const diffCountsAtom = atom<DiffCounts | null>(
|
export const diffCountsAtom = atom<DiffCounts | null>(null);
|
||||||
null as DiffCounts | null,
|
|
||||||
);
|
|
||||||
|
|
||||||
export type ComparePair = { newerId: string; olderId: string };
|
|
||||||
export const compareModeAtom = atom<boolean>(false);
|
|
||||||
export const compareSelectionAtom = atom<string[]>([]);
|
|
||||||
export const comparePairAtom = atom<ComparePair | null>(
|
|
||||||
null as ComparePair | null,
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.history {
|
.history {
|
||||||
display: flex;
|
display: block;
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
padding: var(--mantine-spacing-md);
|
||||||
color: light-dark(var(--mantine-color-black), var(--mantine-color-dark-0));
|
color: light-dark(var(--mantine-color-black), var(--mantine-color-dark-0));
|
||||||
|
|
||||||
@mixin hover {
|
@mixin hover {
|
||||||
@@ -12,28 +12,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.historyButton {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.compareCheckbox {
|
|
||||||
padding-left: var(--mantine-spacing-xs);
|
|
||||||
}
|
|
||||||
|
|
||||||
.itemMenu {
|
|
||||||
opacity: 0;
|
|
||||||
margin-right: var(--mantine-spacing-xs);
|
|
||||||
}
|
|
||||||
|
|
||||||
.history:hover .itemMenu,
|
|
||||||
.history:focus-within .itemMenu,
|
|
||||||
.history.active .itemMenu,
|
|
||||||
.itemMenu[aria-expanded="true"] {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.historyEditor {
|
.historyEditor {
|
||||||
:global(.ProseMirror) {
|
:global(.ProseMirror) {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
@@ -99,8 +77,3 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
padding: rem(16px) rem(40px);
|
padding: rem(16px) rem(40px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.compareBanner {
|
|
||||||
border-bottom: rem(1px) solid
|
|
||||||
light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ export function HistoryEditor({
|
|||||||
const editor = useEditor({
|
const editor = useEditor({
|
||||||
extensions: mainExtensions,
|
extensions: mainExtensions,
|
||||||
editable: false,
|
editable: false,
|
||||||
textDirection: "auto",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -171,6 +170,7 @@ export function HistoryEditor({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const total = addedCount + deletedCount;
|
const total = addedCount + deletedCount;
|
||||||
|
// @ts-ignore
|
||||||
setDiffCounts({ added: addedCount, deleted: deletedCount, total });
|
setDiffCounts({ added: addedCount, deleted: deletedCount, total });
|
||||||
|
|
||||||
editor.setOptions({
|
editor.setOptions({
|
||||||
|
|||||||
@@ -1,21 +1,10 @@
|
|||||||
import {
|
import { Text, Group, UnstyledButton, Avatar, Tooltip } from "@mantine/core";
|
||||||
Text,
|
|
||||||
Group,
|
|
||||||
UnstyledButton,
|
|
||||||
Avatar,
|
|
||||||
Tooltip,
|
|
||||||
ActionIcon,
|
|
||||||
Checkbox,
|
|
||||||
Menu,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconDots } from "@tabler/icons-react";
|
|
||||||
import { CustomAvatar } from "@/components/ui/custom-avatar.tsx";
|
import { CustomAvatar } from "@/components/ui/custom-avatar.tsx";
|
||||||
import { formattedDate } from "@/lib/time";
|
import { formattedDate } from "@/lib/time";
|
||||||
import classes from "./css/history.module.css";
|
import classes from "./css/history.module.css";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { IPageHistory } from "@/features/page-history/types/page.types";
|
import { IPageHistory } from "@/features/page-history/types/page.types";
|
||||||
import { memo, useCallback } from "react";
|
import { memo, useCallback } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
const MAX_VISIBLE_AVATARS = 5;
|
const MAX_VISIBLE_AVATARS = 5;
|
||||||
|
|
||||||
@@ -26,13 +15,6 @@ interface HistoryItemProps {
|
|||||||
onHover?: (id: string, index: number) => void;
|
onHover?: (id: string, index: number) => void;
|
||||||
onHoverEnd?: () => void;
|
onHoverEnd?: () => void;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
compareMode: boolean;
|
|
||||||
isChecked: boolean;
|
|
||||||
isCheckboxDisabled: boolean;
|
|
||||||
canCompare: boolean;
|
|
||||||
onToggleCompare: (id: string) => void;
|
|
||||||
onStartCompare: (id: string) => void;
|
|
||||||
onRestore?: (id: string, index: number) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const HistoryItem = memo(function HistoryItem({
|
const HistoryItem = memo(function HistoryItem({
|
||||||
@@ -42,24 +24,10 @@ const HistoryItem = memo(function HistoryItem({
|
|||||||
onHover,
|
onHover,
|
||||||
onHoverEnd,
|
onHoverEnd,
|
||||||
isActive,
|
isActive,
|
||||||
compareMode,
|
|
||||||
isChecked,
|
|
||||||
isCheckboxDisabled,
|
|
||||||
canCompare,
|
|
||||||
onToggleCompare,
|
|
||||||
onStartCompare,
|
|
||||||
onRestore,
|
|
||||||
}: HistoryItemProps) {
|
}: HistoryItemProps) {
|
||||||
const { t } = useTranslation();
|
|
||||||
const date = formattedDate(new Date(historyItem.createdAt));
|
|
||||||
|
|
||||||
const handleClick = useCallback(() => {
|
const handleClick = useCallback(() => {
|
||||||
if (compareMode) {
|
onSelect(historyItem.id, index);
|
||||||
onToggleCompare(historyItem.id);
|
}, [onSelect, historyItem.id, index]);
|
||||||
} else {
|
|
||||||
onSelect(historyItem.id, index);
|
|
||||||
}
|
|
||||||
}, [compareMode, onToggleCompare, onSelect, historyItem.id, index]);
|
|
||||||
|
|
||||||
const handleMouseEnter = useCallback(() => {
|
const handleMouseEnter = useCallback(() => {
|
||||||
onHover?.(historyItem.id, index);
|
onHover?.(historyItem.id, index);
|
||||||
@@ -69,115 +37,63 @@ const HistoryItem = memo(function HistoryItem({
|
|||||||
const hasContributors = contributors && contributors.length > 0;
|
const hasContributors = contributors && contributors.length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<UnstyledButton
|
||||||
className={clsx(classes.history, { [classes.active]: isActive })}
|
p="xs"
|
||||||
|
onClick={handleClick}
|
||||||
onMouseEnter={handleMouseEnter}
|
onMouseEnter={handleMouseEnter}
|
||||||
onMouseLeave={onHoverEnd}
|
onMouseLeave={onHoverEnd}
|
||||||
|
className={clsx(classes.history, { [classes.active]: isActive })}
|
||||||
>
|
>
|
||||||
{compareMode && (
|
<Text size="sm">{formattedDate(new Date(historyItem.createdAt))}</Text>
|
||||||
<Checkbox
|
|
||||||
size="xs"
|
|
||||||
className={classes.compareCheckbox}
|
|
||||||
checked={isChecked}
|
|
||||||
disabled={isCheckboxDisabled}
|
|
||||||
onChange={() => onToggleCompare(historyItem.id)}
|
|
||||||
aria-label={t("Select version from {{date}}", { date })}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<UnstyledButton
|
<Group gap={6} wrap="nowrap" mt={4}>
|
||||||
p="xs"
|
{hasContributors ? (
|
||||||
onClick={handleClick}
|
<>
|
||||||
className={classes.historyButton}
|
<Tooltip.Group openDelay={300} closeDelay={100}>
|
||||||
>
|
<Avatar.Group spacing={8}>
|
||||||
<Text size="sm">{date}</Text>
|
{contributors.slice(0, MAX_VISIBLE_AVATARS).map((contributor) => (
|
||||||
|
<Tooltip key={contributor.id} label={contributor.name} withArrow>
|
||||||
<Group gap={6} wrap="nowrap" mt={4}>
|
<CustomAvatar
|
||||||
{hasContributors ? (
|
size="sm"
|
||||||
<>
|
avatarUrl={contributor.avatarUrl}
|
||||||
<Tooltip.Group openDelay={300} closeDelay={100}>
|
name={contributor.name}
|
||||||
<Avatar.Group spacing={8}>
|
/>
|
||||||
{contributors
|
</Tooltip>
|
||||||
.slice(0, MAX_VISIBLE_AVATARS)
|
))}
|
||||||
.map((contributor) => (
|
{contributors.length > MAX_VISIBLE_AVATARS && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
key={contributor.id}
|
withArrow
|
||||||
label={contributor.name}
|
label={contributors.slice(MAX_VISIBLE_AVATARS).map((c) => (
|
||||||
withArrow
|
<div key={c.id}>{c.name}</div>
|
||||||
>
|
|
||||||
<CustomAvatar
|
|
||||||
size="sm"
|
|
||||||
avatarUrl={contributor.avatarUrl}
|
|
||||||
name={contributor.name}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
))}
|
))}
|
||||||
{contributors.length > MAX_VISIBLE_AVATARS && (
|
>
|
||||||
<Tooltip
|
<Avatar size="sm" color="gray">
|
||||||
withArrow
|
+{contributors.length - MAX_VISIBLE_AVATARS}
|
||||||
label={contributors
|
</Avatar>
|
||||||
.slice(MAX_VISIBLE_AVATARS)
|
</Tooltip>
|
||||||
.map((c) => (
|
)}
|
||||||
<div key={c.id}>{c.name}</div>
|
</Avatar.Group>
|
||||||
))}
|
</Tooltip.Group>
|
||||||
>
|
{contributors.length === 1 && (
|
||||||
<Avatar size="sm" color="gray">
|
|
||||||
+{contributors.length - MAX_VISIBLE_AVATARS}
|
|
||||||
</Avatar>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</Avatar.Group>
|
|
||||||
</Tooltip.Group>
|
|
||||||
{contributors.length === 1 && (
|
|
||||||
<Text size="sm" c="dimmed" lineClamp={1}>
|
|
||||||
{contributors[0].name}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<CustomAvatar
|
|
||||||
size="sm"
|
|
||||||
avatarUrl={historyItem.lastUpdatedBy?.avatarUrl}
|
|
||||||
name={historyItem.lastUpdatedBy?.name}
|
|
||||||
/>
|
|
||||||
<Text size="sm" c="dimmed" lineClamp={1}>
|
<Text size="sm" c="dimmed" lineClamp={1}>
|
||||||
{historyItem.lastUpdatedBy?.name}
|
{contributors[0].name}
|
||||||
</Text>
|
</Text>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
</UnstyledButton>
|
|
||||||
|
|
||||||
{!compareMode && (
|
|
||||||
<Menu shadow="md" width={180} position="bottom-end">
|
|
||||||
<Menu.Target>
|
|
||||||
<ActionIcon
|
|
||||||
variant="subtle"
|
|
||||||
color="gray"
|
|
||||||
className={classes.itemMenu}
|
|
||||||
aria-label={t("Version actions for {{date}}", { date })}
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
<IconDots size={18} />
|
|
||||||
</ActionIcon>
|
|
||||||
</Menu.Target>
|
|
||||||
<Menu.Dropdown>
|
|
||||||
<Menu.Item
|
|
||||||
disabled={!canCompare}
|
|
||||||
onClick={() => onStartCompare(historyItem.id)}
|
|
||||||
>
|
|
||||||
{t("Compare")}
|
|
||||||
</Menu.Item>
|
|
||||||
{onRestore && (
|
|
||||||
<Menu.Item onClick={() => onRestore(historyItem.id, index)}>
|
|
||||||
{t("Restore")}
|
|
||||||
</Menu.Item>
|
|
||||||
)}
|
)}
|
||||||
</Menu.Dropdown>
|
</>
|
||||||
</Menu>
|
) : (
|
||||||
)}
|
<>
|
||||||
</div>
|
<CustomAvatar
|
||||||
|
size="sm"
|
||||||
|
avatarUrl={historyItem.lastUpdatedBy?.avatarUrl}
|
||||||
|
name={historyItem.lastUpdatedBy?.name}
|
||||||
|
/>
|
||||||
|
<Text size="sm" c="dimmed" lineClamp={1}>
|
||||||
|
{historyItem.lastUpdatedBy?.name}
|
||||||
|
</Text>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
</UnstyledButton>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,8 @@ import HistoryItem from "@/features/page-history/components/history-item";
|
|||||||
import {
|
import {
|
||||||
activeHistoryIdAtom,
|
activeHistoryIdAtom,
|
||||||
activeHistoryPrevIdAtom,
|
activeHistoryPrevIdAtom,
|
||||||
compareModeAtom,
|
|
||||||
comparePairAtom,
|
|
||||||
compareSelectionAtom,
|
|
||||||
historyAtoms,
|
historyAtoms,
|
||||||
} from "@/features/page-history/atoms/history-atoms";
|
} from "@/features/page-history/atoms/history-atoms";
|
||||||
import { resolveComparePair } from "@/features/page-history/utils/resolve-compare-pair";
|
|
||||||
import { useAtom, useSetAtom } from "jotai";
|
import { useAtom, useSetAtom } from "jotai";
|
||||||
import { useCallback, useEffect, useMemo, useRef } from "react";
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
||||||
import {
|
import {
|
||||||
@@ -36,9 +32,6 @@ function HistoryList({ pageId }: Props) {
|
|||||||
const [activeHistoryId, setActiveHistoryId] = useAtom(activeHistoryIdAtom);
|
const [activeHistoryId, setActiveHistoryId] = useAtom(activeHistoryIdAtom);
|
||||||
const setActiveHistoryPrevId = useSetAtom(activeHistoryPrevIdAtom);
|
const setActiveHistoryPrevId = useSetAtom(activeHistoryPrevIdAtom);
|
||||||
const setHistoryModalOpen = useSetAtom(historyAtoms);
|
const setHistoryModalOpen = useSetAtom(historyAtoms);
|
||||||
const [compareMode, setCompareMode] = useAtom(compareModeAtom);
|
|
||||||
const [compareSelection, setCompareSelection] = useAtom(compareSelectionAtom);
|
|
||||||
const setComparePair = useSetAtom(comparePairAtom);
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: pageHistoryData,
|
data: pageHistoryData,
|
||||||
@@ -86,58 +79,10 @@ function HistoryList({ pageId }: Props) {
|
|||||||
|
|
||||||
const handleSelect = useCallback(
|
const handleSelect = useCallback(
|
||||||
(id: string, index: number) => {
|
(id: string, index: number) => {
|
||||||
setComparePair(null);
|
|
||||||
setActiveHistoryId(id);
|
setActiveHistoryId(id);
|
||||||
setActiveHistoryPrevId(historyItems[index + 1]?.id ?? "");
|
setActiveHistoryPrevId(historyItems[index + 1]?.id ?? "");
|
||||||
},
|
},
|
||||||
[historyItems, setActiveHistoryId, setActiveHistoryPrevId, setComparePair],
|
[historyItems, setActiveHistoryId, setActiveHistoryPrevId],
|
||||||
);
|
|
||||||
|
|
||||||
const handleToggleCompare = useCallback(
|
|
||||||
(id: string) => {
|
|
||||||
setCompareSelection((prev) => {
|
|
||||||
if (prev.includes(id)) return prev.filter((item) => item !== id);
|
|
||||||
if (prev.length >= 2) return prev;
|
|
||||||
return [...prev, id];
|
|
||||||
});
|
|
||||||
},
|
|
||||||
[setCompareSelection],
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleStartCompare = useCallback(
|
|
||||||
(id: string) => {
|
|
||||||
setComparePair(null);
|
|
||||||
setCompareMode(true);
|
|
||||||
setCompareSelection([id]);
|
|
||||||
},
|
|
||||||
[setComparePair, setCompareMode, setCompareSelection],
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleCancelCompare = useCallback(() => {
|
|
||||||
setCompareMode(false);
|
|
||||||
setCompareSelection([]);
|
|
||||||
}, [setCompareMode, setCompareSelection]);
|
|
||||||
|
|
||||||
const handleConfirmCompare = useCallback(() => {
|
|
||||||
const pair = resolveComparePair(historyItems, compareSelection);
|
|
||||||
if (!pair) return;
|
|
||||||
setComparePair(pair);
|
|
||||||
setCompareMode(false);
|
|
||||||
setCompareSelection([]);
|
|
||||||
}, [
|
|
||||||
historyItems,
|
|
||||||
compareSelection,
|
|
||||||
setComparePair,
|
|
||||||
setCompareMode,
|
|
||||||
setCompareSelection,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const handleRestoreItem = useCallback(
|
|
||||||
(id: string, index: number) => {
|
|
||||||
handleSelect(id, index);
|
|
||||||
confirmRestore(id);
|
|
||||||
},
|
|
||||||
[handleSelect, confirmRestore],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -193,16 +138,6 @@ function HistoryList({ pageId }: Props) {
|
|||||||
onHover={handleHover}
|
onHover={handleHover}
|
||||||
onHoverEnd={clearPrefetchTimeout}
|
onHoverEnd={clearPrefetchTimeout}
|
||||||
isActive={historyItem.id === activeHistoryId}
|
isActive={historyItem.id === activeHistoryId}
|
||||||
compareMode={compareMode}
|
|
||||||
isChecked={compareSelection.includes(historyItem.id)}
|
|
||||||
isCheckboxDisabled={
|
|
||||||
!compareSelection.includes(historyItem.id) &&
|
|
||||||
compareSelection.length >= 2
|
|
||||||
}
|
|
||||||
canCompare={historyItems.length >= 2}
|
|
||||||
onToggleCompare={handleToggleCompare}
|
|
||||||
onStartCompare={handleStartCompare}
|
|
||||||
onRestore={canRestore ? handleRestoreItem : undefined}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{hasNextPage && <div ref={loadMoreRef} style={{ height: 1 }} />}
|
{hasNextPage && <div ref={loadMoreRef} style={{ height: 1 }} />}
|
||||||
@@ -213,44 +148,22 @@ function HistoryList({ pageId }: Props) {
|
|||||||
)}
|
)}
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
|
|
||||||
{compareMode ? (
|
{canRestore && (
|
||||||
<>
|
<>
|
||||||
<Divider />
|
<Divider />
|
||||||
<Group p="xs" wrap="nowrap">
|
<Group p="xs" wrap="nowrap">
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
size="compact-md"
|
size="compact-md"
|
||||||
onClick={handleCancelCompare}
|
onClick={() => setHistoryModalOpen(false)}
|
||||||
>
|
>
|
||||||
{t("Cancel")}
|
{t("Cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button size="compact-md" onClick={confirmRestore}>
|
||||||
size="compact-md"
|
{t("Restore")}
|
||||||
disabled={compareSelection.length !== 2}
|
|
||||||
onClick={handleConfirmCompare}
|
|
||||||
>
|
|
||||||
{t("Compare")}
|
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</>
|
</>
|
||||||
) : (
|
|
||||||
canRestore && (
|
|
||||||
<>
|
|
||||||
<Divider />
|
|
||||||
<Group p="xs" wrap="nowrap">
|
|
||||||
<Button
|
|
||||||
variant="default"
|
|
||||||
size="compact-md"
|
|
||||||
onClick={() => setHistoryModalOpen(false)}
|
|
||||||
>
|
|
||||||
{t("Cancel")}
|
|
||||||
</Button>
|
|
||||||
<Button size="compact-md" onClick={() => confirmRestore()}>
|
|
||||||
{t("Restore")}
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
CloseButton,
|
|
||||||
Group,
|
Group,
|
||||||
Paper,
|
Paper,
|
||||||
ScrollArea,
|
ScrollArea,
|
||||||
@@ -13,20 +12,17 @@ import { useAtom, useAtomValue } from "jotai";
|
|||||||
import {
|
import {
|
||||||
activeHistoryIdAtom,
|
activeHistoryIdAtom,
|
||||||
activeHistoryPrevIdAtom,
|
activeHistoryPrevIdAtom,
|
||||||
comparePairAtom,
|
|
||||||
diffCountsAtom,
|
diffCountsAtom,
|
||||||
highlightChangesAtom,
|
highlightChangesAtom,
|
||||||
} from "@/features/page-history/atoms/history-atoms";
|
} from "@/features/page-history/atoms/history-atoms";
|
||||||
import HistoryView from "@/features/page-history/components/history-view";
|
import HistoryView from "@/features/page-history/components/history-view";
|
||||||
import { useMemo, useRef } from "react";
|
import { useRef } from "react";
|
||||||
import { IconChevronUp, IconChevronDown } from "@tabler/icons-react";
|
import { IconChevronUp, IconChevronDown } from "@tabler/icons-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
useDiffNavigation,
|
useDiffNavigation,
|
||||||
useHistoryReset,
|
useHistoryReset,
|
||||||
} from "@/features/page-history/hooks";
|
} from "@/features/page-history/hooks";
|
||||||
import { usePageHistoryListQuery } from "@/features/page-history/queries/page-history-query";
|
|
||||||
import { formattedDate } from "@/lib/time";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
pageId: string;
|
pageId: string;
|
||||||
@@ -40,28 +36,6 @@ export default function HistoryModalBody({ pageId }: Props) {
|
|||||||
const activeHistoryPrevId = useAtomValue(activeHistoryPrevIdAtom);
|
const activeHistoryPrevId = useAtomValue(activeHistoryPrevIdAtom);
|
||||||
const [highlightChanges, setHighlightChanges] = useAtom(highlightChangesAtom);
|
const [highlightChanges, setHighlightChanges] = useAtom(highlightChangesAtom);
|
||||||
const diffCounts = useAtomValue(diffCountsAtom);
|
const diffCounts = useAtomValue(diffCountsAtom);
|
||||||
const [comparePair, setComparePair] = useAtom(comparePairAtom);
|
|
||||||
|
|
||||||
const { data: pageHistoryData } = usePageHistoryListQuery(pageId);
|
|
||||||
const historyItems = useMemo(
|
|
||||||
() => pageHistoryData?.pages.flatMap((page) => page.items) ?? [],
|
|
||||||
[pageHistoryData],
|
|
||||||
);
|
|
||||||
|
|
||||||
const compareLabel = useMemo(() => {
|
|
||||||
if (!comparePair) return null;
|
|
||||||
const newerItem = historyItems.find(
|
|
||||||
(item) => item.id === comparePair.newerId,
|
|
||||||
);
|
|
||||||
const olderItem = historyItems.find(
|
|
||||||
(item) => item.id === comparePair.olderId,
|
|
||||||
);
|
|
||||||
if (!newerItem || !olderItem) return null;
|
|
||||||
return t("Comparing {{newer}} and {{older}}", {
|
|
||||||
newer: formattedDate(new Date(newerItem.createdAt)),
|
|
||||||
older: formattedDate(new Date(olderItem.createdAt)),
|
|
||||||
});
|
|
||||||
}, [comparePair, historyItems, t]);
|
|
||||||
|
|
||||||
useHistoryReset(pageId);
|
useHistoryReset(pageId);
|
||||||
const { currentChangeIndex, handlePrevChange, handleNextChange } =
|
const { currentChangeIndex, handlePrevChange, handleNextChange } =
|
||||||
@@ -76,25 +50,6 @@ export default function HistoryModalBody({ pageId }: Props) {
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div style={{ position: "relative", flex: 1 }}>
|
<div style={{ position: "relative", flex: 1 }}>
|
||||||
{comparePair && (
|
|
||||||
<Group
|
|
||||||
justify="space-between"
|
|
||||||
wrap="nowrap"
|
|
||||||
px="md"
|
|
||||||
py={4}
|
|
||||||
className={classes.compareBanner}
|
|
||||||
>
|
|
||||||
<Text size="sm" fw={500} lineClamp={1}>
|
|
||||||
{compareLabel ?? t("Compare versions")}
|
|
||||||
</Text>
|
|
||||||
<CloseButton
|
|
||||||
size="sm"
|
|
||||||
aria-label={t("Exit compare")}
|
|
||||||
onClick={() => setComparePair(null)}
|
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<ScrollArea
|
<ScrollArea
|
||||||
h={650}
|
h={650}
|
||||||
w="100%"
|
w="100%"
|
||||||
@@ -102,18 +57,11 @@ export default function HistoryModalBody({ pageId }: Props) {
|
|||||||
viewportRef={scrollViewportRef}
|
viewportRef={scrollViewportRef}
|
||||||
>
|
>
|
||||||
<div className={classes.sidebarRightSection}>
|
<div className={classes.sidebarRightSection}>
|
||||||
{comparePair ? (
|
{activeHistoryId && <HistoryView />}
|
||||||
<HistoryView
|
|
||||||
historyId={comparePair.newerId}
|
|
||||||
prevHistoryId={comparePair.olderId}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
activeHistoryId && <HistoryView />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
|
|
||||||
{(comparePair || (activeHistoryId && activeHistoryPrevId)) && (
|
{activeHistoryId && activeHistoryPrevId && (
|
||||||
<Paper
|
<Paper
|
||||||
shadow="md"
|
shadow="md"
|
||||||
radius="xl"
|
radius="xl"
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ export default function HistoryModalMobile({ pageId, pageTitle }: Props) {
|
|||||||
<Button variant="default" onClick={() => setHistoryModalOpen(false)}>
|
<Button variant="default" onClick={() => setHistoryModalOpen(false)}>
|
||||||
{t("Cancel")}
|
{t("Cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={() => confirmRestore()}>{t("Restore")}</Button>
|
<Button onClick={confirmRestore}>{t("Restore")}</Button>
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -7,29 +7,21 @@ import {
|
|||||||
activeHistoryPrevIdAtom,
|
activeHistoryPrevIdAtom,
|
||||||
} from "@/features/page-history/atoms/history-atoms";
|
} from "@/features/page-history/atoms/history-atoms";
|
||||||
|
|
||||||
interface Props {
|
function HistoryView() {
|
||||||
historyId?: string;
|
|
||||||
prevHistoryId?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function HistoryView({ historyId, prevHistoryId }: Props) {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const activeId = useAtomValue(activeHistoryIdAtom);
|
const historyId = useAtomValue(activeHistoryIdAtom);
|
||||||
const activePrevId = useAtomValue(activeHistoryPrevIdAtom);
|
const prevHistoryId = useAtomValue(activeHistoryPrevIdAtom);
|
||||||
|
|
||||||
const resolvedId = historyId ?? activeId;
|
|
||||||
const resolvedPrevId = prevHistoryId ?? activePrevId;
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data,
|
data,
|
||||||
isLoading: isLoadingCurrent,
|
isLoading: isLoadingCurrent,
|
||||||
isError: isErrorCurrent,
|
isError: isErrorCurrent,
|
||||||
} = usePageHistoryQuery(resolvedId);
|
} = usePageHistoryQuery(historyId);
|
||||||
const {
|
const {
|
||||||
data: prevData,
|
data: prevData,
|
||||||
isLoading: isLoadingPrev,
|
isLoading: isLoadingPrev,
|
||||||
isError: isErrorPrev,
|
isError: isErrorPrev,
|
||||||
} = usePageHistoryQuery(resolvedPrevId);
|
} = usePageHistoryQuery(prevHistoryId);
|
||||||
|
|
||||||
if (isLoadingCurrent || isLoadingPrev) {
|
if (isLoadingCurrent || isLoadingPrev) {
|
||||||
return <></>;
|
return <></>;
|
||||||
|
|||||||
@@ -3,45 +3,22 @@ import { useEffect } from "react";
|
|||||||
import {
|
import {
|
||||||
activeHistoryIdAtom,
|
activeHistoryIdAtom,
|
||||||
activeHistoryPrevIdAtom,
|
activeHistoryPrevIdAtom,
|
||||||
compareModeAtom,
|
|
||||||
comparePairAtom,
|
|
||||||
compareSelectionAtom,
|
|
||||||
diffCountsAtom,
|
diffCountsAtom,
|
||||||
} from "@/features/page-history/atoms/history-atoms";
|
} from "@/features/page-history/atoms/history-atoms";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets history state when pageId changes.
|
* Resets history state when pageId changes.
|
||||||
* Clears active selection, diff counts, and compare state.
|
* Clears active selection and diff counts.
|
||||||
* Compare state also resets on unmount so reopening the modal starts clean.
|
|
||||||
*/
|
*/
|
||||||
export function useHistoryReset(pageId: string) {
|
export function useHistoryReset(pageId: string) {
|
||||||
const [, setActiveHistoryId] = useAtom(activeHistoryIdAtom);
|
const [, setActiveHistoryId] = useAtom(activeHistoryIdAtom);
|
||||||
const [, setActiveHistoryPrevId] = useAtom(activeHistoryPrevIdAtom);
|
const [, setActiveHistoryPrevId] = useAtom(activeHistoryPrevIdAtom);
|
||||||
const [, setDiffCounts] = useAtom(diffCountsAtom);
|
const [, setDiffCounts] = useAtom(diffCountsAtom);
|
||||||
const [, setCompareMode] = useAtom(compareModeAtom);
|
|
||||||
const [, setCompareSelection] = useAtom(compareSelectionAtom);
|
|
||||||
const [, setComparePair] = useAtom(comparePairAtom);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const resetCompare = () => {
|
|
||||||
setCompareMode(false);
|
|
||||||
setCompareSelection([]);
|
|
||||||
setComparePair(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
setActiveHistoryId("");
|
setActiveHistoryId("");
|
||||||
setActiveHistoryPrevId("");
|
setActiveHistoryPrevId("");
|
||||||
|
// @ts-ignore
|
||||||
setDiffCounts(null);
|
setDiffCounts(null);
|
||||||
resetCompare();
|
}, [pageId, setActiveHistoryId, setActiveHistoryPrevId, setDiffCounts]);
|
||||||
|
|
||||||
return resetCompare;
|
|
||||||
}, [
|
|
||||||
pageId,
|
|
||||||
setActiveHistoryId,
|
|
||||||
setActiveHistoryPrevId,
|
|
||||||
setDiffCounts,
|
|
||||||
setCompareMode,
|
|
||||||
setCompareSelection,
|
|
||||||
setComparePair,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useAtomValue, useSetAtom } from "jotai";
|
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Text } from "@mantine/core";
|
import { Text } from "@mantine/core";
|
||||||
@@ -9,8 +9,7 @@ import {
|
|||||||
activeHistoryIdAtom,
|
activeHistoryIdAtom,
|
||||||
historyAtoms,
|
historyAtoms,
|
||||||
} from "@/features/page-history/atoms/history-atoms";
|
} from "@/features/page-history/atoms/history-atoms";
|
||||||
import { fetchPageHistory } from "@/features/page-history/queries/page-history-query";
|
import { usePageHistoryQuery } from "@/features/page-history/queries/page-history-query";
|
||||||
import { IPageHistory } from "@/features/page-history/types/page.types";
|
|
||||||
import {
|
import {
|
||||||
pageEditorAtom,
|
pageEditorAtom,
|
||||||
titleEditorAtom,
|
titleEditorAtom,
|
||||||
@@ -26,6 +25,8 @@ export function useHistoryRestore() {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const activeHistoryId = useAtomValue(activeHistoryIdAtom);
|
const activeHistoryId = useAtomValue(activeHistoryIdAtom);
|
||||||
|
const { data: activeHistoryData } = usePageHistoryQuery(activeHistoryId);
|
||||||
|
|
||||||
const mainEditor = useAtomValue(pageEditorAtom);
|
const mainEditor = useAtomValue(pageEditorAtom);
|
||||||
const mainEditorTitle = useAtomValue(titleEditorAtom);
|
const mainEditorTitle = useAtomValue(titleEditorAtom);
|
||||||
const setHistoryModalOpen = useSetAtom(historyAtoms);
|
const setHistoryModalOpen = useSetAtom(historyAtoms);
|
||||||
@@ -39,66 +40,47 @@ export function useHistoryRestore() {
|
|||||||
SpaceCaslSubject.Page,
|
SpaceCaslSubject.Page,
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleRestore = useCallback(
|
const handleRestore = useCallback(() => {
|
||||||
async (historyId: string) => {
|
if (!activeHistoryData) return;
|
||||||
let historyData: IPageHistory;
|
if (
|
||||||
try {
|
!mainEditor ||
|
||||||
historyData = await fetchPageHistory(historyId);
|
mainEditor.isDestroyed ||
|
||||||
} catch {
|
!mainEditorTitle ||
|
||||||
notifications.show({
|
mainEditorTitle.isDestroyed
|
||||||
message: t("Error fetching page data."),
|
) {
|
||||||
color: "red",
|
return;
|
||||||
});
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
mainEditorTitle
|
||||||
!mainEditor ||
|
.chain()
|
||||||
mainEditor.isDestroyed ||
|
.clearContent()
|
||||||
!mainEditorTitle ||
|
.setContent(activeHistoryData.title, { emitUpdate: true })
|
||||||
mainEditorTitle.isDestroyed
|
.run();
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mainEditorTitle
|
mainEditor
|
||||||
.chain()
|
.chain()
|
||||||
.clearContent()
|
.clearContent()
|
||||||
.setContent(historyData.title, { emitUpdate: true })
|
.setContent(activeHistoryData.content)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
mainEditor
|
setHistoryModalOpen(false);
|
||||||
.chain()
|
notifications.show({ message: t("Successfully restored") });
|
||||||
.clearContent()
|
}, [activeHistoryData, mainEditor, mainEditorTitle, setHistoryModalOpen, t]);
|
||||||
.setContent(historyData.content)
|
|
||||||
.run();
|
|
||||||
|
|
||||||
setHistoryModalOpen(false);
|
const confirmRestore = useCallback(() => {
|
||||||
notifications.show({ message: t("Successfully restored") });
|
modals.openConfirmModal({
|
||||||
},
|
title: t("Please confirm your action"),
|
||||||
[mainEditor, mainEditorTitle, setHistoryModalOpen, t],
|
children: (
|
||||||
);
|
<Text size="sm">
|
||||||
|
{t(
|
||||||
const confirmRestore = useCallback(
|
"Are you sure you want to restore this version? Any changes not versioned will be lost.",
|
||||||
(historyId?: string) => {
|
)}
|
||||||
const targetId = historyId ?? activeHistoryId;
|
</Text>
|
||||||
if (!targetId) return;
|
),
|
||||||
|
labels: { confirm: t("Confirm"), cancel: t("Cancel") },
|
||||||
modals.openConfirmModal({
|
onConfirm: handleRestore,
|
||||||
title: t("Please confirm your action"),
|
});
|
||||||
children: (
|
}, [t, handleRestore]);
|
||||||
<Text size="sm">
|
|
||||||
{t(
|
|
||||||
"Are you sure you want to restore this version? Any changes not versioned will be lost.",
|
|
||||||
)}
|
|
||||||
</Text>
|
|
||||||
),
|
|
||||||
labels: { confirm: t("Confirm"), cancel: t("Cancel") },
|
|
||||||
onConfirm: () => handleRestore(targetId),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
[t, handleRestore, activeHistoryId],
|
|
||||||
);
|
|
||||||
|
|
||||||
return { canRestore, confirmRestore };
|
return { canRestore, confirmRestore };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,14 +23,6 @@ export function prefetchPageHistory(historyId: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchPageHistory(historyId: string): Promise<IPageHistory> {
|
|
||||||
return queryClient.fetchQuery({
|
|
||||||
queryKey: ["page-history", historyId],
|
|
||||||
queryFn: () => getPageHistoryById(historyId),
|
|
||||||
staleTime: HISTORY_STALE_TIME,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function usePageHistoryListQuery(
|
export function usePageHistoryListQuery(
|
||||||
pageId: string,
|
pageId: string,
|
||||||
): UseInfiniteQueryResult<InfiniteData<IPagination<IPageHistory>, unknown>> {
|
): UseInfiniteQueryResult<InfiniteData<IPagination<IPageHistory>, unknown>> {
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
import { resolveComparePair } from "./resolve-compare-pair";
|
|
||||||
|
|
||||||
// list is newest-first, matching usePageHistoryListQuery order
|
|
||||||
const items = [{ id: "v3" }, { id: "v2" }, { id: "v1" }];
|
|
||||||
|
|
||||||
describe("resolveComparePair", () => {
|
|
||||||
it("orders newer before older regardless of selection order", () => {
|
|
||||||
expect(resolveComparePair(items, ["v1", "v3"])).toEqual({
|
|
||||||
newerId: "v3",
|
|
||||||
olderId: "v1",
|
|
||||||
});
|
|
||||||
expect(resolveComparePair(items, ["v3", "v1"])).toEqual({
|
|
||||||
newerId: "v3",
|
|
||||||
olderId: "v1",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("returns null unless exactly two versions are selected", () => {
|
|
||||||
expect(resolveComparePair(items, [])).toBeNull();
|
|
||||||
expect(resolveComparePair(items, ["v1"])).toBeNull();
|
|
||||||
expect(resolveComparePair(items, ["v1", "v2", "v3"])).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("returns null when a selected id is not in the list", () => {
|
|
||||||
expect(resolveComparePair(items, ["v1", "missing"])).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("returns null when the same id is selected twice", () => {
|
|
||||||
expect(resolveComparePair(items, ["v2", "v2"])).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { ComparePair } from "@/features/page-history/atoms/history-atoms";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolves which of the two selected versions is newer using their position
|
|
||||||
* in the history list (list is newest-first: lower index = newer).
|
|
||||||
*/
|
|
||||||
export function resolveComparePair(
|
|
||||||
historyItems: { id: string }[],
|
|
||||||
selection: string[],
|
|
||||||
): ComparePair | null {
|
|
||||||
if (selection.length !== 2) return null;
|
|
||||||
const indexA = historyItems.findIndex((item) => item.id === selection[0]);
|
|
||||||
const indexB = historyItems.findIndex((item) => item.id === selection[1]);
|
|
||||||
if (indexA === -1 || indexB === -1 || indexA === indexB) return null;
|
|
||||||
return indexA < indexB
|
|
||||||
? { newerId: selection[0], olderId: selection[1] }
|
|
||||||
: { newerId: selection[1], olderId: selection[0] };
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,6 @@ import {
|
|||||||
IconList,
|
IconList,
|
||||||
IconMarkdown,
|
IconMarkdown,
|
||||||
IconMessage,
|
IconMessage,
|
||||||
IconPaperclip,
|
|
||||||
IconPrinter,
|
IconPrinter,
|
||||||
IconStar,
|
IconStar,
|
||||||
IconStarFilled,
|
IconStarFilled,
|
||||||
@@ -43,7 +42,6 @@ import {
|
|||||||
import { formattedDate } from "@/lib/time.ts";
|
import { formattedDate } from "@/lib/time.ts";
|
||||||
import { PageEditModeToggle } from "@/features/user/components/page-state-pref.tsx";
|
import { PageEditModeToggle } from "@/features/user/components/page-state-pref.tsx";
|
||||||
import MovePageModal from "@/features/page/components/move-page-modal.tsx";
|
import MovePageModal from "@/features/page/components/move-page-modal.tsx";
|
||||||
import PageAttachmentsModal from "@/features/attachments/components/page-attachments-modal.tsx";
|
|
||||||
import { useTimeAgo } from "@/hooks/use-time-ago.tsx";
|
import { useTimeAgo } from "@/hooks/use-time-ago.tsx";
|
||||||
import { PageShareModal } from "@/ee/page-permission";
|
import { PageShareModal } from "@/ee/page-permission";
|
||||||
import {
|
import {
|
||||||
@@ -159,10 +157,6 @@ function PageActionMenu({ readOnly }: PageActionMenuProps) {
|
|||||||
verificationOpened,
|
verificationOpened,
|
||||||
{ open: openVerificationModal, close: closeVerificationModal },
|
{ open: openVerificationModal, close: closeVerificationModal },
|
||||||
] = useDisclosure(false);
|
] = useDisclosure(false);
|
||||||
const [
|
|
||||||
attachmentsOpened,
|
|
||||||
{ open: openAttachmentsModal, close: closeAttachmentsModal },
|
|
||||||
] = useDisclosure(false);
|
|
||||||
const [pageEditor] = useAtom(pageEditorAtom);
|
const [pageEditor] = useAtom(pageEditorAtom);
|
||||||
const pageUpdatedAt = useTimeAgo(page?.updatedAt);
|
const pageUpdatedAt = useTimeAgo(page?.updatedAt);
|
||||||
const favoriteIds = useFavoriteIds("page", page?.spaceId);
|
const favoriteIds = useFavoriteIds("page", page?.spaceId);
|
||||||
@@ -299,15 +293,6 @@ function PageActionMenu({ readOnly }: PageActionMenuProps) {
|
|||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!page?.isBase && (
|
|
||||||
<Menu.Item
|
|
||||||
leftSection={<IconPaperclip size={16} />}
|
|
||||||
onClick={openAttachmentsModal}
|
|
||||||
>
|
|
||||||
{t("Attachments")}
|
|
||||||
</Menu.Item>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!readOnly && !page?.isBase && (
|
{!readOnly && !page?.isBase && (
|
||||||
<PageVerificationMenuItem
|
<PageVerificationMenuItem
|
||||||
pageId={page?.id}
|
pageId={page?.id}
|
||||||
@@ -410,12 +395,6 @@ function PageActionMenu({ readOnly }: PageActionMenuProps) {
|
|||||||
opened={verificationOpened}
|
opened={verificationOpened}
|
||||||
onClose={closeVerificationModal}
|
onClose={closeVerificationModal}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PageAttachmentsModal
|
|
||||||
pageId={page.id}
|
|
||||||
open={attachmentsOpened}
|
|
||||||
onClose={closeAttachmentsModal}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,16 +13,11 @@ import { SearchResultItem } from "./search-result-item.tsx";
|
|||||||
import { AiSearchResult } from "../../../ee/ai/components/ai-search-result.tsx";
|
import { AiSearchResult } from "../../../ee/ai/components/ai-search-result.tsx";
|
||||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||||
import { Feature } from "@/ee/features";
|
import { Feature } from "@/ee/features";
|
||||||
import { useAtomValue } from "jotai";
|
|
||||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
|
||||||
import { hintVectorCache } from "@/ee/ai/services/ai-search-service.ts";
|
|
||||||
import { getAiVectorDriver } from "@/lib/config.ts";
|
|
||||||
|
|
||||||
interface SearchSpotlightProps {
|
interface SearchSpotlightProps {
|
||||||
spaceId?: string;
|
spaceId?: string;
|
||||||
}
|
}
|
||||||
export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
||||||
const workspace = useAtomValue(workspaceAtom);
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const hasAiFeature = useHasFeature(Feature.AI);
|
const hasAiFeature = useHasFeature(Feature.AI);
|
||||||
const hasAttachmentIndexing = useHasFeature(Feature.ATTACHMENT_INDEXING);
|
const hasAttachmentIndexing = useHasFeature(Feature.ATTACHMENT_INDEXING);
|
||||||
@@ -101,15 +96,6 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
const handleSpotlightOpen = () => {
|
|
||||||
if (
|
|
||||||
workspace?.settings?.ai?.search === true &&
|
|
||||||
getAiVectorDriver() === "turbopuffer"
|
|
||||||
) {
|
|
||||||
hintVectorCache();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleFiltersChange = (newFilters: any) => {
|
const handleFiltersChange = (newFilters: any) => {
|
||||||
setFilters(newFilters);
|
setFilters(newFilters);
|
||||||
};
|
};
|
||||||
@@ -129,7 +115,6 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
<Spotlight.Root
|
<Spotlight.Root
|
||||||
size="xl"
|
size="xl"
|
||||||
maxHeight={600}
|
maxHeight={600}
|
||||||
onSpotlightOpen={handleSpotlightOpen}
|
|
||||||
store={searchSpotlightStore}
|
store={searchSpotlightStore}
|
||||||
query={query}
|
query={query}
|
||||||
onQueryChange={setQuery}
|
onQueryChange={setQuery}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useDebouncedValue } from "@mantine/hooks";
|
import { useDebouncedValue } from "@mantine/hooks";
|
||||||
import { Group, Select, SelectProps, Text } from "@mantine/core";
|
import { Group, Select, SelectProps, Text } from "@mantine/core";
|
||||||
import { useGetSpacesQuery } from "@/features/space/queries/space-query.ts";
|
import { useGetSpacesQuery } from "@/features/space/queries/space-query.ts";
|
||||||
@@ -14,7 +14,6 @@ interface SpaceSelectProps {
|
|||||||
width?: number;
|
width?: number;
|
||||||
opened?: boolean;
|
opened?: boolean;
|
||||||
clearable?: boolean;
|
clearable?: boolean;
|
||||||
withinPortal?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderSelectOption: SelectProps["renderOption"] = ({ option }) => (
|
const renderSelectOption: SelectProps["renderOption"] = ({ option }) => (
|
||||||
@@ -42,7 +41,6 @@ export function SpaceSelect({
|
|||||||
width,
|
width,
|
||||||
opened,
|
opened,
|
||||||
clearable,
|
clearable,
|
||||||
withinPortal = true,
|
|
||||||
}: SpaceSelectProps) {
|
}: SpaceSelectProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [searchValue, setSearchValue] = useState("");
|
const [searchValue, setSearchValue] = useState("");
|
||||||
@@ -52,13 +50,9 @@ export function SpaceSelect({
|
|||||||
limit: 50,
|
limit: 50,
|
||||||
});
|
});
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
const fetchedSpaces = useRef(new Map<string, ISpace>());
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (spaces) {
|
if (spaces) {
|
||||||
spaces.items.forEach((space: ISpace) =>
|
|
||||||
fetchedSpaces.current.set(space.slug, space),
|
|
||||||
);
|
|
||||||
const spaceData = spaces?.items
|
const spaceData = spaces?.items
|
||||||
.filter((space: ISpace) => space.slug !== value)
|
.filter((space: ISpace) => space.slug !== value)
|
||||||
.map((space: ISpace) => {
|
.map((space: ISpace) => {
|
||||||
@@ -89,19 +83,14 @@ export function SpaceSelect({
|
|||||||
onSearchChange={setSearchValue}
|
onSearchChange={setSearchValue}
|
||||||
clearable={clearable}
|
clearable={clearable}
|
||||||
variant="filled"
|
variant="filled"
|
||||||
onChange={(slug) => {
|
onChange={(slug) =>
|
||||||
// options accumulate across fetches; resolve against everything
|
onChange(spaces.items?.find((item) => item.slug === slug))
|
||||||
// fetched, not just the latest query result
|
}
|
||||||
const space = slug && fetchedSpaces.current.get(slug);
|
|
||||||
if (space) {
|
|
||||||
onChange(space);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
nothingFoundMessage={t("No space found")}
|
nothingFoundMessage={t("No space found")}
|
||||||
limit={50}
|
limit={50}
|
||||||
checkIconPosition="right"
|
checkIconPosition="right"
|
||||||
comboboxProps={{ width, withinPortal, position: "bottom", keepMounted: false, dropdownPadding: 0 }}
|
comboboxProps={{ width, withinPortal: true, position: "bottom", keepMounted: false, dropdownPadding: 0 }}
|
||||||
dropdownOpened={opened}
|
dropdownOpened={opened}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ import {
|
|||||||
import { mobileSidebarAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
import { mobileSidebarAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
||||||
import { useToggleSidebar } from "@/components/layouts/global/hooks/hooks/use-toggle-sidebar.ts";
|
import { useToggleSidebar } from "@/components/layouts/global/hooks/hooks/use-toggle-sidebar.ts";
|
||||||
import { searchSpotlight } from "@/features/search/constants";
|
import { searchSpotlight } from "@/features/search/constants";
|
||||||
const TemplatePickerModal = React.lazy(
|
import TemplatePickerModal from "@/ee/template/components/template-picker-modal";
|
||||||
() => import("@/ee/template/components/template-picker-modal"),
|
|
||||||
);
|
|
||||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||||
import { Feature } from "@/ee/features";
|
import { Feature } from "@/ee/features";
|
||||||
@@ -408,13 +406,11 @@ function SpaceMenu({
|
|||||||
|
|
||||||
{hasTemplates && templatePickerOpened && (
|
{hasTemplates && templatePickerOpened && (
|
||||||
<ErrorBoundary fallbackRender={() => null}>
|
<ErrorBoundary fallbackRender={() => null}>
|
||||||
<React.Suspense fallback={null}>
|
<TemplatePickerModal
|
||||||
<TemplatePickerModal
|
opened={templatePickerOpened}
|
||||||
opened={templatePickerOpened}
|
onClose={closeTemplatePicker}
|
||||||
onClose={closeTemplatePicker}
|
initialSpaceId={spaceId}
|
||||||
initialSpaceId={spaceId}
|
/>
|
||||||
/>
|
|
||||||
</React.Suspense>
|
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ export function SwitchSpace({
|
|||||||
onChange={(space) => handleSelect(space.slug)}
|
onChange={(space) => handleSelect(space.slug)}
|
||||||
width={300}
|
width={300}
|
||||||
opened={true}
|
opened={true}
|
||||||
withinPortal={false}
|
|
||||||
/>
|
/>
|
||||||
</Popover.Dropdown>
|
</Popover.Dropdown>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ export function isCloud(): boolean {
|
|||||||
return castToBoolean(getConfigValue("CLOUD"));
|
return castToBoolean(getConfigValue("CLOUD"));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAiVectorDriver(): string {
|
|
||||||
return getConfigValue("AI_VECTOR_DRIVER");
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAvatarUrl(
|
export function getAvatarUrl(
|
||||||
avatarUrl: string,
|
avatarUrl: string,
|
||||||
type: AvatarIconType = AvatarIconType.AVATAR,
|
type: AvatarIconType = AvatarIconType.AVATAR,
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import { ForgotPasswordForm } from "@/features/auth/components/forgot-password-form";
|
import { ForgotPasswordForm } from "@/features/auth/components/forgot-password-form";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
import { getAppName } from "@/lib/config";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
|
||||||
export default function ForgotPassword() {
|
export default function ForgotPassword() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title="Forgot Password" />
|
<Helmet>
|
||||||
|
<title>Forgot Password - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
<ForgotPasswordForm />
|
<ForgotPasswordForm />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { InviteSignUpForm } from "@/features/auth/components/invite-sign-up-form.tsx";
|
import { InviteSignUpForm } from "@/features/auth/components/invite-sign-up-form.tsx";
|
||||||
|
import {getAppName} from "@/lib/config.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function InviteSignup() {
|
export default function InviteSignup() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Invitation Signup")} />
|
<Helmet>
|
||||||
|
<title>{t("Invitation Signup")} - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
<InviteSignUpForm />
|
<InviteSignUpForm />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import { LoginForm } from "@/features/auth/components/login-form";
|
import { LoginForm } from "@/features/auth/components/login-form";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Login")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Login")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<LoginForm />
|
<LoginForm />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { PasswordResetForm } from "@/features/auth/components/password-reset-form";
|
import { PasswordResetForm } from "@/features/auth/components/password-reset-form";
|
||||||
import { Link, useSearchParams } from "react-router-dom";
|
import { Link, useSearchParams } from "react-router-dom";
|
||||||
import { useVerifyUserTokenQuery } from "@/features/auth/queries/auth-query";
|
import { useVerifyUserTokenQuery } from "@/features/auth/queries/auth-query";
|
||||||
import { Button, Container, Group, Text } from "@mantine/core";
|
import { Button, Container, Group, Text } from "@mantine/core";
|
||||||
import APP_ROUTE from "@/lib/app-route";
|
import APP_ROUTE from "@/lib/app-route";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function PasswordReset() {
|
export default function PasswordReset() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -22,7 +23,11 @@ export default function PasswordReset() {
|
|||||||
if (isError || !resetToken) {
|
if (isError || !resetToken) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Password Reset")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Password Reset")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<Container my={40}>
|
<Container my={40}>
|
||||||
<Text size="lg" ta="center">
|
<Text size="lg" ta="center">
|
||||||
{t("Invalid or expired password reset link")}
|
{t("Invalid or expired password reset link")}
|
||||||
@@ -44,7 +49,11 @@ export default function PasswordReset() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Password Reset")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Password Reset")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<PasswordResetForm resetToken={resetToken} />
|
<PasswordResetForm resetToken={resetToken} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useWorkspacePublicDataQuery } from "@/features/workspace/queries/workspace-query.ts";
|
import { useWorkspacePublicDataQuery } from "@/features/workspace/queries/workspace-query.ts";
|
||||||
import { SetupWorkspaceForm } from "@/features/auth/components/setup-workspace-form.tsx";
|
import { SetupWorkspaceForm } from "@/features/auth/components/setup-workspace-form.tsx";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import APP_ROUTE from "@/lib/app-route.ts";
|
import APP_ROUTE from "@/lib/app-route.ts";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function SetupWorkspace() {
|
export default function SetupWorkspace() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -34,7 +35,11 @@ export default function SetupWorkspace() {
|
|||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Setup Workspace")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Setup Workspace")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<SetupWorkspaceForm />
|
<SetupWorkspaceForm />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,15 +2,20 @@ import { Container, Space } from "@mantine/core";
|
|||||||
import HomeTabs from "@/features/home/components/home-tabs";
|
import HomeTabs from "@/features/home/components/home-tabs";
|
||||||
import HomeAiPrompt from "@/features/home/components/home-ai-prompt";
|
import HomeAiPrompt from "@/features/home/components/home-ai-prompt";
|
||||||
import SpaceCarousel from "@/features/space/components/space-carousel.tsx";
|
import SpaceCarousel from "@/features/space/components/space-carousel.tsx";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Home")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Home")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<Container size={"900"} pt="xl">
|
<Container size={"900"} pt="xl">
|
||||||
<HomeAiPrompt />
|
<HomeAiPrompt />
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ import {
|
|||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { Link, useParams } from "react-router-dom";
|
import { Link, useParams } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useDebouncedValue } from "@mantine/hooks";
|
import { useDebouncedValue } from "@mantine/hooks";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
import { useLabelPagesQuery } from "@/features/label/queries/label-query.ts";
|
import { useLabelPagesQuery } from "@/features/label/queries/label-query.ts";
|
||||||
import { useGetSpacesQuery } from "@/features/space/queries/space-query.ts";
|
import { useGetSpacesQuery } from "@/features/space/queries/space-query.ts";
|
||||||
import { getLabelColor } from "@/features/label/utils/label-colors.ts";
|
import { getLabelColor } from "@/features/label/utils/label-colors.ts";
|
||||||
@@ -27,7 +29,6 @@ import { normalizeLabelName } from "@/features/label/utils/normalize-label.ts";
|
|||||||
import { SpaceFilterMenu } from "@/features/space/components/space-filter-menu.tsx";
|
import { SpaceFilterMenu } from "@/features/space/components/space-filter-menu.tsx";
|
||||||
import { EmptyState } from "@/components/ui/empty-state";
|
import { EmptyState } from "@/components/ui/empty-state";
|
||||||
import classes from "@/features/label/label.module.css";
|
import classes from "@/features/label/label.module.css";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function LabelPage() {
|
export default function LabelPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -81,7 +82,11 @@ export default function LabelPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={labelName} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{labelName} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
<Container size={820} py="xl">
|
<Container size={820} py="xl">
|
||||||
<Stack gap="lg">
|
<Stack gap="lg">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { usePageQuery } from "@/features/page/queries/page-query";
|
|||||||
import { FullEditor } from "@/features/editor/full-editor";
|
import { FullEditor } from "@/features/editor/full-editor";
|
||||||
import { TitleEditor } from "@/features/editor/title-editor";
|
import { TitleEditor } from "@/features/editor/title-editor";
|
||||||
import HistoryModal from "@/features/page-history/components/history-modal";
|
import HistoryModal from "@/features/page-history/components/history-modal";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import PageHeader from "@/features/page/components/header/page-header.tsx";
|
import PageHeader from "@/features/page/components/header/page-header.tsx";
|
||||||
import { extractPageSlugId } from "@/lib";
|
import { extractPageSlugId } from "@/lib";
|
||||||
import { useGetSpaceBySlugQuery } from "@/features/space/queries/space-query.ts";
|
import { useGetSpaceBySlugQuery } from "@/features/space/queries/space-query.ts";
|
||||||
@@ -17,7 +18,6 @@ import { BaseView } from "@/ee/base/components/base-view";
|
|||||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||||
import { Feature } from "@/ee/features";
|
import { Feature } from "@/ee/features";
|
||||||
import { getPageTitle } from "@/features/page/page.utils";
|
import { getPageTitle } from "@/features/page/page.utils";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
const MemoizedFullEditor = React.memo(FullEditor);
|
const MemoizedFullEditor = React.memo(FullEditor);
|
||||||
const MemoizedTitleEditor = React.memo(TitleEditor);
|
const MemoizedTitleEditor = React.memo(TitleEditor);
|
||||||
const MemoizedPageHeader = React.memo(PageHeader);
|
const MemoizedPageHeader = React.memo(PageHeader);
|
||||||
@@ -110,10 +110,9 @@ function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
|||||||
paddingTop: "calc(var(--page-header-height) + 6px)",
|
paddingTop: "calc(var(--page-header-height) + 6px)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DocumentTitle
|
<Helmet>
|
||||||
title={`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}
|
<title>{`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}</title>
|
||||||
withAppName={false}
|
</Helmet>
|
||||||
/>
|
|
||||||
<MemoizedPageHeader readOnly={!canEdit} />
|
<MemoizedPageHeader readOnly={!canEdit} />
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -160,10 +159,9 @@ function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
|||||||
return (
|
return (
|
||||||
page && (
|
page && (
|
||||||
<div>
|
<div>
|
||||||
<DocumentTitle
|
<Helmet>
|
||||||
title={`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}
|
<title>{`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}</title>
|
||||||
withAppName={false}
|
</Helmet>
|
||||||
/>
|
|
||||||
|
|
||||||
<MemoizedPageHeader readOnly={!canEdit} />
|
<MemoizedPageHeader readOnly={!canEdit} />
|
||||||
|
|
||||||
|
|||||||
@@ -5,16 +5,21 @@ import PageWidthPref from "@/features/user/components/page-width-pref.tsx";
|
|||||||
import PageEditPref from "@/features/user/components/page-state-pref";
|
import PageEditPref from "@/features/user/components/page-state-pref";
|
||||||
import FixedToolbarPref from "@/features/user/components/fixed-toolbar-pref";
|
import FixedToolbarPref from "@/features/user/components/fixed-toolbar-pref";
|
||||||
import NotificationPref from "@/features/user/components/notification-pref";
|
import NotificationPref from "@/features/user/components/notification-pref";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import { Divider } from "@mantine/core";
|
import { Divider } from "@mantine/core";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function AccountPreferences() {
|
export default function AccountPreferences() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Preferences")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Preferences")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title={t("Preferences")} />
|
<SettingsTitle title={t("Preferences")} />
|
||||||
|
|
||||||
<AccountTheme />
|
<AccountTheme />
|
||||||
|
|||||||
@@ -4,17 +4,22 @@ import ChangePassword from "@/features/user/components/change-password";
|
|||||||
import { Divider } from "@mantine/core";
|
import { Divider } from "@mantine/core";
|
||||||
import AccountAvatar from "@/features/user/components/account-avatar";
|
import AccountAvatar from "@/features/user/components/account-avatar";
|
||||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { AccountMfaSection } from "@/features/user/components/account-mfa-section";
|
import { AccountMfaSection } from "@/features/user/components/account-mfa-section";
|
||||||
import SessionList from "@/features/session/components/session-list";
|
import SessionList from "@/features/session/components/session-list";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function AccountSettings() {
|
export default function AccountSettings() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("My Profile")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("My Profile")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title={t("My Profile")} />
|
<SettingsTitle title={t("My Profile")} />
|
||||||
|
|
||||||
<AccountAvatar />
|
<AccountAvatar />
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||||
import GroupMembersList from "@/features/group/components/group-members";
|
import GroupMembersList from "@/features/group/components/group-members";
|
||||||
import GroupDetails from "@/features/group/components/group-details";
|
import GroupDetails from "@/features/group/components/group-details";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function GroupInfo() {
|
export default function GroupInfo() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Manage Group")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Manage Group")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title={t("Manage Group")} />
|
<SettingsTitle title={t("Manage Group")} />
|
||||||
<GroupDetails />
|
<GroupDetails />
|
||||||
<GroupMembersList />
|
<GroupMembersList />
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import SettingsTitle from "@/components/settings/settings-title.tsx";
|
|||||||
import { Group } from "@mantine/core";
|
import { Group } from "@mantine/core";
|
||||||
import CreateGroupModal from "@/features/group/components/create-group-modal";
|
import CreateGroupModal from "@/features/group/components/create-group-modal";
|
||||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
|
import {getAppName} from "@/lib/config.ts";
|
||||||
|
import {Helmet} from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function Groups() {
|
export default function Groups() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -12,7 +13,9 @@ export default function Groups() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Groups")} />
|
<Helmet>
|
||||||
|
<title>{t("Groups")} - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title={t("Groups")} />
|
<SettingsTitle title={t("Groups")} />
|
||||||
|
|
||||||
<Group my="md" justify="flex-end">
|
<Group my="md" justify="flex-end">
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import ShareList from "@/features/share/components/share-list.tsx";
|
import ShareList from "@/features/share/components/share-list.tsx";
|
||||||
import { Alert, Text } from "@mantine/core";
|
import { Alert, Text } from "@mantine/core";
|
||||||
import { IconInfoCircle } from "@tabler/icons-react";
|
import { IconInfoCircle } from "@tabler/icons-react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function Shares() {
|
export default function Shares() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Public sharing")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Public sharing")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title={t("Public sharing")} />
|
<SettingsTitle title={t("Public sharing")} />
|
||||||
|
|
||||||
<Alert variant="light" color="blue" icon={<IconInfoCircle />}>
|
<Alert variant="light" color="blue" icon={<IconInfoCircle />}>
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import SpaceList from "@/features/space/components/space-list.tsx";
|
|||||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
import { Group } from "@mantine/core";
|
import { Group } from "@mantine/core";
|
||||||
import CreateSpaceModal from "@/features/space/components/create-space-modal.tsx";
|
import CreateSpaceModal from "@/features/space/components/create-space-modal.tsx";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function Spaces() {
|
export default function Spaces() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -12,7 +13,11 @@ export default function Spaces() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Spaces")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Spaces")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title={t("Spaces")} />
|
<SettingsTitle title={t("Spaces")} />
|
||||||
|
|
||||||
<Group my="md" justify="flex-end">
|
<Group my="md" justify="flex-end">
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ import { useEffect, useState } from "react";
|
|||||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||||
import WorkspaceInvitesTable from "@/features/workspace/components/members/components/workspace-invites-table.tsx";
|
import WorkspaceInvitesTable from "@/features/workspace/components/members/components/workspace-invites-table.tsx";
|
||||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
|
import { getAppName } from "@/lib/config.ts";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function WorkspaceMembers() {
|
export default function WorkspaceMembers() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -37,7 +38,11 @@ export default function WorkspaceMembers() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Members")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Members")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title={t("Members")} />
|
<SettingsTitle title={t("Members")} />
|
||||||
|
|
||||||
{/* <WorkspaceInviteSection /> */}
|
{/* <WorkspaceInviteSection /> */}
|
||||||
|
|||||||
@@ -2,19 +2,21 @@ import SettingsTitle from "@/components/settings/settings-title.tsx";
|
|||||||
import WorkspaceNameForm from "@/features/workspace/components/settings/components/workspace-name-form";
|
import WorkspaceNameForm from "@/features/workspace/components/settings/components/workspace-name-form";
|
||||||
import WorkspaceIcon from "@/features/workspace/components/settings/components/workspace-icon.tsx";
|
import WorkspaceIcon from "@/features/workspace/components/settings/components/workspace-icon.tsx";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { isCloud } from "@/lib/config.ts";
|
import { getAppName, isCloud } from "@/lib/config.ts";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import ManageHostname from "@/ee/components/manage-hostname.tsx";
|
import ManageHostname from "@/ee/components/manage-hostname.tsx";
|
||||||
import { Divider } from "@mantine/core";
|
import { Divider } from "@mantine/core";
|
||||||
import AllowMemberTemplates from "@/ee/security/components/allow-member-templates.tsx";
|
import AllowMemberTemplates from "@/ee/security/components/allow-member-templates.tsx";
|
||||||
import WorkspaceDefaultPageEditMode from "@/features/workspace/components/settings/components/workspace-default-page-edit-mode.tsx";
|
import WorkspaceDefaultPageEditMode from "@/features/workspace/components/settings/components/workspace-default-page-edit-mode.tsx";
|
||||||
import PersonalSpacesSetting from "@/ee/personal-space/components/personal-spaces-setting.tsx";
|
import PersonalSpacesSetting from "@/ee/personal-space/components/personal-spaces-setting.tsx";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function WorkspaceSettings() {
|
export default function WorkspaceSettings() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title="Workspace Settings" />
|
<Helmet>
|
||||||
|
<title>Workspace Settings - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
<SettingsTitle title={t("General")} />
|
<SettingsTitle title={t("General")} />
|
||||||
<WorkspaceIcon />
|
<WorkspaceIcon />
|
||||||
<WorkspaceNameForm />
|
<WorkspaceNameForm />
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useSharePageQuery } from "@/features/share/queries/share-query.ts";
|
import { useSharePageQuery } from "@/features/share/queries/share-query.ts";
|
||||||
import { Container } from "@mantine/core";
|
import { Container } from "@mantine/core";
|
||||||
@@ -13,7 +14,6 @@ import {
|
|||||||
sharedTreeDataAtom,
|
sharedTreeDataAtom,
|
||||||
} from "@/features/share/atoms/shared-page-atom.ts";
|
} from "@/features/share/atoms/shared-page-atom.ts";
|
||||||
import { isPageInTree } from "@/features/share/utils.ts";
|
import { isPageInTree } from "@/features/share/utils.ts";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function SharedPage() {
|
export default function SharedPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -56,14 +56,12 @@ export default function SharedPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<DocumentTitle
|
<Helmet>
|
||||||
title={data?.page?.title || t("untitled")}
|
<title>{`${data?.page?.title || t("untitled")}`}</title>
|
||||||
withAppName={false}
|
|
||||||
>
|
|
||||||
{!data?.share.searchIndexing && (
|
{!data?.share.searchIndexing && (
|
||||||
<meta name="robots" content="noindex" />
|
<meta name="robots" content="noindex" />
|
||||||
)}
|
)}
|
||||||
</DocumentTitle>
|
</Helmet>
|
||||||
|
|
||||||
<Container fluid={fullWidth} size={fullWidth ? undefined : 900} p={0}>
|
<Container fluid={fullWidth} size={fullWidth ? undefined : 900} p={0}>
|
||||||
<ReadonlyPageEditor
|
<ReadonlyPageEditor
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import {Container} from "@mantine/core";
|
|||||||
import SpaceHomeTabs from "@/features/space/components/space-home-tabs.tsx";
|
import SpaceHomeTabs from "@/features/space/components/space-home-tabs.tsx";
|
||||||
import {useParams} from "react-router-dom";
|
import {useParams} from "react-router-dom";
|
||||||
import {useGetSpaceBySlugQuery} from "@/features/space/queries/space-query.ts";
|
import {useGetSpaceBySlugQuery} from "@/features/space/queries/space-query.ts";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
import {getAppName} from "@/lib/config.ts";
|
||||||
|
import {Helmet} from "react-helmet-async";
|
||||||
|
|
||||||
export default function SpaceHome() {
|
export default function SpaceHome() {
|
||||||
const {spaceSlug} = useParams();
|
const {spaceSlug} = useParams();
|
||||||
@@ -10,7 +11,9 @@ export default function SpaceHome() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={space?.name || 'Overview'} />
|
<Helmet>
|
||||||
|
<title>{space?.name || 'Overview'} - {getAppName()}</title>
|
||||||
|
</Helmet>
|
||||||
<Container size={"900"} pt="xl">
|
<Container size={"900"} pt="xl">
|
||||||
{space && <SpaceHomeTabs/>}
|
{space && <SpaceHomeTabs/>}
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { Container, Title, Text, Group, Box } from "@mantine/core";
|
import { Container, Title, Text, Group, Box } from "@mantine/core";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
||||||
import CreateSpaceModal from "@/features/space/components/create-space-modal";
|
import CreateSpaceModal from "@/features/space/components/create-space-modal";
|
||||||
import { AllSpacesList } from "@/features/space/components/spaces-page";
|
import { AllSpacesList } from "@/features/space/components/spaces-page";
|
||||||
import FavoriteSpacesGrid from "@/features/space/components/spaces-page/favorite-spaces-grid";
|
import FavoriteSpacesGrid from "@/features/space/components/spaces-page/favorite-spaces-grid";
|
||||||
import { usePaginateAndSearch } from "@/hooks/use-paginate-and-search";
|
import { usePaginateAndSearch } from "@/hooks/use-paginate-and-search";
|
||||||
import useUserRole from "@/hooks/use-user-role";
|
import useUserRole from "@/hooks/use-user-role";
|
||||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
||||||
|
|
||||||
export default function Spaces() {
|
export default function Spaces() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -21,7 +22,11 @@ export default function Spaces() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DocumentTitle title={t("Spaces")} />
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Spaces")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
<Container size={"800"} pt="xl">
|
<Container size={"800"} pt="xl">
|
||||||
<Group justify="space-between" mb="xl">
|
<Group justify="space-between" mb="xl">
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ export default defineConfig(({ mode }) => {
|
|||||||
BILLING_TRIAL_DAYS,
|
BILLING_TRIAL_DAYS,
|
||||||
POSTHOG_HOST,
|
POSTHOG_HOST,
|
||||||
POSTHOG_KEY,
|
POSTHOG_KEY,
|
||||||
AI_VECTOR_DRIVER,
|
|
||||||
} = loadEnv(mode, envPath, "");
|
} = loadEnv(mode, envPath, "");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -32,7 +31,6 @@ export default defineConfig(({ mode }) => {
|
|||||||
BILLING_TRIAL_DAYS,
|
BILLING_TRIAL_DAYS,
|
||||||
POSTHOG_HOST,
|
POSTHOG_HOST,
|
||||||
POSTHOG_KEY,
|
POSTHOG_KEY,
|
||||||
AI_VECTOR_DRIVER,
|
|
||||||
},
|
},
|
||||||
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
||||||
},
|
},
|
||||||
|
|||||||
+17
-18
@@ -40,33 +40,32 @@
|
|||||||
"@clickhouse/client": "1.18.2",
|
"@clickhouse/client": "1.18.2",
|
||||||
"@docmost/base-formula": "workspace:*",
|
"@docmost/base-formula": "workspace:*",
|
||||||
"@docmost/pdf-inspector": "1.9.6",
|
"@docmost/pdf-inspector": "1.9.6",
|
||||||
"@fastify/cookie": "11.1.2",
|
"@fastify/cookie": "^11.0.2",
|
||||||
"@fastify/multipart": "10.1.1",
|
"@fastify/multipart": "^10.0.0",
|
||||||
"@fastify/static": "10.1.3",
|
"@fastify/static": "^9.1.3",
|
||||||
"@keyv/redis": "5.1.6",
|
"@keyv/redis": "^5.1.6",
|
||||||
"@langchain/core": "1.1.46",
|
"@langchain/core": "1.1.46",
|
||||||
"@langchain/textsplitters": "1.0.1",
|
"@langchain/textsplitters": "1.0.1",
|
||||||
"@modelcontextprotocol/sdk": "1.30.0",
|
"@modelcontextprotocol/sdk": "1.29.0",
|
||||||
"@nest-lab/throttler-storage-redis": "1.2.0",
|
"@nest-lab/throttler-storage-redis": "^1.2.0",
|
||||||
"@nestjs-labs/nestjs-ioredis": "11.0.4",
|
"@nestjs-labs/nestjs-ioredis": "11.0.4",
|
||||||
"@nestjs/bullmq": "11.0.5",
|
"@nestjs/bullmq": "11.0.4",
|
||||||
"@nestjs/cache-manager": "3.1.3",
|
"@nestjs/cache-manager": "3.1.3",
|
||||||
"@nestjs/common": "11.2.1",
|
"@nestjs/common": "11.1.27",
|
||||||
"@nestjs/config": "4.0.4",
|
"@nestjs/config": "4.0.4",
|
||||||
"@nestjs/core": "11.2.1",
|
"@nestjs/core": "11.1.27",
|
||||||
"@nestjs/event-emitter": "3.1.0",
|
"@nestjs/event-emitter": "3.1.0",
|
||||||
"@nestjs/jwt": "11.0.2",
|
"@nestjs/jwt": "11.0.2",
|
||||||
"@nestjs/mapped-types": "2.1.1",
|
"@nestjs/mapped-types": "2.1.1",
|
||||||
"@nestjs/passport": "11.0.5",
|
"@nestjs/passport": "11.0.5",
|
||||||
"@nestjs/platform-fastify": "11.2.1",
|
"@nestjs/platform-fastify": "11.1.27",
|
||||||
"@nestjs/platform-socket.io": "11.2.1",
|
"@nestjs/platform-socket.io": "11.1.27",
|
||||||
"@nestjs/schedule": "6.1.3",
|
"@nestjs/schedule": "6.1.3",
|
||||||
"@nestjs/terminus": "11.1.1",
|
"@nestjs/terminus": "11.1.1",
|
||||||
"@nestjs/throttler": "6.5.0",
|
"@nestjs/throttler": "6.5.0",
|
||||||
"@nestjs/websockets": "11.2.1",
|
"@nestjs/websockets": "11.1.27",
|
||||||
"@node-saml/passport-saml": "5.1.0",
|
"@node-saml/passport-saml": "5.1.0",
|
||||||
"@socket.io/redis-adapter": "8.3.0",
|
"@socket.io/redis-adapter": "8.3.0",
|
||||||
"@turbopuffer/turbopuffer": "^2.8.0",
|
|
||||||
"ai": "6.0.134",
|
"ai": "6.0.134",
|
||||||
"ai-sdk-ollama": "3.8.1",
|
"ai-sdk-ollama": "3.8.1",
|
||||||
"bcrypt": "6.0.0",
|
"bcrypt": "6.0.0",
|
||||||
@@ -91,8 +90,8 @@
|
|||||||
"ldapts": "8.1.7",
|
"ldapts": "8.1.7",
|
||||||
"mammoth": "1.12.0",
|
"mammoth": "1.12.0",
|
||||||
"mime-types": "3.0.2",
|
"mime-types": "3.0.2",
|
||||||
"msgpackr": "1.11.9",
|
"msgpackr": "^1.11.9",
|
||||||
"nanoid": "5.1.16",
|
"nanoid": "5.1.7",
|
||||||
"nestjs-cls": "6.2.0",
|
"nestjs-cls": "6.2.0",
|
||||||
"nestjs-kysely": "3.1.2",
|
"nestjs-kysely": "3.1.2",
|
||||||
"nestjs-pino": "4.6.1",
|
"nestjs-pino": "4.6.1",
|
||||||
@@ -103,7 +102,7 @@
|
|||||||
"passport-google-oauth20": "2.0.0",
|
"passport-google-oauth20": "2.0.0",
|
||||||
"passport-jwt": "4.0.1",
|
"passport-jwt": "4.0.1",
|
||||||
"pg-tsquery": "8.4.2",
|
"pg-tsquery": "8.4.2",
|
||||||
"pgvector": "0.2.1",
|
"pgvector": "^0.2.1",
|
||||||
"pino-http": "11.0.0",
|
"pino-http": "11.0.0",
|
||||||
"pino-pretty": "13.1.3",
|
"pino-pretty": "13.1.3",
|
||||||
"postgres": "3.4.8",
|
"postgres": "3.4.8",
|
||||||
@@ -119,8 +118,8 @@
|
|||||||
"tlds": "1.261.0",
|
"tlds": "1.261.0",
|
||||||
"tmp-promise": "3.0.3",
|
"tmp-promise": "3.0.3",
|
||||||
"typesense": "3.0.5",
|
"typesense": "3.0.5",
|
||||||
"undici": "7.29.0",
|
"undici": "7.28.0",
|
||||||
"ws": "8.21.3",
|
"ws": "8.21.0",
|
||||||
"yauzl": "3.4.0",
|
"yauzl": "3.4.0",
|
||||||
"zod": "4.3.6"
|
"zod": "4.3.6"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,13 +22,11 @@ import { TelemetryModule } from './integrations/telemetry/telemetry.module';
|
|||||||
import { RedisModule } from '@nestjs-labs/nestjs-ioredis';
|
import { RedisModule } from '@nestjs-labs/nestjs-ioredis';
|
||||||
import { RedisConfigService } from './integrations/redis/redis-config.service';
|
import { RedisConfigService } from './integrations/redis/redis-config.service';
|
||||||
import { CacheModule } from '@nestjs/cache-manager';
|
import { CacheModule } from '@nestjs/cache-manager';
|
||||||
import KeyvRedis, { defaultReconnectStrategy } from '@keyv/redis';
|
import KeyvRedis from '@keyv/redis';
|
||||||
import { parseRedisUrl } from './common/helpers';
|
|
||||||
import { LoggerModule } from './common/logger/logger.module';
|
import { LoggerModule } from './common/logger/logger.module';
|
||||||
import { ClsModule } from 'nestjs-cls';
|
import { ClsModule } from 'nestjs-cls';
|
||||||
import { NoopAuditModule } from './integrations/audit/audit.module';
|
import { NoopAuditModule } from './integrations/audit/audit.module';
|
||||||
import { ThrottleModule } from './integrations/throttle/throttle.module';
|
import { ThrottleModule } from './integrations/throttle/throttle.module';
|
||||||
import { EncryptionModule } from './integrations/encryption/encryption.module';
|
|
||||||
|
|
||||||
const enterpriseModules = [];
|
const enterpriseModules = [];
|
||||||
try {
|
try {
|
||||||
@@ -55,7 +53,6 @@ try {
|
|||||||
CoreModule,
|
CoreModule,
|
||||||
DatabaseModule,
|
DatabaseModule,
|
||||||
EnvironmentModule,
|
EnvironmentModule,
|
||||||
EncryptionModule,
|
|
||||||
RedisModule.forRootAsync({
|
RedisModule.forRootAsync({
|
||||||
useClass: RedisConfigService,
|
useClass: RedisConfigService,
|
||||||
}),
|
}),
|
||||||
@@ -63,20 +60,10 @@ try {
|
|||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
useFactory: async (environmentService: EnvironmentService) => {
|
useFactory: async (environmentService: EnvironmentService) => {
|
||||||
const redisUrl = environmentService.getRedisUrl();
|
const redisUrl = environmentService.getRedisUrl();
|
||||||
const { family, tls } = parseRedisUrl(redisUrl);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ttl: 5 * 1000,
|
ttl: 5 * 1000,
|
||||||
stores: [
|
stores: [new KeyvRedis(redisUrl)],
|
||||||
new KeyvRedis({
|
|
||||||
url: redisUrl,
|
|
||||||
socket: {
|
|
||||||
family,
|
|
||||||
reconnectStrategy: defaultReconnectStrategy,
|
|
||||||
...tls,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
inject: [EnvironmentService],
|
inject: [EnvironmentService],
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ export class CollaborationGateway {
|
|||||||
password: this.redisConfig.password,
|
password: this.redisConfig.password,
|
||||||
db: this.redisConfig.db,
|
db: this.redisConfig.db,
|
||||||
family: this.redisConfig.family,
|
family: this.redisConfig.family,
|
||||||
tls: this.redisConfig.tls,
|
|
||||||
retryStrategy: createRetryStrategy(),
|
retryStrategy: createRetryStrategy(),
|
||||||
}),
|
}),
|
||||||
serverId: `collab-${os?.hostname()}-${nanoid(10)}`,
|
serverId: `collab-${os?.hostname()}-${nanoid(10)}`,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { StarterKit } from '@tiptap/starter-kit';
|
import { StarterKit } from '@tiptap/starter-kit';
|
||||||
import { Document } from '@tiptap/extension-document';
|
|
||||||
import { TextAlign } from '@tiptap/extension-text-align';
|
import { TextAlign } from '@tiptap/extension-text-align';
|
||||||
import { Superscript } from '@tiptap/extension-superscript';
|
import { Superscript } from '@tiptap/extension-superscript';
|
||||||
import SubScript from '@tiptap/extension-subscript';
|
import SubScript from '@tiptap/extension-subscript';
|
||||||
@@ -46,18 +45,13 @@ import {
|
|||||||
TransclusionSource,
|
TransclusionSource,
|
||||||
TransclusionReference,
|
TransclusionReference,
|
||||||
BaseEmbed,
|
BaseEmbed,
|
||||||
Footnotes,
|
Tabs,
|
||||||
Footnote,
|
Tab,
|
||||||
FootnoteReference,
|
TabLabel,
|
||||||
|
TabPanel,
|
||||||
} from '@docmost/editor-ext';
|
} from '@docmost/editor-ext';
|
||||||
import {
|
import { generateText, getSchema, JSONContent } from '@tiptap/core';
|
||||||
extensions as coreExtensions,
|
|
||||||
generateText,
|
|
||||||
getSchema,
|
|
||||||
JSONContent,
|
|
||||||
} from '@tiptap/core';
|
|
||||||
import { generateHTML, generateJSON } from '../common/helpers/prosemirror/html';
|
import { generateHTML, generateJSON } from '../common/helpers/prosemirror/html';
|
||||||
import { collapseBlankLines } from '../common/helpers';
|
|
||||||
// @tiptap/html library works best for generating prosemirror json state but not HTML
|
// @tiptap/html library works best for generating prosemirror json state but not HTML
|
||||||
// see: https://github.com/ueberdosis/tiptap/issues/5352
|
// see: https://github.com/ueberdosis/tiptap/issues/5352
|
||||||
// see:https://github.com/ueberdosis/tiptap/issues/4089
|
// see:https://github.com/ueberdosis/tiptap/issues/4089
|
||||||
@@ -67,17 +61,12 @@ import * as Y from 'yjs';
|
|||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
|
|
||||||
export const tiptapExtensions = [
|
export const tiptapExtensions = [
|
||||||
coreExtensions.TextDirection.configure({ direction: 'auto' }),
|
|
||||||
StarterKit.configure({
|
StarterKit.configure({
|
||||||
document: false,
|
|
||||||
codeBlock: false,
|
codeBlock: false,
|
||||||
link: false,
|
link: false,
|
||||||
trailingNode: false,
|
trailingNode: false,
|
||||||
heading: false,
|
heading: false,
|
||||||
}),
|
}),
|
||||||
Document.extend({
|
|
||||||
content: 'block+ footnotes?',
|
|
||||||
}),
|
|
||||||
Heading,
|
Heading,
|
||||||
UniqueID.configure({
|
UniqueID.configure({
|
||||||
types: ['heading', 'paragraph', 'transclusionSource'],
|
types: ['heading', 'paragraph', 'transclusionSource'],
|
||||||
@@ -102,6 +91,10 @@ export const tiptapExtensions = [
|
|||||||
Details,
|
Details,
|
||||||
DetailsContent,
|
DetailsContent,
|
||||||
DetailsSummary,
|
DetailsSummary,
|
||||||
|
Tabs,
|
||||||
|
Tab,
|
||||||
|
TabLabel,
|
||||||
|
TabPanel,
|
||||||
CustomTable,
|
CustomTable,
|
||||||
TableCell,
|
TableCell,
|
||||||
TableRow,
|
TableRow,
|
||||||
@@ -125,10 +118,7 @@ export const tiptapExtensions = [
|
|||||||
Status,
|
Status,
|
||||||
TransclusionSource,
|
TransclusionSource,
|
||||||
TransclusionReference,
|
TransclusionReference,
|
||||||
BaseEmbed,
|
BaseEmbed
|
||||||
Footnotes,
|
|
||||||
Footnote,
|
|
||||||
FootnoteReference,
|
|
||||||
] as any;
|
] as any;
|
||||||
|
|
||||||
export function jsonToHtml(tiptapJson: any) {
|
export function jsonToHtml(tiptapJson: any) {
|
||||||
@@ -147,7 +137,7 @@ export function htmlToJson(html: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function jsonToText(tiptapJson: JSONContent) {
|
export function jsonToText(tiptapJson: JSONContent) {
|
||||||
return collapseBlankLines(generateText(tiptapJson, tiptapExtensions));
|
return generateText(tiptapJson, tiptapExtensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function jsonToNode(tiptapJson: JSONContent) {
|
export function jsonToNode(tiptapJson: JSONContent) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
export * from './utils';
|
export * from './utils';
|
||||||
export * from './text.utils';
|
|
||||||
export * from './nanoid.utils';
|
export * from './nanoid.utils';
|
||||||
export * from './file.helper';
|
export * from './file.helper';
|
||||||
export * from './constants';
|
export * from './constants';
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
import { collapseBlankLines } from './text.utils';
|
|
||||||
|
|
||||||
describe('collapseBlankLines', () => {
|
|
||||||
it.each([
|
|
||||||
['a\n\n\n\nb', 'a\n\nb'],
|
|
||||||
['a\n\nb', 'a\n\nb'],
|
|
||||||
['a\nb', 'a\nb'],
|
|
||||||
['\n\n\n\na\n\n\n', '\n\na\n\n'],
|
|
||||||
['no newlines', 'no newlines'],
|
|
||||||
['', ''],
|
|
||||||
])('collapses %j to %j', (input, expected) => {
|
|
||||||
expect(collapseBlankLines(input)).toBe(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export function collapseBlankLines(text: string): string {
|
|
||||||
return text.replace(/\n{2,}/g, '\n\n');
|
|
||||||
}
|
|
||||||
@@ -30,14 +30,13 @@ export type RedisConfig = {
|
|||||||
db: number;
|
db: number;
|
||||||
password?: string;
|
password?: string;
|
||||||
family?: number;
|
family?: number;
|
||||||
tls?: { rejectUnauthorized?: boolean };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function parseRedisUrl(redisUrl: string): RedisConfig {
|
export function parseRedisUrl(redisUrl: string): RedisConfig {
|
||||||
// format - redis[s]://[[username][:password]@][host][:port][/db-number][?family=4|6][&rejectUnauthorized=false]
|
// format - redis[s]://[[username][:password]@][host][:port][/db-number][?family=4|6]
|
||||||
const url = new URL(redisUrl);
|
const url = new URL(redisUrl);
|
||||||
const { hostname, port, password, pathname, protocol, searchParams } = url;
|
const { hostname, port, password, pathname, searchParams } = url;
|
||||||
const portInt = port ? parseInt(port, 10) : 6379;
|
const portInt = parseInt(port, 10);
|
||||||
|
|
||||||
let db: number = 0;
|
let db: number = 0;
|
||||||
// extract db value if present
|
// extract db value if present
|
||||||
@@ -55,14 +54,7 @@ export function parseRedisUrl(redisUrl: string): RedisConfig {
|
|||||||
family = parseInt(familyParam, 10);
|
family = parseInt(familyParam, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tls =
|
return { host: hostname, port: portInt, password, db, family };
|
||||||
protocol === 'rediss:'
|
|
||||||
? searchParams.get('rejectUnauthorized') === 'false'
|
|
||||||
? { rejectUnauthorized: false }
|
|
||||||
: {}
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
return { host: hostname, port: portInt, password: password || undefined, db, family, tls };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createRetryStrategy() {
|
export function createRetryStrategy() {
|
||||||
|
|||||||
@@ -53,14 +53,8 @@ import { EnvironmentService } from '../../integrations/environment/environment.s
|
|||||||
import { TokenService } from '../auth/services/token.service';
|
import { TokenService } from '../auth/services/token.service';
|
||||||
import { JwtAttachmentPayload, JwtType } from '../auth/dto/jwt-payload';
|
import { JwtAttachmentPayload, JwtType } from '../auth/dto/jwt-payload';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {
|
import { AttachmentInfoDto, RemoveIconDto } from './dto/attachment.dto';
|
||||||
AttachmentInfoDto,
|
|
||||||
PageIdDto,
|
|
||||||
RemoveIconDto,
|
|
||||||
} from './dto/attachment.dto';
|
|
||||||
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
|
||||||
import { PageAccessService } from '../page/page-access/page-access.service';
|
import { PageAccessService } from '../page/page-access/page-access.service';
|
||||||
import { DomainService } from '../../integrations/environment/domain.service';
|
|
||||||
import { AuditEvent, AuditResource } from '../../common/events/audit-events';
|
import { AuditEvent, AuditResource } from '../../common/events/audit-events';
|
||||||
import {
|
import {
|
||||||
AUDIT_SERVICE,
|
AUDIT_SERVICE,
|
||||||
@@ -81,7 +75,6 @@ export class AttachmentController {
|
|||||||
private readonly environmentService: EnvironmentService,
|
private readonly environmentService: EnvironmentService,
|
||||||
private readonly tokenService: TokenService,
|
private readonly tokenService: TokenService,
|
||||||
private readonly pageAccessService: PageAccessService,
|
private readonly pageAccessService: PageAccessService,
|
||||||
private readonly domainService: DomainService,
|
|
||||||
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -158,10 +151,7 @@ export class AttachmentController {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.send({
|
return res.send(fileResponse);
|
||||||
...fileResponse,
|
|
||||||
url: this.buildFileUrl(workspace, fileResponse),
|
|
||||||
});
|
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err?.statusCode === 413) {
|
if (err?.statusCode === 413) {
|
||||||
const errMessage = `File too large. Exceeds the ${this.environmentService.getFileUploadSizeLimit()} limit`;
|
const errMessage = `File too large. Exceeds the ${this.environmentService.getFileUploadSizeLimit()} limit`;
|
||||||
@@ -421,37 +411,7 @@ export class AttachmentController {
|
|||||||
|
|
||||||
await this.pageAccessService.validateCanView(page, user);
|
await this.pageAccessService.validateCanView(page, user);
|
||||||
|
|
||||||
return { ...attachment, url: this.buildFileUrl(workspace, attachment) };
|
return attachment;
|
||||||
}
|
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard)
|
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
@Post('pages/attachments')
|
|
||||||
async getPageAttachments(
|
|
||||||
@Body() dto: PageIdDto,
|
|
||||||
@Body() pagination: PaginationOptions,
|
|
||||||
@AuthUser() user: User,
|
|
||||||
@AuthWorkspace() workspace: Workspace,
|
|
||||||
) {
|
|
||||||
const page = await this.pageRepo.findById(dto.pageId);
|
|
||||||
if (!page || page.workspaceId !== workspace.id) {
|
|
||||||
throw new NotFoundException('Page not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.pageAccessService.validateCanView(page, user);
|
|
||||||
|
|
||||||
const result = await this.attachmentRepo.findPageAttachments(
|
|
||||||
page.id,
|
|
||||||
pagination,
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...result,
|
|
||||||
items: result.items.map((attachment) => ({
|
|
||||||
...attachment,
|
|
||||||
url: this.buildFileUrl(workspace, attachment),
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@@ -505,10 +465,6 @@ export class AttachmentController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildFileUrl(workspace: Workspace, attachment: Attachment): string {
|
|
||||||
return `${this.domainService.getUrl(workspace.hostname)}/api/files/${attachment.id}/${encodeURIComponent(attachment.fileName)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async sendFileResponse(
|
private async sendFileResponse(
|
||||||
req: FastifyRequest,
|
req: FastifyRequest,
|
||||||
res: FastifyReply,
|
res: FastifyReply,
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
import {
|
import { IsEnum, IsIn, IsNotEmpty, IsOptional, IsUUID } from 'class-validator';
|
||||||
IsEnum,
|
|
||||||
IsIn,
|
|
||||||
IsNotEmpty,
|
|
||||||
IsOptional,
|
|
||||||
IsString,
|
|
||||||
IsUUID,
|
|
||||||
} from 'class-validator';
|
|
||||||
import { AttachmentType } from '../attachment.constants';
|
import { AttachmentType } from '../attachment.constants';
|
||||||
|
|
||||||
export class AttachmentInfoDto {
|
export class AttachmentInfoDto {
|
||||||
@@ -14,12 +7,6 @@ export class AttachmentInfoDto {
|
|||||||
attachmentId: string;
|
attachmentId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PageIdDto {
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
pageId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class RemoveIconDto {
|
export class RemoveIconDto {
|
||||||
@IsEnum(AttachmentType)
|
@IsEnum(AttachmentType)
|
||||||
@IsIn([
|
@IsIn([
|
||||||
|
|||||||
@@ -496,21 +496,10 @@ export class PageService {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.aiQueue.add(
|
await this.aiQueue.add(QueueJob.PAGE_MOVED_TO_SPACE, {
|
||||||
QueueJob.PAGE_MOVED_TO_SPACE,
|
pageIds: pageIdsToMove,
|
||||||
{
|
workspaceId: rootPage.workspaceId,
|
||||||
pageIds: pageIdsToMove,
|
});
|
||||||
spaceId,
|
|
||||||
workspaceId: rootPage.workspaceId,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
attempts: 2,
|
|
||||||
backoff: {
|
|
||||||
type: 'fixed',
|
|
||||||
delay: 2 * 60 * 1000,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -821,10 +810,6 @@ export class PageService {
|
|||||||
throw new BadRequestException('Invalid move position');
|
throw new BadRequestException('Invalid move position');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dto.parentPageId && dto.parentPageId === dto.pageId) {
|
|
||||||
throw new BadRequestException('A page cannot be its own parent');
|
|
||||||
}
|
|
||||||
|
|
||||||
let parentPageId = null;
|
let parentPageId = null;
|
||||||
if (movedPage.parentPageId === dto.parentPageId) {
|
if (movedPage.parentPageId === dto.parentPageId) {
|
||||||
parentPageId = undefined;
|
parentPageId = undefined;
|
||||||
|
|||||||
@@ -339,25 +339,15 @@ export class SpaceMemberService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await executeTx(this.db, async (trx) => {
|
if (spaceMember.role === SpaceRole.ADMIN) {
|
||||||
await trx
|
await this.validateLastAdmin(dto.spaceId);
|
||||||
.selectFrom('spaces')
|
}
|
||||||
.select('id')
|
|
||||||
.where('id', '=', dto.spaceId)
|
|
||||||
.forUpdate()
|
|
||||||
.executeTakeFirst();
|
|
||||||
|
|
||||||
if (spaceMember.role === SpaceRole.ADMIN) {
|
await this.spaceMemberRepo.updateSpaceMember(
|
||||||
await this.validateLastAdmin(dto.spaceId, trx);
|
{ role: dto.role },
|
||||||
}
|
spaceMember.id,
|
||||||
|
dto.spaceId,
|
||||||
await this.spaceMemberRepo.updateSpaceMember(
|
);
|
||||||
{ role: dto.role },
|
|
||||||
spaceMember.id,
|
|
||||||
dto.spaceId,
|
|
||||||
trx,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.auditService.log({
|
this.auditService.log({
|
||||||
event: AuditEvent.SPACE_MEMBER_ROLE_CHANGED,
|
event: AuditEvent.SPACE_MEMBER_ROLE_CHANGED,
|
||||||
@@ -378,14 +368,10 @@ export class SpaceMemberService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateLastAdmin(
|
async validateLastAdmin(spaceId: string): Promise<void> {
|
||||||
spaceId: string,
|
|
||||||
trx?: KyselyTransaction,
|
|
||||||
): Promise<void> {
|
|
||||||
const spaceOwnerCount = await this.spaceMemberRepo.roleCountBySpaceId(
|
const spaceOwnerCount = await this.spaceMemberRepo.roleCountBySpaceId(
|
||||||
SpaceRole.ADMIN,
|
SpaceRole.ADMIN,
|
||||||
spaceId,
|
spaceId,
|
||||||
trx,
|
|
||||||
);
|
);
|
||||||
if (spaceOwnerCount === 1) {
|
if (spaceOwnerCount === 1) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { EnvironmentService } from '../../integrations/environment/environment.s
|
|||||||
|
|
||||||
export class SpaceEvent {
|
export class SpaceEvent {
|
||||||
spaceId: string;
|
spaceId: string;
|
||||||
workspaceId: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -23,12 +22,12 @@ export class SpaceListener {
|
|||||||
|
|
||||||
@OnEvent(EventName.SPACE_DELETED)
|
@OnEvent(EventName.SPACE_DELETED)
|
||||||
async handleSpaceDeleted(event: SpaceEvent) {
|
async handleSpaceDeleted(event: SpaceEvent) {
|
||||||
const { spaceId, workspaceId } = event;
|
const { spaceId } = event;
|
||||||
if (this.isTypesense()) {
|
if (this.isTypesense()) {
|
||||||
await this.searchQueue.add(QueueJob.SPACE_DELETED, { spaceId });
|
await this.searchQueue.add(QueueJob.SPACE_DELETED, { spaceId });
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.aiQueue.add(QueueJob.SPACE_DELETED, { spaceId, workspaceId });
|
await this.aiQueue.add(QueueJob.SPACE_DELETED, { spaceId });
|
||||||
}
|
}
|
||||||
|
|
||||||
isTypesense(): boolean {
|
isTypesense(): boolean {
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { InjectKysely } from 'nestjs-kysely';
|
import { InjectKysely } from 'nestjs-kysely';
|
||||||
import { ExpressionBuilder, sql } from 'kysely';
|
|
||||||
import { jsonObjectFrom } from 'kysely/helpers/postgres';
|
|
||||||
import { DB } from '@docmost/db/types/db';
|
|
||||||
import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types';
|
import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types';
|
||||||
import { dbOrTx } from '@docmost/db/utils';
|
import { dbOrTx } from '@docmost/db/utils';
|
||||||
import {
|
import {
|
||||||
@@ -11,8 +8,6 @@ import {
|
|||||||
UpdatableAttachment,
|
UpdatableAttachment,
|
||||||
} from '@docmost/db/types/entity.types';
|
} from '@docmost/db/types/entity.types';
|
||||||
import { AttachmentType } from '../../../core/attachment/attachment.constants';
|
import { AttachmentType } from '../../../core/attachment/attachment.constants';
|
||||||
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
|
||||||
import { executeWithCursorPagination } from '@docmost/db/pagination/cursor-pagination';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AttachmentRepo {
|
export class AttachmentRepo {
|
||||||
@@ -94,41 +89,6 @@ export class AttachmentRepo {
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
async findPageAttachments(pageId: string, pagination: PaginationOptions) {
|
|
||||||
let query = this.db
|
|
||||||
.selectFrom('attachments')
|
|
||||||
.select(this.baseFields)
|
|
||||||
.select((eb) => this.withCreator(eb))
|
|
||||||
.where('pageId', '=', pageId)
|
|
||||||
.where('type', '=', AttachmentType.File)
|
|
||||||
.where('deletedAt', 'is', null);
|
|
||||||
|
|
||||||
if (pagination.query) {
|
|
||||||
query = query.where(
|
|
||||||
sql`f_unaccent(file_name)`,
|
|
||||||
'ilike',
|
|
||||||
sql`f_unaccent(${'%' + pagination.query + '%'})`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return executeWithCursorPagination(query, {
|
|
||||||
perPage: pagination.limit,
|
|
||||||
cursor: pagination.cursor,
|
|
||||||
beforeCursor: pagination.beforeCursor,
|
|
||||||
fields: [{ expression: 'id', direction: 'desc' }],
|
|
||||||
parseCursor: (cursor) => ({ id: cursor.id }),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
withCreator(eb: ExpressionBuilder<DB, 'attachments'>) {
|
|
||||||
return jsonObjectFrom(
|
|
||||||
eb
|
|
||||||
.selectFrom('users')
|
|
||||||
.select(['users.id', 'users.name', 'users.avatarUrl'])
|
|
||||||
.whereRef('users.id', '=', 'attachments.creatorId'),
|
|
||||||
).as('creator');
|
|
||||||
}
|
|
||||||
|
|
||||||
async findByIds(
|
async findByIds(
|
||||||
ids: string[],
|
ids: string[],
|
||||||
opts?: {
|
opts?: {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user