mirror of
https://github.com/docmost/docmost.git
synced 2026-08-25 15:57:11 +08:00
Compare commits
54
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f0ebdd0bf | ||
|
|
8ba4792e25 | ||
|
|
06d7e24676 | ||
|
|
3219bd7160 | ||
|
|
8b73343b6c | ||
|
|
809f6eb3be | ||
|
|
5d8e9fde8b | ||
|
|
dacaaf5629 | ||
|
|
1dd7d79453 | ||
|
|
ecc6b974b5 | ||
|
|
defc1f4ba5 | ||
|
|
50e81ade57 | ||
|
|
228fe14cd8 | ||
|
|
2fe13daa09 | ||
|
|
44086cbb01 | ||
|
|
a81e5c42ec | ||
|
|
65af1cc2a4 | ||
|
|
231f0deeb0 | ||
|
|
b9d8612ecd | ||
|
|
e76c138e4c | ||
|
|
e146cfd075 | ||
|
|
efcca2e4fd | ||
|
|
3b57ce7c89 | ||
|
|
86687d2bf2 | ||
|
|
15f893184e | ||
|
|
dc3f7b0be4 | ||
|
|
88e057c76e | ||
|
|
89bf9f3078 | ||
|
|
b0f7c11fb3 | ||
|
|
feb5167771 | ||
|
|
97a1248818 | ||
|
|
b7d7ad4521 | ||
|
|
79df1229cb | ||
|
|
812d0765b5 | ||
|
|
234bd13453 | ||
|
|
affd2e6740 | ||
|
|
37e652ade5 | ||
|
|
38a847f305 | ||
|
|
7c80688698 | ||
|
|
0320e07bb1 | ||
|
|
1982a0ed1e | ||
|
|
fcb2b08cf3 | ||
|
|
e5ff58a73a | ||
|
|
d3bb105366 | ||
|
|
bbb1b5eb26 | ||
|
|
3e66aff1e2 | ||
|
|
89442f5154 | ||
|
|
12ef426541 | ||
|
|
93ff3f43b7 | ||
|
|
cbf03fc956 | ||
|
|
68309247b5 | ||
|
|
474ff6c629 | ||
|
|
c5e9be6b36 | ||
|
|
00e8c53852 |
@@ -52,7 +52,7 @@
|
|||||||
"mantine-form-zod-resolver": "1.3.0",
|
"mantine-form-zod-resolver": "1.3.0",
|
||||||
"mermaid": "11.16.1",
|
"mermaid": "11.16.1",
|
||||||
"mitt": "3.0.1",
|
"mitt": "3.0.1",
|
||||||
"nanoid": "3.3.18",
|
"nanoid": "3.3.17",
|
||||||
"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",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"Can view": "Can view",
|
"Can view": "Can view",
|
||||||
"Can view pages in space but not edit.": "Can view pages in space but not edit.",
|
"Can view pages in space but not edit.": "Can view pages in space but not edit.",
|
||||||
"Cancel": "Cancel",
|
"Cancel": "Cancel",
|
||||||
|
"Cancelled": "Cancelled",
|
||||||
"Change email": "Change email",
|
"Change email": "Change email",
|
||||||
"Change password": "Change password",
|
"Change password": "Change password",
|
||||||
"Change photo": "Change photo",
|
"Change photo": "Change photo",
|
||||||
@@ -29,7 +30,9 @@
|
|||||||
"Choose your preferred color scheme.": "Choose your preferred color scheme.",
|
"Choose your preferred color scheme.": "Choose your preferred color scheme.",
|
||||||
"Choose your preferred interface language.": "Choose your preferred interface language.",
|
"Choose your preferred interface language.": "Choose your preferred interface language.",
|
||||||
"Choose your preferred page width.": "Choose your preferred page width.",
|
"Choose your preferred page width.": "Choose your preferred page width.",
|
||||||
|
"Completed": "Completed",
|
||||||
"Confirm": "Confirm",
|
"Confirm": "Confirm",
|
||||||
|
"Confluence site": "Confluence site",
|
||||||
"Copy as Markdown": "Copy as Markdown",
|
"Copy as Markdown": "Copy as Markdown",
|
||||||
"Copy link": "Copy link",
|
"Copy link": "Copy link",
|
||||||
"Create": "Create",
|
"Create": "Create",
|
||||||
@@ -57,6 +60,10 @@
|
|||||||
"e.g Space for product team": "e.g Space for product team",
|
"e.g Space for product team": "e.g Space for product team",
|
||||||
"e.g Space for sales team to collaborate": "e.g Space for sales team to collaborate",
|
"e.g Space for sales team to collaborate": "e.g Space for sales team to collaborate",
|
||||||
"Edit": "Edit",
|
"Edit": "Edit",
|
||||||
|
"Everyone with access to this space": "Everyone with access to this space",
|
||||||
|
"Failed": "Failed",
|
||||||
|
"Import details": "Import details",
|
||||||
|
"Permissions": "Permissions",
|
||||||
"Read": "Read",
|
"Read": "Read",
|
||||||
"Edit group": "Edit group",
|
"Edit group": "Edit group",
|
||||||
"Email": "Email",
|
"Email": "Email",
|
||||||
@@ -76,6 +83,7 @@
|
|||||||
"Failed to restore page": "Failed to restore page",
|
"Failed to restore page": "Failed to restore page",
|
||||||
"Failed to fetch recent pages": "Failed to fetch recent pages",
|
"Failed to fetch recent pages": "Failed to fetch recent pages",
|
||||||
"Failed to import pages": "Failed to import pages",
|
"Failed to import pages": "Failed to import pages",
|
||||||
|
"Failed to load comments. An error occurred.": "Failed to load comments. An error occurred.",
|
||||||
"Failed to load page. An error occurred.": "Failed to load page. An error occurred.",
|
"Failed to load page. An error occurred.": "Failed to load page. An error occurred.",
|
||||||
"Failed to update data": "Failed to update data",
|
"Failed to update data": "Failed to update data",
|
||||||
"Failed to create base": "Failed to create base",
|
"Failed to create base": "Failed to create base",
|
||||||
@@ -150,6 +158,9 @@
|
|||||||
"page": "page",
|
"page": "page",
|
||||||
"Page deleted successfully": "Page deleted successfully",
|
"Page deleted successfully": "Page deleted successfully",
|
||||||
"Page history": "Page history",
|
"Page history": "Page history",
|
||||||
|
"Restricted pages": "Restricted pages",
|
||||||
|
"Restrictions": "Restrictions",
|
||||||
|
"Running": "Running",
|
||||||
"Select version": "Select version",
|
"Select version": "Select version",
|
||||||
"Highlight changes": "Highlight changes",
|
"Highlight changes": "Highlight changes",
|
||||||
"Page import is in progress. Please do not close this tab.": "Page import is in progress. Please do not close this tab.",
|
"Page import is in progress. Please do not close this tab.": "Page import is in progress. Please do not close this tab.",
|
||||||
@@ -186,6 +197,7 @@
|
|||||||
"Setup workspace": "Setup workspace",
|
"Setup workspace": "Setup workspace",
|
||||||
"Sign In": "Sign In",
|
"Sign In": "Sign In",
|
||||||
"Sign Up": "Sign Up",
|
"Sign Up": "Sign Up",
|
||||||
|
"Site": "Site",
|
||||||
"Slug": "Slug",
|
"Slug": "Slug",
|
||||||
"Space": "Space",
|
"Space": "Space",
|
||||||
"Space description": "Space description",
|
"Space description": "Space description",
|
||||||
@@ -194,10 +206,13 @@
|
|||||||
"Space settings": "Space settings",
|
"Space settings": "Space settings",
|
||||||
"Space slug": "Space slug",
|
"Space slug": "Space slug",
|
||||||
"Spaces": "Spaces",
|
"Spaces": "Spaces",
|
||||||
|
"spaces": "spaces",
|
||||||
"Spaces you belong to": "Spaces you belong to",
|
"Spaces you belong to": "Spaces you belong to",
|
||||||
"No space found": "No space found",
|
"No space found": "No space found",
|
||||||
"Search for spaces": "Search for spaces",
|
"Search for spaces": "Search for spaces",
|
||||||
"Start typing to search...": "Start typing to search...",
|
"Start typing to search...": "Start typing to search...",
|
||||||
|
"Started at": "Started at",
|
||||||
|
"Started by": "Started by",
|
||||||
"Status": "Status",
|
"Status": "Status",
|
||||||
"Successfully imported": "Successfully imported",
|
"Successfully imported": "Successfully imported",
|
||||||
"Successfully restored": "Successfully restored",
|
"Successfully restored": "Successfully restored",
|
||||||
@@ -211,6 +226,8 @@
|
|||||||
"Untitled": "Untitled",
|
"Untitled": "Untitled",
|
||||||
"Updated successfully": "Updated successfully",
|
"Updated successfully": "Updated successfully",
|
||||||
"User": "User",
|
"User": "User",
|
||||||
|
"Users": "Users",
|
||||||
|
"users": "users",
|
||||||
"Workspace": "Workspace",
|
"Workspace": "Workspace",
|
||||||
"Workspace Name": "Workspace Name",
|
"Workspace Name": "Workspace Name",
|
||||||
"Workspace settings": "Workspace settings",
|
"Workspace settings": "Workspace settings",
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import FavoritesPage from "@/pages/favorites/favorites-page";
|
|||||||
import AiChat from "@/ee/ai-chat/pages/ai-chat.tsx";
|
import AiChat from "@/ee/ai-chat/pages/ai-chat.tsx";
|
||||||
import VerifyEmail from "@/ee/pages/verify-email.tsx";
|
import VerifyEmail from "@/ee/pages/verify-email.tsx";
|
||||||
import LabelPage from "@/pages/label/label-page";
|
import LabelPage from "@/pages/label/label-page";
|
||||||
|
import ConfluenceImportPage from "@/ee/confluence-import/pages/confluence-import.tsx";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -128,6 +129,10 @@ export default function App() {
|
|||||||
<Route path={"ai/mcp"} element={<AiSettings />} />
|
<Route path={"ai/mcp"} element={<AiSettings />} />
|
||||||
<Route path={"audit"} element={<AuditLogs />} />
|
<Route path={"audit"} element={<AuditLogs />} />
|
||||||
<Route path={"verifications"} element={<VerifiedPages />} />
|
<Route path={"verifications"} element={<VerifiedPages />} />
|
||||||
|
<Route
|
||||||
|
path={"import/confluence"}
|
||||||
|
element={<ConfluenceImportPage />}
|
||||||
|
/>
|
||||||
{!isCloud() && <Route path={"license"} element={<License />} />}
|
{!isCloud() && <Route path={"license"} element={<License />} />}
|
||||||
{isCloud() && <Route path={"billing"} element={<Billing />} />}
|
{isCloud() && <Route path={"billing"} element={<Billing />} />}
|
||||||
</Route>
|
</Route>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
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 CommentListWithTabs from "@/features/comment/components/comment-list-with-tabs.tsx";
|
||||||
|
import { CommentErrorBoundary } from "@/features/comment/components/comment-error-boundary.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, { ReactNode, useEffect } from "react";
|
import React, { ReactNode, useEffect } from "react";
|
||||||
@@ -28,7 +29,11 @@ export default function Aside() {
|
|||||||
|
|
||||||
switch (tab) {
|
switch (tab) {
|
||||||
case "comments":
|
case "comments":
|
||||||
component = <CommentListWithTabs />;
|
component = (
|
||||||
|
<CommentErrorBoundary>
|
||||||
|
<CommentListWithTabs />
|
||||||
|
</CommentErrorBoundary>
|
||||||
|
);
|
||||||
title = "Comments";
|
title = "Comments";
|
||||||
break;
|
break;
|
||||||
case "toc":
|
case "toc":
|
||||||
|
|||||||
@@ -15,11 +15,12 @@ import {
|
|||||||
IconSparkles,
|
IconSparkles,
|
||||||
IconHistory,
|
IconHistory,
|
||||||
IconShieldCheck,
|
IconShieldCheck,
|
||||||
|
IconFileImport,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { Link, useLocation } from "react-router-dom";
|
import { Link, useLocation } from "react-router-dom";
|
||||||
import classes from "./settings.module.css";
|
import classes from "./settings.module.css";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { isCloud } from "@/lib/config.ts";
|
import { isBetaConfluenceImporter, isCloud } from "@/lib/config.ts";
|
||||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
||||||
@@ -51,6 +52,7 @@ type DataItem = {
|
|||||||
feature?: string;
|
feature?: string;
|
||||||
role?: "admin" | "owner";
|
role?: "admin" | "owner";
|
||||||
env?: "cloud" | "selfhosted";
|
env?: "cloud" | "selfhosted";
|
||||||
|
show?: () => boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DataGroup = {
|
type DataGroup = {
|
||||||
@@ -125,6 +127,14 @@ const groupedData: DataGroup[] = [
|
|||||||
role: "owner",
|
role: "owner",
|
||||||
env: "selfhosted",
|
env: "selfhosted",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Import",
|
||||||
|
icon: IconFileImport,
|
||||||
|
path: "/settings/import/confluence",
|
||||||
|
feature: Feature.CONFLUENCE_API_IMPORT,
|
||||||
|
role: "admin",
|
||||||
|
show: () => isBetaConfluenceImporter(),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -158,6 +168,7 @@ export default function SettingsSidebar() {
|
|||||||
entitlements?.features?.includes(f) ?? false;
|
entitlements?.features?.includes(f) ?? false;
|
||||||
|
|
||||||
const canShowItem = (item: DataItem) => {
|
const canShowItem = (item: DataItem) => {
|
||||||
|
if (item.show && !item.show()) return false;
|
||||||
if (item.env === "cloud" && !isCloud()) return false;
|
if (item.env === "cloud" && !isCloud()) return false;
|
||||||
if (item.env === "selfhosted" && isCloud()) return false;
|
if (item.env === "selfhosted" && isCloud()) return false;
|
||||||
if (item.role === "admin" && !isAdmin) return false;
|
if (item.role === "admin" && !isAdmin) return false;
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -0,0 +1,340 @@
|
|||||||
|
import { useMemo, useState } from "react";
|
||||||
|
import {
|
||||||
|
Badge,
|
||||||
|
Group,
|
||||||
|
Loader,
|
||||||
|
Modal,
|
||||||
|
Progress,
|
||||||
|
Skeleton,
|
||||||
|
Stack,
|
||||||
|
Table,
|
||||||
|
Text,
|
||||||
|
Tooltip,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { IconAlertCircle, IconCheck, IconX } from "@tabler/icons-react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import {
|
||||||
|
ConfluenceImportHistoryItem,
|
||||||
|
ConfluenceImportStatus,
|
||||||
|
} from "@/ee/confluence-import/types/confluence-import.types";
|
||||||
|
import { CustomAvatar } from "@/components/ui/custom-avatar";
|
||||||
|
import { formattedDate } from "@/lib/time";
|
||||||
|
import NoTableResults from "@/components/common/no-table-results";
|
||||||
|
import { useConfluenceImportsQuery } from "@/ee/confluence-import/queries/confluence-import-queries";
|
||||||
|
|
||||||
|
const BADGE_STYLES = {
|
||||||
|
root: { flexShrink: 0 },
|
||||||
|
label: { overflow: "visible" as const },
|
||||||
|
};
|
||||||
|
|
||||||
|
function statusBadge(
|
||||||
|
status: ConfluenceImportStatus,
|
||||||
|
cancelled: boolean,
|
||||||
|
t: (key: string) => string,
|
||||||
|
) {
|
||||||
|
if (cancelled) {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
color="gray"
|
||||||
|
variant="light"
|
||||||
|
leftSection={<IconX size={12} />}
|
||||||
|
styles={BADGE_STYLES}
|
||||||
|
>
|
||||||
|
{t("Cancelled")}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (status === "processing") {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
color="blue"
|
||||||
|
variant="light"
|
||||||
|
leftSection={<Loader size={10} />}
|
||||||
|
styles={BADGE_STYLES}
|
||||||
|
>
|
||||||
|
{t("Running")}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (status === "success") {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
color="teal"
|
||||||
|
variant="light"
|
||||||
|
leftSection={<IconCheck size={12} />}
|
||||||
|
styles={BADGE_STYLES}
|
||||||
|
>
|
||||||
|
{t("Completed")}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
color="red"
|
||||||
|
variant="light"
|
||||||
|
leftSection={<IconAlertCircle size={12} />}
|
||||||
|
styles={BADGE_STYLES}
|
||||||
|
>
|
||||||
|
{t("Failed")}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function phaseLabel(phase: string | null, t: (key: string) => string): string {
|
||||||
|
if (!phase) return "—";
|
||||||
|
return t(phase.charAt(0).toUpperCase() + phase.slice(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
function progressValue(item: ConfluenceImportHistoryItem) {
|
||||||
|
if (item.status === "success") return 100;
|
||||||
|
if (item.totalPages > 0) {
|
||||||
|
return Math.min(
|
||||||
|
100,
|
||||||
|
Math.round((item.importedPages / item.totalPages) * 100),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return item.status === "processing" ? 5 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ProgressCell({ item }: { item: ConfluenceImportHistoryItem }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const value = progressValue(item);
|
||||||
|
const color =
|
||||||
|
item.status === "failed"
|
||||||
|
? "red"
|
||||||
|
: item.status === "success"
|
||||||
|
? "teal"
|
||||||
|
: "blue";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack gap={4}>
|
||||||
|
<Progress value={value} color={color} size="xs" animated={item.status === "processing"} />
|
||||||
|
<Group gap="xs" wrap="nowrap">
|
||||||
|
<Text fz="xs" c="dimmed" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{item.importedPages}/{item.totalPages || "?"} {t("pages")}
|
||||||
|
</Text>
|
||||||
|
<Text fz="xs" c="dimmed" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
· {item.importedSpaces}/{item.totalSpaces || "?"} {t("spaces")}
|
||||||
|
</Text>
|
||||||
|
<Text fz="xs" c="dimmed" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
· {item.importedUsers}/{item.totalUsers || "?"} {t("users")}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ImportStatsModal({
|
||||||
|
item,
|
||||||
|
onClose,
|
||||||
|
}: {
|
||||||
|
item: ConfluenceImportHistoryItem | null;
|
||||||
|
onClose: () => void;
|
||||||
|
}) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const stats = item
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
label: t("Spaces"),
|
||||||
|
imported: item.importedSpaces,
|
||||||
|
total: item.totalSpaces,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Pages"),
|
||||||
|
imported: item.importedPages,
|
||||||
|
total: item.totalPages,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Users"),
|
||||||
|
imported: item.importedUsers,
|
||||||
|
total: item.totalUsers,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Groups"),
|
||||||
|
imported: item.importedGroups,
|
||||||
|
total: item.totalGroups,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Attachments"),
|
||||||
|
imported: item.importedAttachments,
|
||||||
|
total: item.totalAttachments,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Labels"),
|
||||||
|
imported: item.importedLabels,
|
||||||
|
total: item.totalLabels,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("Restricted pages"),
|
||||||
|
imported: item.importedRestrictedPages,
|
||||||
|
total: item.totalRestrictedPages,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
opened={!!item}
|
||||||
|
onClose={onClose}
|
||||||
|
title={t("Import details")}
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
{item && (
|
||||||
|
<Stack gap="sm">
|
||||||
|
<div>
|
||||||
|
<Text fz="sm" c="dimmed">
|
||||||
|
{t("Confluence site")}
|
||||||
|
</Text>
|
||||||
|
<Text fz="sm" fw={500} lineClamp={1}>
|
||||||
|
{item.siteUrl}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Text fz="sm" c="dimmed">
|
||||||
|
{t("Started at")}
|
||||||
|
</Text>
|
||||||
|
<Text fz="sm">{formattedDate(new Date(item.createdAt))}</Text>
|
||||||
|
</div>
|
||||||
|
<Table verticalSpacing="xs" fz="sm">
|
||||||
|
<Table.Tbody>
|
||||||
|
{stats.map((stat) => (
|
||||||
|
<Table.Tr key={stat.label}>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm">{stat.label}</Text>
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm" ta="right">
|
||||||
|
{stat.imported} / {stat.total}
|
||||||
|
</Text>
|
||||||
|
</Table.Td>
|
||||||
|
</Table.Tr>
|
||||||
|
))}
|
||||||
|
</Table.Tbody>
|
||||||
|
</Table>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function TableSkeleton() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{Array.from({ length: 3 }).map((_, i) => (
|
||||||
|
<Table.Tr key={i}>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={120} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={180} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={80} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={140} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={120} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Skeleton height={14} width={120} />
|
||||||
|
</Table.Td>
|
||||||
|
</Table.Tr>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ConfluenceImportHistory() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { data, isLoading } = useConfluenceImportsQuery();
|
||||||
|
const [selectedItem, setSelectedItem] =
|
||||||
|
useState<ConfluenceImportHistoryItem | null>(null);
|
||||||
|
|
||||||
|
const items = useMemo(() => data?.items ?? [], [data]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Table.ScrollContainer minWidth={720}>
|
||||||
|
<Table verticalSpacing="xs" highlightOnHover>
|
||||||
|
<Table.Thead>
|
||||||
|
<Table.Tr>
|
||||||
|
<Table.Th>{t("Status")}</Table.Th>
|
||||||
|
<Table.Th>{t("Site")}</Table.Th>
|
||||||
|
<Table.Th>{t("Phase")}</Table.Th>
|
||||||
|
<Table.Th>{t("Progress")}</Table.Th>
|
||||||
|
<Table.Th>{t("Started by")}</Table.Th>
|
||||||
|
<Table.Th>{t("Started at")}</Table.Th>
|
||||||
|
</Table.Tr>
|
||||||
|
</Table.Thead>
|
||||||
|
|
||||||
|
<Table.Tbody>
|
||||||
|
{isLoading ? (
|
||||||
|
<TableSkeleton />
|
||||||
|
) : items.length > 0 ? (
|
||||||
|
items.map((item) => (
|
||||||
|
<Table.Tr
|
||||||
|
key={item.fileTaskId}
|
||||||
|
onClick={() => setSelectedItem(item)}
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
<Table.Td>
|
||||||
|
{statusBadge(item.status, item.cancelled, t)}
|
||||||
|
{item.status === "failed" && item.errorMessage && (
|
||||||
|
<Tooltip label={item.errorMessage} multiline w={320}>
|
||||||
|
<Text fz="xs" c="red" lineClamp={1} maw={180}>
|
||||||
|
{item.errorMessage}
|
||||||
|
</Text>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm" lineClamp={1} maw={240}>
|
||||||
|
{item.siteUrl}
|
||||||
|
</Text>
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm">{phaseLabel(item.currentPhase, t)}</Text>
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<ProgressCell item={item} />
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
{item.creatorName ? (
|
||||||
|
<Group gap="sm" wrap="nowrap">
|
||||||
|
<CustomAvatar
|
||||||
|
avatarUrl={item.creatorAvatarUrl}
|
||||||
|
name={item.creatorName}
|
||||||
|
size={24}
|
||||||
|
/>
|
||||||
|
<Text fz="sm" lineClamp={1}>
|
||||||
|
{item.creatorName}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
) : (
|
||||||
|
<Text fz="sm" c="dimmed">
|
||||||
|
—
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Table.Td>
|
||||||
|
<Table.Td>
|
||||||
|
<Text fz="sm" style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{formattedDate(new Date(item.createdAt))}
|
||||||
|
</Text>
|
||||||
|
</Table.Td>
|
||||||
|
</Table.Tr>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<NoTableResults colSpan={6} />
|
||||||
|
)}
|
||||||
|
</Table.Tbody>
|
||||||
|
</Table>
|
||||||
|
|
||||||
|
<ImportStatsModal
|
||||||
|
item={selectedItem}
|
||||||
|
onClose={() => setSelectedItem(null)}
|
||||||
|
/>
|
||||||
|
</Table.ScrollContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,445 @@
|
|||||||
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
Group,
|
||||||
|
Modal,
|
||||||
|
PasswordInput,
|
||||||
|
ScrollArea,
|
||||||
|
SegmentedControl,
|
||||||
|
Stack,
|
||||||
|
Stepper,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import {
|
||||||
|
IconAlertCircle,
|
||||||
|
IconCheck,
|
||||||
|
IconCloudCheck,
|
||||||
|
IconPlug,
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useForm } from "@mantine/form";
|
||||||
|
import { notifications } from "@mantine/notifications";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
import {
|
||||||
|
listConfluenceSpaces,
|
||||||
|
startConfluenceImport,
|
||||||
|
testConfluenceConnection,
|
||||||
|
} from "@/ee/confluence-import/services/confluence-import-service";
|
||||||
|
import {
|
||||||
|
ConfluenceAuthType,
|
||||||
|
ConfluenceCredentials,
|
||||||
|
ConfluenceSpaceSummary,
|
||||||
|
} from "@/ee/confluence-import/types/confluence-import.types";
|
||||||
|
import { confluenceImportsQueryKey } from "@/ee/confluence-import/queries/confluence-import-queries";
|
||||||
|
|
||||||
|
type ConfluenceEditionChoice = "cloud" | "server";
|
||||||
|
|
||||||
|
type CredentialsFormValues = {
|
||||||
|
edition: ConfluenceEditionChoice;
|
||||||
|
authType: ConfluenceAuthType;
|
||||||
|
siteUrl: string;
|
||||||
|
email: string;
|
||||||
|
token: string;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
opened: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function ConfluenceImportModal({ opened, onClose }: Props) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const [active, setActive] = useState(0);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [spaces, setSpaces] = useState<ConfluenceSpaceSummary[]>([]);
|
||||||
|
const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
|
||||||
|
const [importAll, setImportAll] = useState(true);
|
||||||
|
|
||||||
|
const form = useForm<CredentialsFormValues>({
|
||||||
|
initialValues: {
|
||||||
|
edition: "server",
|
||||||
|
authType: "pat",
|
||||||
|
siteUrl: "",
|
||||||
|
email: "",
|
||||||
|
token: "",
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
},
|
||||||
|
validate: {
|
||||||
|
siteUrl: (value) =>
|
||||||
|
!value?.trim()
|
||||||
|
? t("Site URL is required")
|
||||||
|
: !/^https?:\/\//i.test(value.trim())
|
||||||
|
? t("Site URL must start with http:// or https://")
|
||||||
|
: null,
|
||||||
|
email: (value, values) =>
|
||||||
|
values.edition === "cloud" && !value?.trim()
|
||||||
|
? t("Email is required")
|
||||||
|
: null,
|
||||||
|
token: (value, values) =>
|
||||||
|
(values.authType === "cloud_token" || values.authType === "pat") &&
|
||||||
|
!value?.trim()
|
||||||
|
? t("API token is required")
|
||||||
|
: null,
|
||||||
|
username: (value, values) =>
|
||||||
|
values.authType === "basic" && !value?.trim()
|
||||||
|
? t("Username is required")
|
||||||
|
: null,
|
||||||
|
password: (value, values) =>
|
||||||
|
values.authType === "basic" && !value?.trim()
|
||||||
|
? t("Password is required")
|
||||||
|
: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!opened) {
|
||||||
|
setActive(0);
|
||||||
|
setError(null);
|
||||||
|
setSpaces([]);
|
||||||
|
setSelectedKeys([]);
|
||||||
|
setImportAll(true);
|
||||||
|
setLoading(false);
|
||||||
|
form.reset();
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [opened]);
|
||||||
|
|
||||||
|
const credentials: ConfluenceCredentials = useMemo(() => {
|
||||||
|
const values = form.values;
|
||||||
|
return {
|
||||||
|
siteUrl: values.siteUrl.trim().replace(/\/+$/, ""),
|
||||||
|
authType: values.authType,
|
||||||
|
email: values.email?.trim() || undefined,
|
||||||
|
token: values.token?.trim() || undefined,
|
||||||
|
username: values.username?.trim() || undefined,
|
||||||
|
password: values.password || undefined,
|
||||||
|
};
|
||||||
|
}, [form.values]);
|
||||||
|
|
||||||
|
const handleEditionChange = (edition: ConfluenceEditionChoice) => {
|
||||||
|
form.setFieldValue("edition", edition);
|
||||||
|
if (edition === "cloud") {
|
||||||
|
form.setFieldValue("authType", "cloud_token");
|
||||||
|
} else if (form.values.authType === "cloud_token") {
|
||||||
|
form.setFieldValue("authType", "pat");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNextFromCredentials = async () => {
|
||||||
|
if ((await form.validate()).hasErrors) return;
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
const test = await testConfluenceConnection(credentials);
|
||||||
|
if (!test.success) {
|
||||||
|
setError(test.error || t("Connection failed"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const list = await listConfluenceSpaces(credentials);
|
||||||
|
if (!list.success || !list.spaces) {
|
||||||
|
setError(list.error || t("Failed to load spaces"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSpaces(list.spaces);
|
||||||
|
setSelectedKeys(list.spaces.map((s) => s.key));
|
||||||
|
setImportAll(true);
|
||||||
|
setActive(1);
|
||||||
|
} catch (err: any) {
|
||||||
|
setError(
|
||||||
|
err?.response?.data?.message || err?.message || t("Unexpected error"),
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleSpace = (key: string, checked: boolean) => {
|
||||||
|
setSelectedKeys((prev) =>
|
||||||
|
checked
|
||||||
|
? Array.from(new Set([...prev, key]))
|
||||||
|
: prev.filter((k) => k !== key),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleAll = (checked: boolean) => {
|
||||||
|
setImportAll(checked);
|
||||||
|
setSelectedKeys(checked ? spaces.map((s) => s.key) : []);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleStartImport = async () => {
|
||||||
|
const spaceKeys = importAll ? [] : selectedKeys;
|
||||||
|
if (!importAll && spaceKeys.length === 0) {
|
||||||
|
setError(t("Select at least one space to import"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
const result = await startConfluenceImport({
|
||||||
|
...credentials,
|
||||||
|
spaceKeys,
|
||||||
|
});
|
||||||
|
if (!result.success || !result.fileTaskId) {
|
||||||
|
setError(result.error || t("Failed to start import"));
|
||||||
|
setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await queryClient.invalidateQueries({
|
||||||
|
queryKey: confluenceImportsQueryKey,
|
||||||
|
});
|
||||||
|
|
||||||
|
notifications.show({
|
||||||
|
title: t("Confluence import started"),
|
||||||
|
message: t("Track progress below. This runs in the background."),
|
||||||
|
color: "blue",
|
||||||
|
icon: <IconCheck size={18} />,
|
||||||
|
autoClose: 4000,
|
||||||
|
});
|
||||||
|
|
||||||
|
onClose();
|
||||||
|
} catch (err: any) {
|
||||||
|
setError(
|
||||||
|
err?.response?.data?.message || err?.message || t("Unexpected error"),
|
||||||
|
);
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancelFlow = async () => {
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
const editionSegment = (
|
||||||
|
<SegmentedControl
|
||||||
|
value={form.values.edition}
|
||||||
|
onChange={(val) => handleEditionChange(val as ConfluenceEditionChoice)}
|
||||||
|
data={[
|
||||||
|
{ value: "server", label: t("Data Center / Server") },
|
||||||
|
{ value: "cloud", label: t("Cloud") },
|
||||||
|
]}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const authTypeSegment = form.values.edition === "server" && (
|
||||||
|
<SegmentedControl
|
||||||
|
value={form.values.authType}
|
||||||
|
onChange={(val) =>
|
||||||
|
form.setFieldValue("authType", val as ConfluenceAuthType)
|
||||||
|
}
|
||||||
|
data={[
|
||||||
|
{ value: "pat", label: t("Personal Access Token") },
|
||||||
|
{ value: "basic", label: t("Username + password") },
|
||||||
|
]}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const selectedCount = importAll ? spaces.length : selectedKeys.length;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
opened={opened}
|
||||||
|
onClose={onClose}
|
||||||
|
title={t("Import from Confluence")}
|
||||||
|
size={720}
|
||||||
|
centered
|
||||||
|
closeOnClickOutside={!loading}
|
||||||
|
closeOnEscape={!loading}
|
||||||
|
>
|
||||||
|
<Stepper active={active} size="sm" mb="md" allowNextStepsSelect={false}>
|
||||||
|
<Stepper.Step
|
||||||
|
label={t("Connect")}
|
||||||
|
description={t("Credentials")}
|
||||||
|
icon={<IconPlug size={18} />}
|
||||||
|
/>
|
||||||
|
<Stepper.Step
|
||||||
|
label={t("Select spaces")}
|
||||||
|
description={t("Choose what to import")}
|
||||||
|
icon={<IconCloudCheck size={18} />}
|
||||||
|
/>
|
||||||
|
</Stepper>
|
||||||
|
|
||||||
|
{active === 0 && (
|
||||||
|
<Stack>
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{t(
|
||||||
|
"Enter your Confluence URL and credentials. We'll validate the connection before continuing.",
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
{editionSegment}
|
||||||
|
{authTypeSegment}
|
||||||
|
<TextInput
|
||||||
|
label={t("Site URL")}
|
||||||
|
placeholder={
|
||||||
|
form.values.edition === "cloud"
|
||||||
|
? "https://your-site.atlassian.net/wiki"
|
||||||
|
: "https://confluence.example.com"
|
||||||
|
}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("siteUrl")}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{form.values.edition === "cloud" && (
|
||||||
|
<>
|
||||||
|
<TextInput
|
||||||
|
label={t("Email")}
|
||||||
|
placeholder="you@company.com"
|
||||||
|
required
|
||||||
|
{...form.getInputProps("email")}
|
||||||
|
/>
|
||||||
|
<PasswordInput
|
||||||
|
label={t("API token")}
|
||||||
|
description={t(
|
||||||
|
"Create at id.atlassian.com/manage-profile/security/api-tokens",
|
||||||
|
)}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("token")}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{form.values.edition === "server" &&
|
||||||
|
form.values.authType === "pat" && (
|
||||||
|
<>
|
||||||
|
<TextInput
|
||||||
|
label={t("Email")}
|
||||||
|
placeholder="you@company.com"
|
||||||
|
{...form.getInputProps("email")}
|
||||||
|
/>
|
||||||
|
<PasswordInput
|
||||||
|
label={t("Personal Access Token")}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("token")}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{form.values.edition === "server" &&
|
||||||
|
form.values.authType === "basic" && (
|
||||||
|
<>
|
||||||
|
<TextInput
|
||||||
|
label={t("Username")}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("username")}
|
||||||
|
/>
|
||||||
|
<PasswordInput
|
||||||
|
label={t("Password")}
|
||||||
|
required
|
||||||
|
{...form.getInputProps("password")}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={t("Email (optional)")}
|
||||||
|
placeholder="you@company.com"
|
||||||
|
{...form.getInputProps("email")}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<Alert color="red" icon={<IconAlertCircle size={18} />}>
|
||||||
|
{error}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Group justify="flex-end">
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
onClick={handleCancelFlow}
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
{t("Cancel")}
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleNextFromCredentials} loading={loading}>
|
||||||
|
{t("Test & continue")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{active === 1 && (
|
||||||
|
<Stack>
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{t(
|
||||||
|
"Pages, comments, page labels, users, groups, spaces and permissions will be imported.",
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Checkbox
|
||||||
|
label={t("Import all spaces ({{count}})", {
|
||||||
|
count: spaces.length,
|
||||||
|
})}
|
||||||
|
checked={importAll}
|
||||||
|
onChange={(e) => toggleAll(e.currentTarget.checked)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ScrollArea h={320} type="auto" offsetScrollbars>
|
||||||
|
<Stack gap="xs">
|
||||||
|
{spaces.map((space) => (
|
||||||
|
<Checkbox
|
||||||
|
key={space.id}
|
||||||
|
label={
|
||||||
|
<Group gap={6} wrap="nowrap">
|
||||||
|
<Text fw={500}>{space.name}</Text>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
({space.key})
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
}
|
||||||
|
checked={importAll || selectedKeys.includes(space.key)}
|
||||||
|
disabled={importAll}
|
||||||
|
onChange={(e) =>
|
||||||
|
toggleSpace(space.key, e.currentTarget.checked)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
{spaces.length === 0 && (
|
||||||
|
<Text c="dimmed" ta="center" py="lg">
|
||||||
|
{t("No spaces found for this account.")}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</ScrollArea>
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<Alert color="red" icon={<IconAlertCircle size={18} />}>
|
||||||
|
{error}
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Group justify="space-between">
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{t("{{count}} selected", { count: selectedCount })}
|
||||||
|
</Text>
|
||||||
|
<Group>
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
onClick={() => setActive(0)}
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
{t("Back")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={handleStartImport}
|
||||||
|
loading={loading}
|
||||||
|
disabled={!importAll && selectedKeys.length === 0}
|
||||||
|
>
|
||||||
|
{t("Start import")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import { Helmet } from "react-helmet-async";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Divider,
|
||||||
|
Group,
|
||||||
|
Paper,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
Tooltip,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
|
import SettingsTitle from "@/components/settings/settings-title";
|
||||||
|
import { ConfluenceIcon } from "@/components/icons/confluence-icon";
|
||||||
|
import ConfluenceImportModal from "@/ee/confluence-import/components/confluence-import-modal";
|
||||||
|
import ConfluenceImportHistory from "@/ee/confluence-import/components/confluence-import-history";
|
||||||
|
import { getAppName } from "@/lib/config";
|
||||||
|
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||||
|
import { Feature } from "@/ee/features";
|
||||||
|
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||||
|
|
||||||
|
export default function ConfluenceImportPage() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
|
const hasConfluenceImport = useHasFeature(Feature.CONFLUENCE_API_IMPORT);
|
||||||
|
const upgradeLabel = useUpgradeLabel();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Helmet>
|
||||||
|
<title>
|
||||||
|
{t("Import from Confluence")} - {getAppName()}
|
||||||
|
</title>
|
||||||
|
</Helmet>
|
||||||
|
|
||||||
|
<SettingsTitle title={t("Import from Confluence")} />
|
||||||
|
|
||||||
|
<Paper withBorder p="lg" radius="md" mb="lg">
|
||||||
|
<Group align="flex-start" justify="space-between" wrap="nowrap">
|
||||||
|
<Group align="flex-start" wrap="nowrap">
|
||||||
|
<ConfluenceIcon size={32} />
|
||||||
|
<Stack gap={4}>
|
||||||
|
<Text fw={600}>{t("Confluence API import")}</Text>
|
||||||
|
<Text size="sm" c="dimmed" maw={560}>
|
||||||
|
{t(
|
||||||
|
"Connect to Confluence Cloud or Data Center to import spaces, pages, attachments, comments, users, groups and permissions directly via the API.",
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Tooltip label={upgradeLabel} disabled={hasConfluenceImport}>
|
||||||
|
<Button onClick={open} disabled={!hasConfluenceImport}>
|
||||||
|
{t("Start import")}
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</Group>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
<Divider my="md" label={t("Import history")} labelPosition="left" />
|
||||||
|
|
||||||
|
<ConfluenceImportHistory />
|
||||||
|
|
||||||
|
<ConfluenceImportModal opened={opened} onClose={close} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { listConfluenceImports } from "@/ee/confluence-import/services/confluence-import-service";
|
||||||
|
|
||||||
|
export const confluenceImportsQueryKey = ["confluence-imports"] as const;
|
||||||
|
|
||||||
|
export function useConfluenceImportsQuery() {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: confluenceImportsQueryKey,
|
||||||
|
queryFn: listConfluenceImports,
|
||||||
|
refetchInterval: (query) => {
|
||||||
|
const hasRunning = query.state.data?.items?.some(
|
||||||
|
(i) => i.status === "processing",
|
||||||
|
);
|
||||||
|
return hasRunning ? 3000 : false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import api from "@/lib/api-client";
|
||||||
|
import {
|
||||||
|
ConfluenceCredentials,
|
||||||
|
ImportStatusResponse,
|
||||||
|
ListImportsResponse,
|
||||||
|
ListSpacesResponse,
|
||||||
|
StartImportResponse,
|
||||||
|
TestConnectionResponse,
|
||||||
|
} from "@/ee/confluence-import/types/confluence-import.types";
|
||||||
|
|
||||||
|
export async function testConfluenceConnection(
|
||||||
|
data: ConfluenceCredentials,
|
||||||
|
): Promise<TestConnectionResponse> {
|
||||||
|
const req = await api.post<TestConnectionResponse>(
|
||||||
|
"/confluence-import/test-connection",
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listConfluenceSpaces(
|
||||||
|
data: ConfluenceCredentials,
|
||||||
|
): Promise<ListSpacesResponse> {
|
||||||
|
const req = await api.post<ListSpacesResponse>(
|
||||||
|
"/confluence-import/spaces",
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function startConfluenceImport(
|
||||||
|
data: ConfluenceCredentials & { spaceKeys?: string[] },
|
||||||
|
): Promise<StartImportResponse> {
|
||||||
|
const req = await api.post<StartImportResponse>(
|
||||||
|
"/confluence-import/start",
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getConfluenceImportStatus(
|
||||||
|
fileTaskId: string,
|
||||||
|
): Promise<ImportStatusResponse> {
|
||||||
|
const req = await api.post<ImportStatusResponse>(
|
||||||
|
"/confluence-import/status",
|
||||||
|
{ fileTaskId },
|
||||||
|
);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listConfluenceImports(): Promise<ListImportsResponse> {
|
||||||
|
const req = await api.post<ListImportsResponse>("/confluence-import/history");
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function cancelConfluenceImport(
|
||||||
|
fileTaskId: string,
|
||||||
|
): Promise<{ success: boolean }> {
|
||||||
|
const req = await api.post<{ success: boolean }>(
|
||||||
|
"/confluence-import/cancel",
|
||||||
|
{ fileTaskId },
|
||||||
|
);
|
||||||
|
return req.data;
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
export type ConfluenceAuthType = "cloud_token" | "pat" | "basic";
|
||||||
|
|
||||||
|
export type ConfluenceCredentials = {
|
||||||
|
siteUrl: string;
|
||||||
|
authType: ConfluenceAuthType;
|
||||||
|
email?: string;
|
||||||
|
token?: string;
|
||||||
|
username?: string;
|
||||||
|
password?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ConfluenceSpaceSummary = {
|
||||||
|
id: string;
|
||||||
|
key: string;
|
||||||
|
name: string;
|
||||||
|
type?: string;
|
||||||
|
status?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TestConnectionResponse = {
|
||||||
|
success: boolean;
|
||||||
|
edition?: string;
|
||||||
|
spaceCount?: number;
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ListSpacesResponse = {
|
||||||
|
success: boolean;
|
||||||
|
spaces?: ConfluenceSpaceSummary[];
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type StartImportResponse = {
|
||||||
|
success: boolean;
|
||||||
|
fileTaskId?: string;
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ConfluenceImportStatus = "processing" | "success" | "failed";
|
||||||
|
|
||||||
|
export type ImportStatusResponse = {
|
||||||
|
fileTaskId?: string;
|
||||||
|
status?: ConfluenceImportStatus;
|
||||||
|
errorMessage?: string | null;
|
||||||
|
currentPhase?: string | null;
|
||||||
|
totalSpaces?: number;
|
||||||
|
importedSpaces?: number;
|
||||||
|
totalPages?: number;
|
||||||
|
importedPages?: number;
|
||||||
|
totalUsers?: number;
|
||||||
|
importedUsers?: number;
|
||||||
|
totalGroups?: number;
|
||||||
|
importedGroups?: number;
|
||||||
|
totalRestrictedPages?: number;
|
||||||
|
importedRestrictedPages?: number;
|
||||||
|
createdAt?: string;
|
||||||
|
updatedAt?: string;
|
||||||
|
error?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ConfluenceImportHistoryItem = {
|
||||||
|
fileTaskId: string;
|
||||||
|
siteUrl: string;
|
||||||
|
status: ConfluenceImportStatus;
|
||||||
|
errorMessage: string | null;
|
||||||
|
currentPhase: string | null;
|
||||||
|
totalSpaces: number;
|
||||||
|
importedSpaces: number;
|
||||||
|
totalPages: number;
|
||||||
|
importedPages: number;
|
||||||
|
totalUsers: number;
|
||||||
|
importedUsers: number;
|
||||||
|
totalGroups: number;
|
||||||
|
importedGroups: number;
|
||||||
|
totalAttachments: number;
|
||||||
|
importedAttachments: number;
|
||||||
|
totalLabels: number;
|
||||||
|
importedLabels: number;
|
||||||
|
totalRestrictedPages: number;
|
||||||
|
importedRestrictedPages: number;
|
||||||
|
cancelled: boolean;
|
||||||
|
spaceKeys: string[];
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
|
creatorId: string | null;
|
||||||
|
creatorName: string | null;
|
||||||
|
creatorAvatarUrl: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ListImportsResponse = {
|
||||||
|
items: ConfluenceImportHistoryItem[];
|
||||||
|
};
|
||||||
@@ -7,6 +7,7 @@ export const Feature = {
|
|||||||
PAGE_PERMISSIONS: 'page:permissions',
|
PAGE_PERMISSIONS: 'page:permissions',
|
||||||
AI: 'ai',
|
AI: 'ai',
|
||||||
CONFLUENCE_IMPORT: 'import:confluence',
|
CONFLUENCE_IMPORT: 'import:confluence',
|
||||||
|
CONFLUENCE_API_IMPORT: 'import:confluence-api',
|
||||||
DOCX_IMPORT: 'import:docx',
|
DOCX_IMPORT: 'import:docx',
|
||||||
PDF_IMPORT: 'import:pdf',
|
PDF_IMPORT: 'import:pdf',
|
||||||
ATTACHMENT_INDEXING: 'attachment:indexing',
|
ATTACHMENT_INDEXING: 'attachment:indexing',
|
||||||
|
|||||||
@@ -53,7 +53,14 @@ export function PagePermissionItem({
|
|||||||
{isCurrentUser && <Text span c="dimmed"> ({t("You")})</Text>}
|
{isCurrentUser && <Text span c="dimmed"> ({t("You")})</Text>}
|
||||||
</AutoTooltipText>
|
</AutoTooltipText>
|
||||||
<AutoTooltipText fz="xs" c="dimmed">
|
<AutoTooltipText fz="xs" c="dimmed">
|
||||||
{member.type === "user" ? member.email : formatMemberCount(member.memberCount, t)}
|
{member.type === "user"
|
||||||
|
? member.email
|
||||||
|
: member.isDefault
|
||||||
|
? // Page access still requires space membership, so the
|
||||||
|
// workspace-wide member count would overstate who can
|
||||||
|
// actually see the page.
|
||||||
|
t("Everyone with access to this space")
|
||||||
|
: formatMemberCount(member.memberCount, t)}
|
||||||
</AutoTooltipText>
|
</AutoTooltipText>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -166,6 +166,18 @@ export default function useAuth() {
|
|||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
setCurrentUser(RESET);
|
setCurrentUser(RESET);
|
||||||
await logout();
|
await logout();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (typeof indexedDB?.databases === "function") {
|
||||||
|
const dbs = await indexedDB.databases();
|
||||||
|
dbs
|
||||||
|
.filter((db) => db.name?.startsWith("page."))
|
||||||
|
.forEach((db) => indexedDB.deleteDatabase(db.name!));
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
window.location.replace(`${APP_ROUTE.AUTH.LOGIN}?logout=1`);
|
window.location.replace(`${APP_ROUTE.AUTH.LOGIN}?logout=1`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
} from "@/features/comment/atoms/comment-atom";
|
} from "@/features/comment/atoms/comment-atom";
|
||||||
import CommentEditor from "@/features/comment/components/comment-editor";
|
import CommentEditor from "@/features/comment/components/comment-editor";
|
||||||
import CommentActions from "@/features/comment/components/comment-actions";
|
import CommentActions from "@/features/comment/components/comment-actions";
|
||||||
|
import { CommentErrorBoundary } from "@/features/comment/components/comment-error-boundary";
|
||||||
import { currentUserAtom } from "@/features/user/atoms/current-user-atom";
|
import { currentUserAtom } from "@/features/user/atoms/current-user-atom";
|
||||||
import { useCreateCommentMutation } from "@/features/comment/queries/comment-query";
|
import { useCreateCommentMutation } from "@/features/comment/queries/comment-query";
|
||||||
import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom";
|
import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom";
|
||||||
@@ -170,6 +171,7 @@ function CommentDialog({ editor, pageId, readOnly }: CommentDialogProps) {
|
|||||||
</div>
|
</div>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
<CommentErrorBoundary>
|
||||||
<CommentEditor
|
<CommentEditor
|
||||||
onUpdate={handleCommentEditorChange}
|
onUpdate={handleCommentEditorChange}
|
||||||
onSave={handleAddComment}
|
onSave={handleAddComment}
|
||||||
@@ -178,6 +180,7 @@ function CommentDialog({ editor, pageId, readOnly }: CommentDialogProps) {
|
|||||||
autofocus={true}
|
autofocus={true}
|
||||||
/>
|
/>
|
||||||
<CommentActions onSave={handleAddComment} isLoading={isPending} />
|
<CommentActions onSave={handleAddComment} isLoading={isPending} />
|
||||||
|
</CommentErrorBoundary>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { EditorContent, ReactNodeViewRenderer, useEditor } from "@tiptap/react";
|
import { EditorContent, ReactNodeViewRenderer, useEditor } from "@tiptap/react";
|
||||||
import { Placeholder } from "@tiptap/extension-placeholder";
|
import { Placeholder } from "@tiptap/extension-placeholder";
|
||||||
import { StarterKit } from "@tiptap/starter-kit";
|
import { StarterKit } from "@tiptap/starter-kit";
|
||||||
import { Mention, LinkExtension } from "@docmost/editor-ext";
|
import { TextStyle } from "@tiptap/extension-text-style";
|
||||||
|
import { Mention, LinkExtension, Color } from "@docmost/editor-ext";
|
||||||
import classes from "./comment.module.css";
|
import classes from "./comment.module.css";
|
||||||
import { useFocusWithin } from "@mantine/hooks";
|
import { useFocusWithin } from "@mantine/hooks";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
@@ -11,6 +12,8 @@ import EmojiCommand from "@/features/editor/extensions/emoji-command";
|
|||||||
import mentionRenderItems from "@/features/editor/components/mention/mention-suggestion";
|
import mentionRenderItems from "@/features/editor/components/mention/mention-suggestion";
|
||||||
import MentionView from "@/features/editor/components/mention/mention-view";
|
import MentionView from "@/features/editor/components/mention/mention-view";
|
||||||
import { platformModifierKey } from "@/lib";
|
import { platformModifierKey } from "@/lib";
|
||||||
|
import { TableKit } from "@tiptap/extension-table";
|
||||||
|
import { TaskList, TaskItem } from "@tiptap/extension-list";
|
||||||
|
|
||||||
interface CommentEditorProps {
|
interface CommentEditorProps {
|
||||||
defaultContent?: any;
|
defaultContent?: any;
|
||||||
@@ -49,6 +52,8 @@ const CommentEditor = forwardRef(
|
|||||||
placeholder: placeholder || t("Reply..."),
|
placeholder: placeholder || t("Reply..."),
|
||||||
}),
|
}),
|
||||||
LinkExtension,
|
LinkExtension,
|
||||||
|
TextStyle,
|
||||||
|
Color,
|
||||||
EmojiCommand,
|
EmojiCommand,
|
||||||
Mention.configure({
|
Mention.configure({
|
||||||
suggestion: {
|
suggestion: {
|
||||||
@@ -66,6 +71,11 @@ const CommentEditor = forwardRef(
|
|||||||
return ReactNodeViewRenderer(MentionView);
|
return ReactNodeViewRenderer(MentionView);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
TableKit,
|
||||||
|
TaskList,
|
||||||
|
TaskItem.configure({
|
||||||
|
nested: true,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
editorProps: {
|
editorProps: {
|
||||||
attributes: {
|
attributes: {
|
||||||
@@ -113,7 +123,12 @@ const CommentEditor = forwardRef(
|
|||||||
// websocket on another browser). Skip for editable editors to avoid
|
// websocket on another browser). Skip for editable editors to avoid
|
||||||
// resetting the cursor position on every keystroke.
|
// resetting the cursor position on every keystroke.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!editable && commentEditor && !commentEditor.isDestroyed && defaultContent) {
|
if (
|
||||||
|
!editable &&
|
||||||
|
commentEditor &&
|
||||||
|
!commentEditor.isDestroyed &&
|
||||||
|
defaultContent
|
||||||
|
) {
|
||||||
commentEditor.commands.setContent(defaultContent);
|
commentEditor.commands.setContent(defaultContent);
|
||||||
}
|
}
|
||||||
}, [defaultContent, editable, commentEditor]);
|
}, [defaultContent, editable, commentEditor]);
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { ReactNode } from "react";
|
||||||
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
|
import { Button } from "@mantine/core";
|
||||||
|
import { IconAlertTriangle } from "@tabler/icons-react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { EmptyState } from "@/components/ui/empty-state.tsx";
|
||||||
|
|
||||||
|
type CommentErrorBoundaryProps = {
|
||||||
|
children: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Contain comment-editor render throws (e.g. schema errors) so they don't unmount the whole app.
|
||||||
|
export function CommentErrorBoundary({ children }: CommentErrorBoundaryProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ErrorBoundary
|
||||||
|
fallbackRender={({ resetErrorBoundary }) => (
|
||||||
|
<EmptyState
|
||||||
|
icon={IconAlertTriangle}
|
||||||
|
title={t("Failed to load comments. An error occurred.")}
|
||||||
|
action={
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
size="sm"
|
||||||
|
mt="xs"
|
||||||
|
onClick={resetErrorBoundary}
|
||||||
|
>
|
||||||
|
{t("Try again")}
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</ErrorBoundary>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -53,6 +53,10 @@
|
|||||||
margin-block-end: 0;
|
margin-block-end: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ProseMirror :global(.tableWrapper) table {
|
||||||
|
min-width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ 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";
|
||||||
import { TextStyle } from "@tiptap/extension-text-style";
|
import { TextStyle } from "@tiptap/extension-text-style";
|
||||||
import { Color } from "@tiptap/extension-color";
|
|
||||||
import { Youtube } from "@tiptap/extension-youtube";
|
import { Youtube } from "@tiptap/extension-youtube";
|
||||||
import SlashCommand, {
|
import SlashCommand, {
|
||||||
SlashCommandExtension as Command,
|
SlashCommandExtension as Command,
|
||||||
@@ -54,6 +53,7 @@ import {
|
|||||||
Subpages,
|
Subpages,
|
||||||
Heading,
|
Heading,
|
||||||
Highlight,
|
Highlight,
|
||||||
|
Color,
|
||||||
Indent,
|
Indent,
|
||||||
UniqueID,
|
UniqueID,
|
||||||
SharedStorage,
|
SharedStorage,
|
||||||
|
|||||||
@@ -1,6 +1,46 @@
|
|||||||
/* Highlight colors with dark mode support */
|
/* Highlight colors with dark mode support */
|
||||||
|
|
||||||
.ProseMirror {
|
.ProseMirror {
|
||||||
|
@mixin dark {
|
||||||
|
/* Arbitrary (imported) colors have no hand-tuned dark variant, so derive
|
||||||
|
one: cap lightness and chroma so the fill sits on the dark surface.
|
||||||
|
Our own palette opts out and keeps the values below. */
|
||||||
|
mark[data-color]:not(
|
||||||
|
[data-color="#98d8f2" i],
|
||||||
|
[data-color="#7edb6c" i],
|
||||||
|
[data-color="#e0d6ed" i],
|
||||||
|
[data-color="#ffc6c2" i],
|
||||||
|
[data-color="#faf594" i],
|
||||||
|
[data-color="#f5c8a9" i],
|
||||||
|
[data-color="#f5cfe0" i],
|
||||||
|
[data-color="#dfdfd7" i],
|
||||||
|
[data-color="#d7c4b7" i]
|
||||||
|
) {
|
||||||
|
background-color: oklch(
|
||||||
|
from var(--mark-bg, #fff) min(l, clamp(0.28, calc(1.22 - l), 0.45))
|
||||||
|
min(calc(c * 1.8), 0.09) h
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Imported text colors are picked for a light page and go unreadable on
|
||||||
|
the dark surface, so lift their lightness. */
|
||||||
|
span[data-text-color]:not(
|
||||||
|
[data-text-color="#2563EB" i],
|
||||||
|
[data-text-color="#008A00" i],
|
||||||
|
[data-text-color="#9333EA" i],
|
||||||
|
[data-text-color="#E00000" i],
|
||||||
|
[data-text-color="#EAB308" i],
|
||||||
|
[data-text-color="#FFA500" i],
|
||||||
|
[data-text-color="#BA4081" i],
|
||||||
|
[data-text-color="#A8A29E" i],
|
||||||
|
[data-text-color="#92400E" i]
|
||||||
|
) {
|
||||||
|
color: oklch(
|
||||||
|
from var(--text-color, currentcolor) max(l, 0.72) min(c, 0.16) h
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Blue */
|
/* Blue */
|
||||||
mark[data-color="#98d8f2"] {
|
mark[data-color="#98d8f2"] {
|
||||||
background-color: light-dark(
|
background-color: light-dark(
|
||||||
|
|||||||
@@ -86,6 +86,16 @@
|
|||||||
.ProseMirror {
|
.ProseMirror {
|
||||||
table {
|
table {
|
||||||
@mixin dark {
|
@mixin dark {
|
||||||
|
/* Arbitrary (imported) colors: derive a dark variant; the hand-tuned
|
||||||
|
palette rules below override this for native colors. */
|
||||||
|
td[data-background-color],
|
||||||
|
th[data-background-color] {
|
||||||
|
background-color: oklch(
|
||||||
|
from var(--cell-bg, #fff) min(l, clamp(0.28, calc(1.22 - l), 0.45))
|
||||||
|
min(calc(c * 1.8), 0.09) h
|
||||||
|
) !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* Blue */
|
/* Blue */
|
||||||
td[data-background-color="#b4d5ff"],
|
td[data-background-color="#b4d5ff"],
|
||||||
th[data-background-color="#b4d5ff"] {
|
th[data-background-color="#b4d5ff"] {
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ export function isCloud(): boolean {
|
|||||||
return castToBoolean(getConfigValue("CLOUD"));
|
return castToBoolean(getConfigValue("CLOUD"));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAiVectorDriver(): string {
|
export function isBetaConfluenceImporter(): boolean {
|
||||||
return getConfigValue("AI_VECTOR_DRIVER");
|
return castToBoolean(getConfigValue("BETA_CONFLUENCE_IMPORTER"));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAvatarUrl(
|
export function getAvatarUrl(
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
BILLING_TRIAL_DAYS,
|
BILLING_TRIAL_DAYS,
|
||||||
POSTHOG_HOST,
|
POSTHOG_HOST,
|
||||||
POSTHOG_KEY,
|
POSTHOG_KEY,
|
||||||
AI_VECTOR_DRIVER,
|
BETA_CONFLUENCE_IMPORTER,
|
||||||
} = loadEnv(mode, envPath, "");
|
} = loadEnv(mode, envPath, "");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -32,7 +32,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
BILLING_TRIAL_DAYS,
|
BILLING_TRIAL_DAYS,
|
||||||
POSTHOG_HOST,
|
POSTHOG_HOST,
|
||||||
POSTHOG_KEY,
|
POSTHOG_KEY,
|
||||||
AI_VECTOR_DRIVER,
|
BETA_CONFLUENCE_IMPORTER
|
||||||
},
|
},
|
||||||
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
||||||
},
|
},
|
||||||
@@ -57,6 +57,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
|
allowedHosts: ['docmost.nz'],
|
||||||
proxy: {
|
proxy: {
|
||||||
"/api": {
|
"/api": {
|
||||||
target: APP_URL,
|
target: APP_URL,
|
||||||
|
|||||||
+11
-11
@@ -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": "10.1.2",
|
||||||
"@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.30.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.28",
|
||||||
"@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.28",
|
||||||
"@nestjs/platform-socket.io": "11.2.1",
|
"@nestjs/platform-socket.io": "11.1.28",
|
||||||
"@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.28",
|
||||||
"@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",
|
||||||
@@ -78,6 +77,7 @@
|
|||||||
"class-validator": "0.15.1",
|
"class-validator": "0.15.1",
|
||||||
"cookie": "1.1.1",
|
"cookie": "1.1.1",
|
||||||
"csv-stringify": "6.8.0",
|
"csv-stringify": "6.8.0",
|
||||||
|
"entities": "7.0.1",
|
||||||
"fast-bm25": "0.0.5",
|
"fast-bm25": "0.0.5",
|
||||||
"fastify-ip": "2.0.0",
|
"fastify-ip": "2.0.0",
|
||||||
"fs-extra": "11.3.4",
|
"fs-extra": "11.3.4",
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
"tmp-promise": "3.0.3",
|
"tmp-promise": "3.0.3",
|
||||||
"typesense": "3.0.5",
|
"typesense": "3.0.5",
|
||||||
"undici": "7.29.0",
|
"undici": "7.29.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"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
|
|||||||
import { HealthModule } from './integrations/health/health.module';
|
import { HealthModule } from './integrations/health/health.module';
|
||||||
import { ExportModule } from './integrations/export/export.module';
|
import { ExportModule } from './integrations/export/export.module';
|
||||||
import { ImportModule } from './integrations/import/import.module';
|
import { ImportModule } from './integrations/import/import.module';
|
||||||
|
import { ImportProcessorModule } from './integrations/import/import-processor.module';
|
||||||
import { SecurityModule } from './integrations/security/security.module';
|
import { SecurityModule } from './integrations/security/security.module';
|
||||||
import { TelemetryModule } from './integrations/telemetry/telemetry.module';
|
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';
|
||||||
@@ -63,20 +63,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],
|
||||||
@@ -87,6 +77,7 @@ try {
|
|||||||
StaticModule,
|
StaticModule,
|
||||||
HealthModule,
|
HealthModule,
|
||||||
ImportModule,
|
ImportModule,
|
||||||
|
ImportProcessorModule,
|
||||||
ExportModule,
|
ExportModule,
|
||||||
StorageModule.forRootAsync({
|
StorageModule.forRootAsync({
|
||||||
imports: [EnvironmentModule],
|
imports: [EnvironmentModule],
|
||||||
|
|||||||
@@ -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)}`,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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';
|
||||||
import { TextStyle } from '@tiptap/extension-text-style';
|
import { TextStyle } from '@tiptap/extension-text-style';
|
||||||
import { Color } from '@tiptap/extension-color';
|
|
||||||
import { Youtube } from '@tiptap/extension-youtube';
|
import { Youtube } from '@tiptap/extension-youtube';
|
||||||
import { TaskList, TaskItem } from '@tiptap/extension-list';
|
import { TaskList, TaskItem } from '@tiptap/extension-list';
|
||||||
import {
|
import {
|
||||||
@@ -36,6 +35,7 @@ import {
|
|||||||
Mention,
|
Mention,
|
||||||
Subpages,
|
Subpages,
|
||||||
Highlight,
|
Highlight,
|
||||||
|
Color,
|
||||||
Indent,
|
Indent,
|
||||||
UniqueID,
|
UniqueID,
|
||||||
Columns,
|
Columns,
|
||||||
@@ -57,7 +57,6 @@ import {
|
|||||||
JSONContent,
|
JSONContent,
|
||||||
} from '@tiptap/core';
|
} 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
|
||||||
@@ -147,7 +146,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) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export const Feature = {
|
|||||||
PAGE_PERMISSIONS: 'page:permissions',
|
PAGE_PERMISSIONS: 'page:permissions',
|
||||||
AI: 'ai',
|
AI: 'ai',
|
||||||
CONFLUENCE_IMPORT: 'import:confluence',
|
CONFLUENCE_IMPORT: 'import:confluence',
|
||||||
|
CONFLUENCE_API_IMPORT: 'import:confluence-api',
|
||||||
DOCX_IMPORT: 'import:docx',
|
DOCX_IMPORT: 'import:docx',
|
||||||
PDF_IMPORT: 'import:pdf',
|
PDF_IMPORT: 'import:pdf',
|
||||||
ATTACHMENT_INDEXING: 'attachment:indexing',
|
ATTACHMENT_INDEXING: 'attachment:indexing',
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -175,44 +175,7 @@ export class PageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async nextPagePosition(spaceId: string, parentPageId?: string) {
|
async nextPagePosition(spaceId: string, parentPageId?: string) {
|
||||||
let pagePosition: string;
|
return this.pageRepo.nextPagePosition(spaceId, parentPageId);
|
||||||
|
|
||||||
const lastPageQuery = this.db
|
|
||||||
.selectFrom('pages')
|
|
||||||
.select(['position'])
|
|
||||||
.where('spaceId', '=', spaceId)
|
|
||||||
.where('deletedAt', 'is', null)
|
|
||||||
.orderBy('position', (ob) => ob.collate('C').desc())
|
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
if (parentPageId) {
|
|
||||||
// check for children of this page
|
|
||||||
const lastPage = await lastPageQuery
|
|
||||||
.where('parentPageId', '=', parentPageId)
|
|
||||||
.executeTakeFirst();
|
|
||||||
|
|
||||||
if (!lastPage) {
|
|
||||||
pagePosition = generateJitteredKeyBetween(null, null);
|
|
||||||
} else {
|
|
||||||
// if there is an existing page, we should get a position below it
|
|
||||||
pagePosition = generateJitteredKeyBetween(lastPage.position, null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// for root page
|
|
||||||
const lastPage = await lastPageQuery
|
|
||||||
.where('parentPageId', 'is', null)
|
|
||||||
.executeTakeFirst();
|
|
||||||
|
|
||||||
// if no existing page, make this the first
|
|
||||||
if (!lastPage) {
|
|
||||||
pagePosition = generateJitteredKeyBetween(null, null); // we expect "a0"
|
|
||||||
} else {
|
|
||||||
// if there is an existing page, we should get a position below it
|
|
||||||
pagePosition = generateJitteredKeyBetween(lastPage.position, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pagePosition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(
|
async update(
|
||||||
@@ -496,21 +459,10 @@ export class PageService {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.aiQueue.add(
|
await this.aiQueue.add(QueueJob.PAGE_MOVED_TO_SPACE, {
|
||||||
QueueJob.PAGE_MOVED_TO_SPACE,
|
|
||||||
{
|
|
||||||
pageIds: pageIdsToMove,
|
pageIds: pageIdsToMove,
|
||||||
spaceId,
|
|
||||||
workspaceId: rootPage.workspaceId,
|
workspaceId: rootPage.workspaceId,
|
||||||
},
|
});
|
||||||
{
|
|
||||||
attempts: 2,
|
|
||||||
backoff: {
|
|
||||||
type: 'fixed',
|
|
||||||
delay: 2 * 60 * 1000,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -339,25 +339,15 @@ export class SpaceMemberService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await executeTx(this.db, async (trx) => {
|
|
||||||
await trx
|
|
||||||
.selectFrom('spaces')
|
|
||||||
.select('id')
|
|
||||||
.where('id', '=', dto.spaceId)
|
|
||||||
.forUpdate()
|
|
||||||
.executeTakeFirst();
|
|
||||||
|
|
||||||
if (spaceMember.role === SpaceRole.ADMIN) {
|
if (spaceMember.role === SpaceRole.ADMIN) {
|
||||||
await this.validateLastAdmin(dto.spaceId, trx);
|
await this.validateLastAdmin(dto.spaceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.spaceMemberRepo.updateSpaceMember(
|
await this.spaceMemberRepo.updateSpaceMember(
|
||||||
{ role: dto.role },
|
{ role: dto.role },
|
||||||
spaceMember.id,
|
spaceMember.id,
|
||||||
dto.spaceId,
|
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(
|
||||||
|
|||||||
@@ -396,10 +396,7 @@ export class WorkspaceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (updateWorkspaceDto.aiSearch) {
|
||||||
updateWorkspaceDto.aiSearch &&
|
|
||||||
this.environmentService.getAiVectorDriver() !== 'turbopuffer'
|
|
||||||
) {
|
|
||||||
const tableExists = await isPageEmbeddingsTableExists(this.db);
|
const tableExists = await isPageEmbeddingsTableExists(this.db);
|
||||||
if (!tableExists) {
|
if (!tableExists) {
|
||||||
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 {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
|
|||||||
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
||||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||||
import { EventName } from '../../../common/events/event.contants';
|
import { EventName } from '../../../common/events/event.contants';
|
||||||
|
import { generateJitteredKeyBetween } from 'fractional-indexing-jittered';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PageRepo {
|
export class PageRepo {
|
||||||
@@ -605,4 +606,27 @@ export class PageRepo {
|
|||||||
.execute()
|
.execute()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async nextPagePosition(
|
||||||
|
spaceId: string,
|
||||||
|
parentPageId?: string,
|
||||||
|
): Promise<string> {
|
||||||
|
const lastPageQuery = this.db
|
||||||
|
.selectFrom('pages')
|
||||||
|
.select(['position'])
|
||||||
|
.where('spaceId', '=', spaceId)
|
||||||
|
.where('deletedAt', 'is', null)
|
||||||
|
.orderBy('position', (ob) => ob.collate('C').desc())
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
const lastPage = parentPageId
|
||||||
|
? await lastPageQuery
|
||||||
|
.where('parentPageId', '=', parentPageId)
|
||||||
|
.executeTakeFirst()
|
||||||
|
: await lastPageQuery
|
||||||
|
.where('parentPageId', 'is', null)
|
||||||
|
.executeTakeFirst();
|
||||||
|
|
||||||
|
return generateJitteredKeyBetween(lastPage?.position ?? null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,10 +46,8 @@ export class SpaceMemberRepo {
|
|||||||
updatableSpaceMember: UpdatableSpaceMember,
|
updatableSpaceMember: UpdatableSpaceMember,
|
||||||
spaceMemberId: string,
|
spaceMemberId: string,
|
||||||
spaceId: string,
|
spaceId: string,
|
||||||
trx?: KyselyTransaction,
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const db = dbOrTx(this.db, trx);
|
await this.db
|
||||||
await db
|
|
||||||
.updateTable('spaceMembers')
|
.updateTable('spaceMembers')
|
||||||
.set(updatableSpaceMember)
|
.set(updatableSpaceMember)
|
||||||
.where('id', '=', spaceMemberId)
|
.where('id', '=', spaceMemberId)
|
||||||
@@ -94,13 +92,8 @@ export class SpaceMemberRepo {
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
async roleCountBySpaceId(
|
async roleCountBySpaceId(role: string, spaceId: string): Promise<number> {
|
||||||
role: string,
|
const { count } = await this.db
|
||||||
spaceId: string,
|
|
||||||
trx?: KyselyTransaction,
|
|
||||||
): Promise<number> {
|
|
||||||
const db = dbOrTx(this.db, trx);
|
|
||||||
const { count } = await db
|
|
||||||
.selectFrom('spaceMembers')
|
.selectFrom('spaceMembers')
|
||||||
.select((eb) => eb.fn.count('role').as('count'))
|
.select((eb) => eb.fn.count('role').as('count'))
|
||||||
.where('role', '=', role)
|
.where('role', '=', role)
|
||||||
|
|||||||
@@ -230,7 +230,6 @@ export class SpaceRepo {
|
|||||||
|
|
||||||
this.eventEmitter.emit(EventName.SPACE_DELETED, {
|
this.eventEmitter.emit(EventName.SPACE_DELETED, {
|
||||||
spaceId,
|
spaceId,
|
||||||
workspaceId,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,24 +211,6 @@ export class WorkspaceRepo {
|
|||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateAiEmbeddingFingerprint(
|
|
||||||
workspaceId: string,
|
|
||||||
fingerprint: { driver: string; model: string; dimensions: number },
|
|
||||||
trx?: KyselyTransaction,
|
|
||||||
) {
|
|
||||||
const db = dbOrTx(this.db, trx);
|
|
||||||
return db
|
|
||||||
.updateTable('workspaces')
|
|
||||||
.set({
|
|
||||||
settings: sql`COALESCE(settings, '{}'::jsonb)
|
|
||||||
|| jsonb_build_object('ai', COALESCE(settings->'ai', '{}'::jsonb)
|
|
||||||
|| jsonb_build_object('embedding', ${JSON.stringify(fingerprint)}::text::jsonb))`,
|
|
||||||
updatedAt: new Date(),
|
|
||||||
})
|
|
||||||
.where('id', '=', workspaceId)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateSharingSettings(
|
async updateSharingSettings(
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
prefKey: string,
|
prefKey: string,
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { Json, Timestamp, Generated } from '@docmost/db/types/db';
|
||||||
|
|
||||||
|
export interface ConfluenceApiImports {
|
||||||
|
id: Generated<string>;
|
||||||
|
fileTaskId: string;
|
||||||
|
siteUrl: string;
|
||||||
|
authType: string;
|
||||||
|
authEmail: string | null;
|
||||||
|
authToken: string | null;
|
||||||
|
authUsername: string | null;
|
||||||
|
totalSpaces: Generated<number>;
|
||||||
|
importedSpaces: Generated<number>;
|
||||||
|
totalPages: Generated<number>;
|
||||||
|
importedPages: Generated<number>;
|
||||||
|
totalUsers: Generated<number>;
|
||||||
|
importedUsers: Generated<number>;
|
||||||
|
totalAttachments: Generated<number>;
|
||||||
|
importedAttachments: Generated<number>;
|
||||||
|
totalLabels: Generated<number>;
|
||||||
|
importedLabels: Generated<number>;
|
||||||
|
totalGroups: Generated<number>;
|
||||||
|
importedGroups: Generated<number>;
|
||||||
|
totalRestrictedPages: Generated<number>;
|
||||||
|
importedRestrictedPages: Generated<number>;
|
||||||
|
idMapping: Generated<Json>;
|
||||||
|
warnings: Generated<Json>;
|
||||||
|
currentPhase: string | null;
|
||||||
|
cancelled: Generated<boolean>;
|
||||||
|
spaceKeys: Generated<Json>;
|
||||||
|
workspaceId: string;
|
||||||
|
creatorId: string | null;
|
||||||
|
createdAt: Generated<Timestamp>;
|
||||||
|
updatedAt: Generated<Timestamp>;
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import { DB } from '@docmost/db/types/db';
|
import { DB } from '@docmost/db/types/db';
|
||||||
import { PageEmbeddings } from '@docmost/db/types/embeddings.types';
|
import { PageEmbeddings } from '@docmost/db/types/embeddings.types';
|
||||||
|
import { ConfluenceApiImports } from './custom.types';
|
||||||
|
|
||||||
export interface DbInterface extends DB {
|
export interface DbInterface extends DB {
|
||||||
pageEmbeddings: PageEmbeddings;
|
pageEmbeddings: PageEmbeddings;
|
||||||
|
confluenceApiImports: ConfluenceApiImports;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule apps/server/src/ee updated: 6dfbcb9241...3a5ead292e
@@ -214,6 +214,13 @@ export class EnvironmentService {
|
|||||||
return !this.isCloud();
|
return !this.isCloud();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isBetaConfluenceImporter(): boolean {
|
||||||
|
const flag = this.configService
|
||||||
|
.get<string>('BETA_CONFLUENCE_IMPORTER', 'false')
|
||||||
|
.toLowerCase();
|
||||||
|
return flag === 'true';
|
||||||
|
}
|
||||||
|
|
||||||
getStripePublishableKey(): string {
|
getStripePublishableKey(): string {
|
||||||
return this.configService.get<string>('STRIPE_PUBLISHABLE_KEY');
|
return this.configService.get<string>('STRIPE_PUBLISHABLE_KEY');
|
||||||
}
|
}
|
||||||
@@ -310,31 +317,6 @@ export class EnvironmentService {
|
|||||||
return val === 'true';
|
return val === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
getAiVectorDriver(): string {
|
|
||||||
return this.configService
|
|
||||||
.get<string>('AI_VECTOR_DRIVER', 'pgvector')
|
|
||||||
.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
getTurbopufferApiKey(): string {
|
|
||||||
return this.configService.get<string>('TURBOPUFFER_API_KEY');
|
|
||||||
}
|
|
||||||
|
|
||||||
getTurbopufferRegion(): string {
|
|
||||||
return this.configService.get<string>('TURBOPUFFER_REGION');
|
|
||||||
}
|
|
||||||
|
|
||||||
getTurbopufferBaseUrl(): string {
|
|
||||||
return this.configService.get<string>('TURBOPUFFER_BASE_URL');
|
|
||||||
}
|
|
||||||
|
|
||||||
getTurbopufferNamespacePrefix(): string {
|
|
||||||
return this.configService.get<string>(
|
|
||||||
'TURBOPUFFER_NAMESPACE_PREFIX',
|
|
||||||
'docmost',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getOpenAiApiKey(): string {
|
getOpenAiApiKey(): string {
|
||||||
return this.configService.get<string>('OPENAI_API_KEY');
|
return this.configService.get<string>('OPENAI_API_KEY');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
IsUrl,
|
IsUrl,
|
||||||
Matches,
|
|
||||||
MinLength,
|
MinLength,
|
||||||
ValidateIf,
|
ValidateIf,
|
||||||
validateSync,
|
validateSync,
|
||||||
@@ -109,41 +108,6 @@ export class EnvironmentVariables {
|
|||||||
@IsString()
|
@IsString()
|
||||||
AI_DRIVER: string;
|
AI_DRIVER: string;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@ValidateIf((obj) => obj.AI_VECTOR_DRIVER)
|
|
||||||
@IsIn(['pgvector', 'turbopuffer'])
|
|
||||||
@IsString()
|
|
||||||
AI_VECTOR_DRIVER: string;
|
|
||||||
|
|
||||||
@ValidateIf((obj) => obj.AI_VECTOR_DRIVER === 'turbopuffer')
|
|
||||||
@IsNotEmpty()
|
|
||||||
@IsString()
|
|
||||||
TURBOPUFFER_API_KEY: string;
|
|
||||||
|
|
||||||
@ValidateIf(
|
|
||||||
(obj) =>
|
|
||||||
obj.AI_VECTOR_DRIVER === 'turbopuffer' && !obj.TURBOPUFFER_BASE_URL,
|
|
||||||
)
|
|
||||||
@IsNotEmpty({
|
|
||||||
message:
|
|
||||||
'TURBOPUFFER_REGION is required when AI_VECTOR_DRIVER is turbopuffer, unless TURBOPUFFER_BASE_URL is set',
|
|
||||||
})
|
|
||||||
@IsString()
|
|
||||||
TURBOPUFFER_REGION: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@ValidateIf((obj) => obj.TURBOPUFFER_BASE_URL != '' && obj.TURBOPUFFER_BASE_URL != null)
|
|
||||||
@IsUrl({ protocols: ['http', 'https'], require_tld: false })
|
|
||||||
TURBOPUFFER_BASE_URL: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsString()
|
|
||||||
@Matches(/^[A-Za-z0-9\-_.]{1,90}$/, {
|
|
||||||
message:
|
|
||||||
'TURBOPUFFER_NAMESPACE_PREFIX may only contain letters, digits, dot, dash, underscore (max 90 chars)',
|
|
||||||
})
|
|
||||||
TURBOPUFFER_NAMESPACE_PREFIX: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
AI_EMBEDDING_MODEL: string;
|
AI_EMBEDDING_MODEL: string;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { EnvironmentService } from '../environment/environment.service';
|
import { EnvironmentService } from '../environment/environment.service';
|
||||||
import { Redis } from 'ioredis';
|
import { Redis } from 'ioredis';
|
||||||
import { parseRedisUrl } from '../../common/helpers';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RedisHealthIndicator {
|
export class RedisHealthIndicator {
|
||||||
@@ -20,10 +19,8 @@ export class RedisHealthIndicator {
|
|||||||
const indicator = this.healthIndicatorService.check(key);
|
const indicator = this.healthIndicatorService.check(key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const redisUrl = this.environmentService.getRedisUrl();
|
const redis = new Redis(this.environmentService.getRedisUrl(), {
|
||||||
const redis = new Redis(redisUrl, {
|
|
||||||
maxRetriesPerRequest: 15,
|
maxRetriesPerRequest: 15,
|
||||||
tls: parseRedisUrl(redisUrl).tls,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await redis.ping();
|
await redis.ping();
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ImportModule } from './import.module';
|
||||||
|
import { FileTaskProcessor } from './processors/file-task.processor';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [ImportModule],
|
||||||
|
providers: [FileTaskProcessor],
|
||||||
|
})
|
||||||
|
export class ImportProcessorModule {}
|
||||||
@@ -3,19 +3,13 @@ import { ImportService } from './services/import.service';
|
|||||||
import { ImportController } from './import.controller';
|
import { ImportController } from './import.controller';
|
||||||
import { StorageModule } from '../storage/storage.module';
|
import { StorageModule } from '../storage/storage.module';
|
||||||
import { FileImportTaskService } from './services/file-import-task.service';
|
import { FileImportTaskService } from './services/file-import-task.service';
|
||||||
import { FileTaskProcessor } from './processors/file-task.processor';
|
|
||||||
import { ImportAttachmentService } from './services/import-attachment.service';
|
import { ImportAttachmentService } from './services/import-attachment.service';
|
||||||
import { FileTaskController } from './file-task.controller';
|
import { FileTaskController } from './file-task.controller';
|
||||||
import { PageModule } from '../../core/page/page.module';
|
import { PageModule } from '../../core/page/page.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
providers: [
|
providers: [ImportService, FileImportTaskService, ImportAttachmentService],
|
||||||
ImportService,
|
exports: [ImportService, ImportAttachmentService, FileImportTaskService],
|
||||||
FileImportTaskService,
|
|
||||||
FileTaskProcessor,
|
|
||||||
ImportAttachmentService,
|
|
||||||
],
|
|
||||||
exports: [ImportService, ImportAttachmentService],
|
|
||||||
controllers: [ImportController, FileTaskController],
|
controllers: [ImportController, FileTaskController],
|
||||||
imports: [StorageModule, PageModule],
|
imports: [StorageModule, PageModule],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ export class FileTaskProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
case QueueJob.IMPORT_TASK:
|
case QueueJob.IMPORT_TASK:
|
||||||
await this.fileTaskService.processZIpImport(job.data.fileTaskId);
|
await this.fileTaskService.processZIpImport(job.data.fileTaskId);
|
||||||
break;
|
break;
|
||||||
|
case QueueJob.CONFLUENCE_API_IMPORT:
|
||||||
|
await this.processConfluenceApiImport(job.data.fileTaskId);
|
||||||
|
break;
|
||||||
case QueueJob.PDF_EXPORT_TASK:
|
case QueueJob.PDF_EXPORT_TASK:
|
||||||
await this.processExportTask(job.data.fileTaskId);
|
await this.processExportTask(job.data.fileTaskId);
|
||||||
break;
|
break;
|
||||||
@@ -49,6 +52,19 @@ export class FileTaskProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getConfluenceApiImportService() {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
const mod = require('./../../../ee/confluence-api-import/confluence-api-import.service');
|
||||||
|
return this.moduleRef.get(mod.ConfluenceApiImportService, {
|
||||||
|
strict: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async processConfluenceApiImport(fileTaskId: string): Promise<void> {
|
||||||
|
const service = this.getConfluenceApiImportService();
|
||||||
|
await service.processImport(fileTaskId);
|
||||||
|
}
|
||||||
|
|
||||||
private async processExportTask(fileTaskId: string): Promise<void> {
|
private async processExportTask(fileTaskId: string): Promise<void> {
|
||||||
const pdfExportService = this.getPdfExportService();
|
const pdfExportService = this.getPdfExportService();
|
||||||
await pdfExportService.generateAndStorePdf(fileTaskId);
|
await pdfExportService.generateAndStorePdf(fileTaskId);
|
||||||
@@ -77,6 +93,8 @@ export class FileTaskProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
await this.handleFailedImportJob(job);
|
await this.handleFailedImportJob(job);
|
||||||
} else if (job.name === QueueJob.PDF_EXPORT_TASK) {
|
} else if (job.name === QueueJob.PDF_EXPORT_TASK) {
|
||||||
await this.handleFailedExportJob(job);
|
await this.handleFailedExportJob(job);
|
||||||
|
} else if (job.name === QueueJob.CONFLUENCE_API_IMPORT) {
|
||||||
|
await this.handleFailedExportJob(job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -452,16 +452,7 @@ export class ImportAttachmentService {
|
|||||||
|
|
||||||
const audioExtensions = new Set(['.mp3', '.wav', '.ogg', '.m4a', '.webm', '.flac', '.aac']);
|
const audioExtensions = new Set(['.mp3', '.wav', '.ogg', '.m4a', '.webm', '.flac', '.aac']);
|
||||||
|
|
||||||
if (ext === '.pdf') {
|
if (ext === '.mp4') {
|
||||||
const $pdf = $('<div>')
|
|
||||||
.attr('data-type', 'pdf')
|
|
||||||
.attr('src', apiFilePath)
|
|
||||||
.attr('data-attachment-id', attachmentId)
|
|
||||||
.attr('width', '800')
|
|
||||||
.attr('height', '600');
|
|
||||||
$a.replaceWith($pdf);
|
|
||||||
unwrapFromParagraph($, $pdf);
|
|
||||||
} else if (ext === '.mp4') {
|
|
||||||
const $video = $('<video>')
|
const $video = $('<video>')
|
||||||
.attr('src', apiFilePath)
|
.attr('src', apiFilePath)
|
||||||
.attr('data-attachment-id', attachmentId)
|
.attr('data-attachment-id', attachmentId)
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { nodeIdFromConfluenceAnchor } from './confluence-anchor-id';
|
||||||
|
|
||||||
|
describe('nodeIdFromConfluenceAnchor', () => {
|
||||||
|
it('is deterministic for the same (pageId, anchorName)', () => {
|
||||||
|
const a = nodeIdFromConfluenceAnchor('page-1', 'My Anchor');
|
||||||
|
const b = nodeIdFromConfluenceAnchor('page-1', 'My Anchor');
|
||||||
|
expect(a).toBe(b);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns different ids when the anchor name differs', () => {
|
||||||
|
const a = nodeIdFromConfluenceAnchor('page-1', 'one');
|
||||||
|
const b = nodeIdFromConfluenceAnchor('page-1', 'two');
|
||||||
|
expect(a).not.toBe(b);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns different ids when the pageId differs', () => {
|
||||||
|
const a = nodeIdFromConfluenceAnchor('page-1', 'same');
|
||||||
|
const b = nodeIdFromConfluenceAnchor('page-2', 'same');
|
||||||
|
expect(a).not.toBe(b);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns exactly 12 lowercase a-z characters', () => {
|
||||||
|
const id = nodeIdFromConfluenceAnchor('page-xyz', 'Section · 1');
|
||||||
|
expect(id).toHaveLength(12);
|
||||||
|
expect(id).toMatch(/^[a-z]{12}$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('treats an empty anchor name as a valid input', () => {
|
||||||
|
const id = nodeIdFromConfluenceAnchor('page-1', '');
|
||||||
|
expect(id).toMatch(/^[a-z]{12}$/);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { createHash } from 'crypto';
|
||||||
|
|
||||||
|
// Matches the alphabet used by generateNodeId() in
|
||||||
|
// packages/editor-ext/src/lib/utils.ts (customAlphabet from nanoid).
|
||||||
|
const ALPHABET = 'abcdefghijklmnopqrstuvwxyz';
|
||||||
|
const NODE_ID_LENGTH = 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a deterministic 12-character nodeId for a Confluence anchor.
|
||||||
|
* The same (pageId, anchorName) pair always produces the same result, so
|
||||||
|
* cross-page anchor links resolve to the anchor target without a
|
||||||
|
* precomputed map. The output uses the same alphabet and length as
|
||||||
|
* generateNodeId() from @docmost/editor-ext, so it is interchangeable
|
||||||
|
* with editor-generated nodeIds.
|
||||||
|
*/
|
||||||
|
export function nodeIdFromConfluenceAnchor(
|
||||||
|
pageId: string,
|
||||||
|
anchorName: string,
|
||||||
|
): string {
|
||||||
|
const digest = createHash('sha256')
|
||||||
|
.update(`${pageId}#${anchorName}`)
|
||||||
|
.digest();
|
||||||
|
let out = '';
|
||||||
|
for (let i = 0; i < NODE_ID_LENGTH; i++) {
|
||||||
|
out += ALPHABET[digest[i] % ALPHABET.length];
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { parseConfluenceEmojiId } from './confluence-emoji';
|
||||||
|
|
||||||
|
describe('parseConfluenceEmojiId', () => {
|
||||||
|
it('parses a single code point id', () => {
|
||||||
|
expect(parseConfluenceEmojiId('1f600')).toBe('😀');
|
||||||
|
expect(parseConfluenceEmojiId('1F600')).toBe('😀');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('parses a country flag (two regional indicator code points)', () => {
|
||||||
|
expect(parseConfluenceEmojiId('1f1f3-1f1ec')).toBe('🇳🇬');
|
||||||
|
expect(parseConfluenceEmojiId('1f1fa-1f1f8')).toBe('🇺🇸');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('parses a ZWJ sequence (three code points)', () => {
|
||||||
|
expect(parseConfluenceEmojiId('1f468-200d-1f4bb')).toBe('👨💻');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('parses a five-component family ZWJ sequence', () => {
|
||||||
|
// 👨👩👧👦 = man, ZWJ, woman, ZWJ, girl, ZWJ, boy
|
||||||
|
expect(parseConfluenceEmojiId('1f468-200d-1f469-200d-1f467-200d-1f466')).toBe(
|
||||||
|
'👨👩👧👦',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns null for missing input', () => {
|
||||||
|
expect(parseConfluenceEmojiId(undefined)).toBeNull();
|
||||||
|
expect(parseConfluenceEmojiId(null)).toBeNull();
|
||||||
|
expect(parseConfluenceEmojiId('')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns null when any segment is not pure hex', () => {
|
||||||
|
expect(parseConfluenceEmojiId('1f600-NG')).toBeNull();
|
||||||
|
expect(parseConfluenceEmojiId('not-hex')).toBeNull();
|
||||||
|
expect(parseConfluenceEmojiId('1f600--1f1ec')).toBeNull();
|
||||||
|
expect(parseConfluenceEmojiId('1f600 1f1ec')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns null when a segment parses to a non-positive value', () => {
|
||||||
|
expect(parseConfluenceEmojiId('0')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns null for code points outside the valid Unicode range', () => {
|
||||||
|
// 0x110000 is one past the highest valid code point.
|
||||||
|
expect(parseConfluenceEmojiId('110000')).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* Parse a Confluence emoji id (hex code points joined by hyphens) into a
|
||||||
|
* Unicode string. Confluence emits ids in both single- and multi-code-point
|
||||||
|
* forms:
|
||||||
|
*
|
||||||
|
* "1f600" → "😀"
|
||||||
|
* "1f1f3-1f1ec" → "🇳🇬" (flag: Nigeria)
|
||||||
|
* "1f468-200d-1f4bb" → "👨💻" (man technologist, ZWJ sequence)
|
||||||
|
*
|
||||||
|
* Returns null when the input is missing, empty, or doesn't parse cleanly as
|
||||||
|
* hyphen-separated hex code points.
|
||||||
|
*/
|
||||||
|
export function parseConfluenceEmojiId(
|
||||||
|
raw: string | undefined | null,
|
||||||
|
): string | null {
|
||||||
|
if (!raw) return null;
|
||||||
|
const parts = raw.split('-');
|
||||||
|
if (parts.length === 0) return null;
|
||||||
|
if (!parts.every((p) => /^[0-9a-fA-F]+$/.test(p))) return null;
|
||||||
|
const codePoints = parts.map((p) => parseInt(p, 16));
|
||||||
|
if (codePoints.some((cp) => !Number.isFinite(cp) || cp <= 0)) return null;
|
||||||
|
try {
|
||||||
|
return String.fromCodePoint(...codePoints);
|
||||||
|
} catch {
|
||||||
|
// Out-of-range code points throw RangeError on String.fromCodePoint.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { mapConfluenceHighlightColor } from './confluence-highlight-color';
|
||||||
|
|
||||||
|
describe('mapConfluenceHighlightColor', () => {
|
||||||
|
it('maps named DC colours to the Docmost table palette', () => {
|
||||||
|
expect(mapConfluenceHighlightColor('grey')).toEqual({
|
||||||
|
color: '#eaecef',
|
||||||
|
name: 'gray',
|
||||||
|
});
|
||||||
|
expect(mapConfluenceHighlightColor('red')).toEqual({
|
||||||
|
color: '#ffbead',
|
||||||
|
name: 'red',
|
||||||
|
});
|
||||||
|
expect(mapConfluenceHighlightColor('yellow')).toEqual({
|
||||||
|
color: '#fef1b4',
|
||||||
|
name: 'yellow',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is case- and whitespace-insensitive', () => {
|
||||||
|
expect(mapConfluenceHighlightColor(' Grey ')).toEqual({
|
||||||
|
color: '#eaecef',
|
||||||
|
name: 'gray',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('maps teal to the closest Docmost colour', () => {
|
||||||
|
expect(mapConfluenceHighlightColor('teal')).toEqual({
|
||||||
|
color: '#b4d5ff',
|
||||||
|
name: 'blue',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('passes hex values through untouched', () => {
|
||||||
|
expect(mapConfluenceHighlightColor('#f4f5f7')).toEqual({
|
||||||
|
color: '#f4f5f7',
|
||||||
|
});
|
||||||
|
expect(mapConfluenceHighlightColor('#4c9aff')).toEqual({
|
||||||
|
color: '#4c9aff',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
const CONFLUENCE_HIGHLIGHT_TO_DOCMOST: Record<
|
||||||
|
string,
|
||||||
|
{ color: string; name: string }
|
||||||
|
> = {
|
||||||
|
grey: { color: '#eaecef', name: 'gray' },
|
||||||
|
gray: { color: '#eaecef', name: 'gray' },
|
||||||
|
blue: { color: '#b4d5ff', name: 'blue' },
|
||||||
|
teal: { color: '#b4d5ff', name: 'blue' },
|
||||||
|
green: { color: '#acf5d2', name: 'green' },
|
||||||
|
yellow: { color: '#fef1b4', name: 'yellow' },
|
||||||
|
red: { color: '#ffbead', name: 'red' },
|
||||||
|
purple: { color: '#c1b7f2', name: 'purple' },
|
||||||
|
};
|
||||||
|
|
||||||
|
export function mapConfluenceHighlightColor(colour: string): {
|
||||||
|
color: string;
|
||||||
|
name?: string;
|
||||||
|
} {
|
||||||
|
return (
|
||||||
|
CONFLUENCE_HIGHLIGHT_TO_DOCMOST[colour.trim().toLowerCase()] ?? {
|
||||||
|
color: colour,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
import { load } from 'cheerio';
|
||||||
|
import { applyConfluenceMarginLeftIndent } from './confluence-indent';
|
||||||
|
|
||||||
|
function run(html: string): string {
|
||||||
|
const $ = load(html);
|
||||||
|
applyConfluenceMarginLeftIndent($, $.root());
|
||||||
|
// cheerio's html() includes <html><body>; return the body's inner HTML so
|
||||||
|
// tests can assert on the meaningful portion.
|
||||||
|
return $('body').html() ?? $.html();
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('applyConfluenceMarginLeftIndent', () => {
|
||||||
|
describe('Confluence Cloud (30 px per level, max 6)', () => {
|
||||||
|
it('maps 30/60/90/120/150/180 px to data-indent 1..6', () => {
|
||||||
|
const html =
|
||||||
|
'<p style="margin-left: 30.0px;">L1</p>' +
|
||||||
|
'<p style="margin-left: 60.0px;">L2</p>' +
|
||||||
|
'<p style="margin-left: 90.0px;">L3</p>' +
|
||||||
|
'<p style="margin-left: 120.0px;">L4</p>' +
|
||||||
|
'<p style="margin-left: 150.0px;">L5</p>' +
|
||||||
|
'<p style="margin-left: 180.0px;">L6</p>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).toContain('<p data-indent="1">L1</p>');
|
||||||
|
expect(out).toContain('<p data-indent="2">L2</p>');
|
||||||
|
expect(out).toContain('<p data-indent="3">L3</p>');
|
||||||
|
expect(out).toContain('<p data-indent="4">L4</p>');
|
||||||
|
expect(out).toContain('<p data-indent="5">L5</p>');
|
||||||
|
expect(out).toContain('<p data-indent="6">L6</p>');
|
||||||
|
expect(out).not.toContain('margin-left');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Confluence Data Center (40 px per level, no upper bound)', () => {
|
||||||
|
it('maps 40/80/120/160/200/240 px to data-indent 1..6', () => {
|
||||||
|
const html =
|
||||||
|
'<p style="margin-left: 40.0px;">one</p>' +
|
||||||
|
'<p style="margin-left: 80.0px;">two</p>' +
|
||||||
|
'<p style="margin-left: 120.0px;">three</p>' +
|
||||||
|
'<p style="margin-left: 160.0px;">four</p>' +
|
||||||
|
'<p style="margin-left: 200.0px;">five</p>' +
|
||||||
|
'<p style="margin-left: 240.0px;">six</p>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).toContain('<p data-indent="1">one</p>');
|
||||||
|
expect(out).toContain('<p data-indent="2">two</p>');
|
||||||
|
expect(out).toContain('<p data-indent="3">three</p>');
|
||||||
|
expect(out).toContain('<p data-indent="4">four</p>');
|
||||||
|
expect(out).toContain('<p data-indent="5">five</p>');
|
||||||
|
expect(out).toContain('<p data-indent="6">six</p>');
|
||||||
|
expect(out).not.toContain('margin-left');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('clamps DC levels above 8 down to 8', () => {
|
||||||
|
const html =
|
||||||
|
'<p style="margin-left: 320.0px;">L8</p>' +
|
||||||
|
'<p style="margin-left: 360.0px;">L9</p>' +
|
||||||
|
'<p style="margin-left: 600.0px;">L15</p>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).toContain('<p data-indent="8">L8</p>');
|
||||||
|
expect(out).toContain('<p data-indent="8">L9</p>');
|
||||||
|
expect(out).toContain('<p data-indent="8">L15</p>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('headings', () => {
|
||||||
|
it('handles indent on h1-h6 the same way as paragraphs', () => {
|
||||||
|
const html =
|
||||||
|
'<h1 style="margin-left: 30px;">a</h1>' +
|
||||||
|
'<h6 style="margin-left: 90px;">b</h6>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).toContain('<h1 data-indent="1">a</h1>');
|
||||||
|
expect(out).toContain('<h6 data-indent="3">b</h6>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('style attribute handling', () => {
|
||||||
|
it('strips margin-left but preserves other inline styles', () => {
|
||||||
|
const html =
|
||||||
|
'<p style="color: red; margin-left: 30px; font-weight: bold;">x</p>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).toMatch(/<p style="color: red;\s+font-weight: bold;?" data-indent="1">x<\/p>/);
|
||||||
|
expect(out).not.toContain('margin-left');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('removes the style attribute entirely when only margin-left was set', () => {
|
||||||
|
// Two values so GCD detection sees a real unit (60 px) instead of
|
||||||
|
// collapsing to the lone value. The point of this test is the style
|
||||||
|
// attribute being stripped, not the level number.
|
||||||
|
const html =
|
||||||
|
'<p style="margin-left: 60px;">x</p>' +
|
||||||
|
'<p style="margin-left: 120px;">y</p>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).toContain('<p data-indent="1">x</p>');
|
||||||
|
expect(out).toContain('<p data-indent="2">y</p>');
|
||||||
|
expect(out).not.toContain('style=');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('scope and edge cases', () => {
|
||||||
|
it('leaves elements without margin-left untouched', () => {
|
||||||
|
const html = '<p>plain</p><h2>heading</h2>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).toBe('<p>plain</p><h2>heading</h2>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not touch divs, spans, or list items', () => {
|
||||||
|
const html =
|
||||||
|
'<div style="margin-left: 30px;">div</div>' +
|
||||||
|
'<li style="margin-left: 30px;">li</li>' +
|
||||||
|
'<span style="margin-left: 30px;">span</span>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).not.toContain('data-indent');
|
||||||
|
expect(out).toContain('margin-left: 30px');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores zero, negative, and unparseable margin-left values', () => {
|
||||||
|
const html =
|
||||||
|
'<p style="margin-left: 0px;">zero</p>' +
|
||||||
|
'<p style="margin-left: -30px;">neg</p>' +
|
||||||
|
'<p style="margin-left: auto;">auto</p>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).not.toContain('data-indent');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('honors an explicit pxPerLevel override', () => {
|
||||||
|
// Mixed Cloud-and-DC nominal values forced to 40 px/level interpretation.
|
||||||
|
const $ = load(
|
||||||
|
'<p style="margin-left: 40px;">a</p>' +
|
||||||
|
'<p style="margin-left: 80px;">b</p>',
|
||||||
|
);
|
||||||
|
applyConfluenceMarginLeftIndent($, $.root(), { pxPerLevel: 40 });
|
||||||
|
const out = $('body').html() ?? '';
|
||||||
|
expect(out).toContain('<p data-indent="1">a</p>');
|
||||||
|
expect(out).toContain('<p data-indent="2">b</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns a no-op when no indented elements are present', () => {
|
||||||
|
const html = '<p>hi</p>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).toBe('<p>hi</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles a single ambiguous value by clamping to level 1', () => {
|
||||||
|
// GCD of a single value is the value itself, so 120 / 120 = 1.
|
||||||
|
const html = '<p style="margin-left: 120px;">only</p>';
|
||||||
|
const out = run(html);
|
||||||
|
expect(out).toContain('<p data-indent="1">only</p>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { Cheerio, CheerioAPI } from 'cheerio';
|
||||||
|
|
||||||
|
// Maximum indent level supported by the Indent editor extension (see
|
||||||
|
// packages/editor-ext/src/lib/indent.ts). Values above this clamp down.
|
||||||
|
const MAX_INDENT_LEVEL = 8;
|
||||||
|
const MARGIN_LEFT_RE = /margin-left\s*:\s*(-?\d*\.?\d+)\s*px/i;
|
||||||
|
const MARGIN_LEFT_STRIP_RE = /margin-left\s*:\s*-?\d*\.?\d+\s*px\s*;?/i;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confluence encodes paragraph indent as inline `style="margin-left: Npx"`.
|
||||||
|
* The per-level pixel value differs by edition: Cloud uses 30 (max 6 levels),
|
||||||
|
* Data Center uses 40 (no upper limit). The HTML-export ZIP path has no
|
||||||
|
* edition information available, so we auto-detect the per-level unit from
|
||||||
|
* the GCD of all margin-left values in the document. The API converter can
|
||||||
|
* pass `pxPerLevel` explicitly when the edition is known.
|
||||||
|
*
|
||||||
|
* Levels are written to `data-indent` for the TipTap Indent extension to
|
||||||
|
* pick up; the margin-left style is stripped from the element so the
|
||||||
|
* normalized indent doesn't double up with the editor's own indent padding.
|
||||||
|
*/
|
||||||
|
export function applyConfluenceMarginLeftIndent(
|
||||||
|
$: CheerioAPI,
|
||||||
|
$root: Cheerio<any>,
|
||||||
|
options?: { pxPerLevel?: number },
|
||||||
|
): void {
|
||||||
|
const $els = $root.find('p, h1, h2, h3, h4, h5, h6');
|
||||||
|
|
||||||
|
const values: number[] = [];
|
||||||
|
$els.each((_, el) => {
|
||||||
|
const style = $(el).attr('style');
|
||||||
|
if (!style) return;
|
||||||
|
const match = MARGIN_LEFT_RE.exec(style);
|
||||||
|
if (!match) return;
|
||||||
|
const px = parseFloat(match[1]);
|
||||||
|
if (Number.isFinite(px) && px > 0) values.push(px);
|
||||||
|
});
|
||||||
|
if (values.length === 0) return;
|
||||||
|
|
||||||
|
const unit = options?.pxPerLevel ?? detectIndentUnit(values);
|
||||||
|
if (!unit || unit <= 0) return;
|
||||||
|
|
||||||
|
$els.each((_, el) => {
|
||||||
|
const $el = $(el);
|
||||||
|
const style = $el.attr('style');
|
||||||
|
if (!style) return;
|
||||||
|
const match = MARGIN_LEFT_RE.exec(style);
|
||||||
|
if (!match) return;
|
||||||
|
const px = parseFloat(match[1]);
|
||||||
|
if (!Number.isFinite(px) || px <= 0) return;
|
||||||
|
const level = Math.min(
|
||||||
|
MAX_INDENT_LEVEL,
|
||||||
|
Math.max(1, Math.round(px / unit)),
|
||||||
|
);
|
||||||
|
$el.attr('data-indent', String(level));
|
||||||
|
const remaining = style.replace(MARGIN_LEFT_STRIP_RE, '').trim();
|
||||||
|
if (remaining) {
|
||||||
|
$el.attr('style', remaining);
|
||||||
|
} else {
|
||||||
|
$el.removeAttr('style');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function detectIndentUnit(values: number[]): number {
|
||||||
|
// Confluence emits floats like "30.0"; round to ints for a clean GCD.
|
||||||
|
const ints = values.map((v) => Math.round(v)).filter((v) => v > 0);
|
||||||
|
if (ints.length === 0) return 0;
|
||||||
|
return ints.reduce((a, b) => gcd(a, b));
|
||||||
|
}
|
||||||
|
|
||||||
|
function gcd(a: number, b: number): number {
|
||||||
|
while (b !== 0) {
|
||||||
|
[a, b] = [b, a % b];
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ export enum FileImportSource {
|
|||||||
Generic = 'generic',
|
Generic = 'generic',
|
||||||
Notion = 'notion',
|
Notion = 'notion',
|
||||||
Confluence = 'confluence',
|
Confluence = 'confluence',
|
||||||
|
ConfluenceApi = 'confluence-api'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum FileTaskStatus {
|
export enum FileTaskStatus {
|
||||||
|
|||||||
@@ -97,25 +97,21 @@ export function xwikiFormatter($: CheerioAPI, $root: Cheerio<any>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isBareLink($el: Cheerio<any>): boolean {
|
import { applyConfluenceMarginLeftIndent } from './confluence-indent';
|
||||||
const href = $el.attr("href")?.trim();
|
export { applyConfluenceMarginLeftIndent };
|
||||||
const text = $el.text().trim();
|
|
||||||
|
|
||||||
if(!text || !href) return false
|
|
||||||
|
|
||||||
return text === href;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function defaultHtmlFormatter($: CheerioAPI, $root: Cheerio<any>) {
|
export function defaultHtmlFormatter($: CheerioAPI, $root: Cheerio<any>) {
|
||||||
normalizeTableColumnWidths($, $root);
|
normalizeTableColumnWidths($, $root);
|
||||||
|
applyConfluenceMarginLeftIndent($, $root);
|
||||||
|
|
||||||
|
// Auto-embed only when the <a> is the sole meaningful child of its parent
|
||||||
|
// block. A link mixed with surrounding text stays an inline link.
|
||||||
$root.find('a[href]').each((_, el) => {
|
$root.find('a[href]').each((_, el) => {
|
||||||
const $el = $(el);
|
const $el = $(el);
|
||||||
const url = $el.attr('href')!;
|
const url = $el.attr('href')!;
|
||||||
const { provider } = getEmbedUrlAndProvider(url);
|
const { provider } = getEmbedUrlAndProvider(url);
|
||||||
if (provider === 'iframe' || !isBareLink($el)) {
|
if (provider === 'iframe') return;
|
||||||
return;
|
if (!isSoleMeaningfulChild($el, el)) return;
|
||||||
}
|
|
||||||
|
|
||||||
const embed = `<div data-type=\"embed\" data-src=\"${url}\" data-provider=\"${provider}\" data-align=\"center\" data-width=\"640\" data-height=\"480\"></div>`;
|
const embed = `<div data-type=\"embed\" data-src=\"${url}\" data-provider=\"${provider}\" data-align=\"center\" data-width=\"640\" data-height=\"480\"></div>`;
|
||||||
$el.replaceWith(embed);
|
$el.replaceWith(embed);
|
||||||
@@ -131,6 +127,21 @@ export function defaultHtmlFormatter($: CheerioAPI, $root: Cheerio<any>) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSoleMeaningfulChild(
|
||||||
|
$el: Cheerio<any>,
|
||||||
|
rawEl: any,
|
||||||
|
): boolean {
|
||||||
|
const $parent = $el.parent();
|
||||||
|
if ($parent.length === 0) return true;
|
||||||
|
const others = $parent.contents().toArray().filter((n: any) => {
|
||||||
|
if (n === rawEl) return false;
|
||||||
|
if (n.type === 'text') return (n.data ?? '').trim() !== '';
|
||||||
|
if (n.type === 'tag' && n.name === 'br') return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return others.length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
const COLUMN_LAYOUTS = [
|
const COLUMN_LAYOUTS = [
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export enum QueueName {
|
|||||||
GENERAL_QUEUE = '{general-queue}',
|
GENERAL_QUEUE = '{general-queue}',
|
||||||
BILLING_QUEUE = '{billing-queue}',
|
BILLING_QUEUE = '{billing-queue}',
|
||||||
FILE_TASK_QUEUE = '{file-task-queue}',
|
FILE_TASK_QUEUE = '{file-task-queue}',
|
||||||
|
CONFLUENCE_IMPORT_QUEUE = '{confluence-import-queue}',
|
||||||
SEARCH_QUEUE = '{search-queue}',
|
SEARCH_QUEUE = '{search-queue}',
|
||||||
AI_QUEUE = '{ai-queue}',
|
AI_QUEUE = '{ai-queue}',
|
||||||
HISTORY_QUEUE = '{history-queue}',
|
HISTORY_QUEUE = '{history-queue}',
|
||||||
@@ -31,6 +32,7 @@ export enum QueueJob {
|
|||||||
FIRST_PAYMENT_EMAIL = 'first-payment-email',
|
FIRST_PAYMENT_EMAIL = 'first-payment-email',
|
||||||
|
|
||||||
IMPORT_TASK = 'import-task',
|
IMPORT_TASK = 'import-task',
|
||||||
|
CONFLUENCE_API_IMPORT = 'confluence-api-import-task',
|
||||||
EXPORT_TASK = 'export-task',
|
EXPORT_TASK = 'export-task',
|
||||||
|
|
||||||
SEARCH_INDEX_PAGE = 'search-index-page',
|
SEARCH_INDEX_PAGE = 'search-index-page',
|
||||||
@@ -61,7 +63,6 @@ export enum QueueJob {
|
|||||||
WORKSPACE_DELETED = 'workspace-deleted',
|
WORKSPACE_DELETED = 'workspace-deleted',
|
||||||
WORKSPACE_CREATE_EMBEDDINGS = 'workspace-create-embeddings',
|
WORKSPACE_CREATE_EMBEDDINGS = 'workspace-create-embeddings',
|
||||||
WORKSPACE_DELETE_EMBEDDINGS = 'workspace-delete-embeddings',
|
WORKSPACE_DELETE_EMBEDDINGS = 'workspace-delete-embeddings',
|
||||||
WORKSPACE_RESET_EMBEDDINGS = 'workspace-reset-embeddings',
|
|
||||||
|
|
||||||
GENERATE_PAGE_EMBEDDINGS = 'generate-page-embeddings',
|
GENERATE_PAGE_EMBEDDINGS = 'generate-page-embeddings',
|
||||||
DELETE_PAGE_EMBEDDINGS = 'delete-page-embeddings',
|
DELETE_PAGE_EMBEDDINGS = 'delete-page-embeddings',
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Global, Module } from '@nestjs/common';
|
||||||
|
import { BullModule } from '@nestjs/bullmq';
|
||||||
|
import { createQueueRegistrations } from './queue.registrations';
|
||||||
|
|
||||||
|
// Global so @InjectQueue tokens resolve anywhere, in the app and in worker contexts.
|
||||||
|
@Global()
|
||||||
|
@Module({
|
||||||
|
imports: [...createQueueRegistrations()],
|
||||||
|
exports: [BullModule],
|
||||||
|
})
|
||||||
|
export class QueueProducersModule {}
|
||||||
@@ -1,106 +1,18 @@
|
|||||||
import { Global, Module } from '@nestjs/common';
|
import { Global, Module } from '@nestjs/common';
|
||||||
import { BullModule } from '@nestjs/bullmq';
|
import { BullModule } from '@nestjs/bullmq';
|
||||||
import { EnvironmentService } from '../environment/environment.service';
|
import { EnvironmentService } from '../environment/environment.service';
|
||||||
import { createRetryStrategy, parseRedisUrl } from '../../common/helpers';
|
|
||||||
import { QueueName } from './constants';
|
|
||||||
import { GeneralQueueProcessor } from './processors/general-queue.processor';
|
import { GeneralQueueProcessor } from './processors/general-queue.processor';
|
||||||
|
import { bullConfigFactory } from './queue.registrations';
|
||||||
|
import { QueueProducersModule } from './queue-producers.module';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
BullModule.forRootAsync({
|
BullModule.forRootAsync({
|
||||||
useFactory: (environmentService: EnvironmentService) => {
|
useFactory: bullConfigFactory,
|
||||||
const redisConfig = parseRedisUrl(environmentService.getRedisUrl());
|
|
||||||
return {
|
|
||||||
connection: {
|
|
||||||
host: redisConfig.host,
|
|
||||||
port: redisConfig.port,
|
|
||||||
password: redisConfig.password,
|
|
||||||
db: redisConfig.db,
|
|
||||||
family: redisConfig.family,
|
|
||||||
tls: redisConfig.tls,
|
|
||||||
retryStrategy: createRetryStrategy(),
|
|
||||||
},
|
|
||||||
defaultJobOptions: {
|
|
||||||
attempts: 3,
|
|
||||||
backoff: {
|
|
||||||
type: 'exponential',
|
|
||||||
delay: 20 * 1000,
|
|
||||||
},
|
|
||||||
removeOnComplete: {
|
|
||||||
count: 200,
|
|
||||||
},
|
|
||||||
removeOnFail: {
|
|
||||||
count: 100,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
inject: [EnvironmentService],
|
inject: [EnvironmentService],
|
||||||
}),
|
}),
|
||||||
BullModule.registerQueue({
|
QueueProducersModule,
|
||||||
name: QueueName.EMAIL_QUEUE,
|
|
||||||
}),
|
|
||||||
BullModule.registerQueue({
|
|
||||||
name: QueueName.ATTACHMENT_QUEUE,
|
|
||||||
}),
|
|
||||||
BullModule.registerQueue({
|
|
||||||
name: QueueName.GENERAL_QUEUE,
|
|
||||||
}),
|
|
||||||
BullModule.registerQueue({
|
|
||||||
name: QueueName.BILLING_QUEUE,
|
|
||||||
}),
|
|
||||||
BullModule.registerQueue({
|
|
||||||
name: QueueName.FILE_TASK_QUEUE,
|
|
||||||
defaultJobOptions: {
|
|
||||||
removeOnComplete: true,
|
|
||||||
removeOnFail: true,
|
|
||||||
attempts: 1,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
BullModule.registerQueue({
|
|
||||||
name: QueueName.SEARCH_QUEUE,
|
|
||||||
defaultJobOptions: {
|
|
||||||
removeOnComplete: true,
|
|
||||||
removeOnFail: true,
|
|
||||||
attempts: 2,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
BullModule.registerQueue({
|
|
||||||
name: QueueName.AI_QUEUE,
|
|
||||||
defaultJobOptions: {
|
|
||||||
removeOnComplete: true,
|
|
||||||
removeOnFail: true,
|
|
||||||
attempts: 1,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
BullModule.registerQueue({
|
|
||||||
name: QueueName.HISTORY_QUEUE,
|
|
||||||
defaultJobOptions: {
|
|
||||||
removeOnComplete: true,
|
|
||||||
removeOnFail: true,
|
|
||||||
attempts: 2,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
BullModule.registerQueue({
|
|
||||||
name: QueueName.NOTIFICATION_QUEUE,
|
|
||||||
}),
|
|
||||||
BullModule.registerQueue({
|
|
||||||
name: QueueName.AUDIT_QUEUE,
|
|
||||||
defaultJobOptions: {
|
|
||||||
removeOnComplete: true,
|
|
||||||
removeOnFail: true,
|
|
||||||
attempts: 3,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
BullModule.registerQueue({
|
|
||||||
name: QueueName.BASE_QUEUE,
|
|
||||||
defaultJobOptions: {
|
|
||||||
attempts: 2,
|
|
||||||
removeOnComplete: { count: 200 },
|
|
||||||
removeOnFail: { count: 100 },
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
exports: [BullModule],
|
exports: [BullModule],
|
||||||
providers: [GeneralQueueProcessor],
|
providers: [GeneralQueueProcessor],
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import { BullModule } from '@nestjs/bullmq';
|
||||||
|
import { EnvironmentService } from '../environment/environment.service';
|
||||||
|
import { createRetryStrategy, parseRedisUrl } from '../../common/helpers';
|
||||||
|
import { QueueName } from './constants';
|
||||||
|
|
||||||
|
export const bullConfigFactory = (environmentService: EnvironmentService) => {
|
||||||
|
const redisConfig = parseRedisUrl(environmentService.getRedisUrl());
|
||||||
|
return {
|
||||||
|
connection: {
|
||||||
|
host: redisConfig.host,
|
||||||
|
port: redisConfig.port,
|
||||||
|
password: redisConfig.password,
|
||||||
|
db: redisConfig.db,
|
||||||
|
family: redisConfig.family,
|
||||||
|
retryStrategy: createRetryStrategy(),
|
||||||
|
},
|
||||||
|
defaultJobOptions: {
|
||||||
|
attempts: 3,
|
||||||
|
backoff: {
|
||||||
|
type: 'exponential',
|
||||||
|
delay: 20 * 1000,
|
||||||
|
},
|
||||||
|
removeOnComplete: {
|
||||||
|
count: 200,
|
||||||
|
},
|
||||||
|
removeOnFail: {
|
||||||
|
count: 100,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createQueueRegistrations = () => [
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.EMAIL_QUEUE,
|
||||||
|
}),
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.ATTACHMENT_QUEUE,
|
||||||
|
}),
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.GENERAL_QUEUE,
|
||||||
|
}),
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.BILLING_QUEUE,
|
||||||
|
}),
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.FILE_TASK_QUEUE,
|
||||||
|
defaultJobOptions: {
|
||||||
|
removeOnComplete: true,
|
||||||
|
removeOnFail: true,
|
||||||
|
attempts: 1,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.SEARCH_QUEUE,
|
||||||
|
defaultJobOptions: {
|
||||||
|
removeOnComplete: true,
|
||||||
|
removeOnFail: true,
|
||||||
|
attempts: 2,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.AI_QUEUE,
|
||||||
|
defaultJobOptions: {
|
||||||
|
removeOnComplete: true,
|
||||||
|
removeOnFail: true,
|
||||||
|
attempts: 1,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.HISTORY_QUEUE,
|
||||||
|
defaultJobOptions: {
|
||||||
|
removeOnComplete: true,
|
||||||
|
removeOnFail: true,
|
||||||
|
attempts: 2,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.NOTIFICATION_QUEUE,
|
||||||
|
}),
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.AUDIT_QUEUE,
|
||||||
|
defaultJobOptions: {
|
||||||
|
removeOnComplete: true,
|
||||||
|
removeOnFail: true,
|
||||||
|
attempts: 3,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
BullModule.registerQueue({
|
||||||
|
name: QueueName.BASE_QUEUE,
|
||||||
|
defaultJobOptions: {
|
||||||
|
attempts: 2,
|
||||||
|
removeOnComplete: { count: 200 },
|
||||||
|
removeOnFail: { count: 100 },
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
];
|
||||||
@@ -19,7 +19,6 @@ export class RedisConfigService implements RedisOptionsFactory {
|
|||||||
password: redisConfig.password,
|
password: redisConfig.password,
|
||||||
db: redisConfig.db,
|
db: redisConfig.db,
|
||||||
family: redisConfig.family,
|
family: redisConfig.family,
|
||||||
tls: redisConfig.tls,
|
|
||||||
retryStrategy: createRetryStrategy(),
|
retryStrategy: createRetryStrategy(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,10 +49,8 @@ export class StaticModule implements OnModuleInit {
|
|||||||
: undefined,
|
: undefined,
|
||||||
POSTHOG_HOST: this.environmentService.getPostHogHost(),
|
POSTHOG_HOST: this.environmentService.getPostHogHost(),
|
||||||
POSTHOG_KEY: this.environmentService.getPostHogKey(),
|
POSTHOG_KEY: this.environmentService.getPostHogKey(),
|
||||||
AI_VECTOR_DRIVER:
|
BETA_CONFLUENCE_IMPORTER:
|
||||||
this.environmentService.getAiVectorDriver() === 'turbopuffer'
|
this.environmentService.isBetaConfluenceImporter(),
|
||||||
? 'turbopuffer'
|
|
||||||
: undefined,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const windowScriptContent = `<script>window.CONFIG=${JSON.stringify(configString)};</script>`;
|
const windowScriptContent = `<script>window.CONFIG=${JSON.stringify(configString)};</script>`;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { ThrottlerModule } from '@nestjs/throttler';
|
|||||||
import { ThrottlerStorageRedisService } from '@nest-lab/throttler-storage-redis';
|
import { ThrottlerStorageRedisService } from '@nest-lab/throttler-storage-redis';
|
||||||
import { EnvironmentService } from '../environment/environment.service';
|
import { EnvironmentService } from '../environment/environment.service';
|
||||||
import { EnvironmentModule } from '../environment/environment.module';
|
import { EnvironmentModule } from '../environment/environment.module';
|
||||||
import { createRetryStrategy, parseRedisUrl } from '../../common/helpers';
|
import { parseRedisUrl } from '../../common/helpers';
|
||||||
import { AUTH_THROTTLER, AI_CHAT_THROTTLER } from './throttler-names';
|
import { AUTH_THROTTLER, AI_CHAT_THROTTLER } from './throttler-names';
|
||||||
import Redis from 'ioredis';
|
import Redis from 'ioredis';
|
||||||
|
|
||||||
@@ -27,8 +27,6 @@ import Redis from 'ioredis';
|
|||||||
password: redisConfig.password,
|
password: redisConfig.password,
|
||||||
db: redisConfig.db,
|
db: redisConfig.db,
|
||||||
family: redisConfig.family,
|
family: redisConfig.family,
|
||||||
tls: redisConfig.tls,
|
|
||||||
retryStrategy: createRetryStrategy(),
|
|
||||||
keyPrefix: 'throttle:',
|
keyPrefix: 'throttle:',
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ export class WsRedisIoAdapter extends IoAdapter {
|
|||||||
|
|
||||||
const options: RedisOptions = {
|
const options: RedisOptions = {
|
||||||
family: this.redisConfig.family,
|
family: this.redisConfig.family,
|
||||||
tls: this.redisConfig.tls,
|
|
||||||
retryStrategy: createRetryStrategy(),
|
retryStrategy: createRetryStrategy(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export * from "./lib/embed-provider";
|
|||||||
export * from "./lib/subpages";
|
export * from "./lib/subpages";
|
||||||
export * from "./lib/transclusion";
|
export * from "./lib/transclusion";
|
||||||
export * from "./lib/highlight";
|
export * from "./lib/highlight";
|
||||||
|
export * from "./lib/text-color";
|
||||||
export * from "./lib/indent";
|
export * from "./lib/indent";
|
||||||
export * from "./lib/heading/heading";
|
export * from "./lib/heading/heading";
|
||||||
export * from "./lib/unique-id";
|
export * from "./lib/unique-id";
|
||||||
|
|||||||
@@ -73,13 +73,9 @@ export const embedProviders: IEmbedProvider[] = [
|
|||||||
id: "vimeo",
|
id: "vimeo",
|
||||||
name: "Vimeo",
|
name: "Vimeo",
|
||||||
regex:
|
regex:
|
||||||
/^(https:)?\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:\/([\da-zA-Z]+))?/,
|
/^(https:)?\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)/,
|
||||||
getEmbedUrl: (match, url: string) => {
|
getEmbedUrl: (match) => {
|
||||||
// preserve ?h= hash for unlisted videos
|
return `https://player.vimeo.com/video/${match[4]}`;
|
||||||
const hash =
|
|
||||||
match[5] ?? new URL(url, "https://vimeo.com").searchParams.get("h");
|
|
||||||
const base = `https://player.vimeo.com/video/${match[4]}`;
|
|
||||||
return hash ? `${base}?h=${hash}` : base;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,9 +16,11 @@ export const Highlight = TiptapHighlight.extend<HighlightOptions>({
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --mark-bg lets CSS derive a legible dark-mode variant for
|
||||||
|
// arbitrary (imported) colors.
|
||||||
return {
|
return {
|
||||||
"data-color": attributes.color,
|
"data-color": attributes.color,
|
||||||
style: `background-color: ${attributes.color}; color: inherit`,
|
style: `background-color: ${attributes.color}; --mark-bg: ${attributes.color}; color: inherit`,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const TableCell = TiptapTableCell.extend({
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
style: `background-color: ${attributes.backgroundColor}`,
|
style: `background-color: ${attributes.backgroundColor}; --cell-bg: ${attributes.backgroundColor}`,
|
||||||
"data-background-color": attributes.backgroundColor,
|
"data-background-color": attributes.backgroundColor,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const TableHeader = TiptapTableHeader.extend({
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
style: `background-color: ${attributes.backgroundColor}`,
|
style: `background-color: ${attributes.backgroundColor}; --cell-bg: ${attributes.backgroundColor}`,
|
||||||
"data-background-color": attributes.backgroundColor,
|
"data-background-color": attributes.backgroundColor,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { getStyleProperty } from "@tiptap/core";
|
||||||
|
import { Color as TiptapColor } from "@tiptap/extension-color";
|
||||||
|
|
||||||
|
export const Color = TiptapColor.extend({
|
||||||
|
addGlobalAttributes() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
types: this.options.types,
|
||||||
|
attributes: {
|
||||||
|
color: {
|
||||||
|
default: null,
|
||||||
|
parseHTML: (element) => {
|
||||||
|
const value =
|
||||||
|
element.getAttribute("data-text-color") ??
|
||||||
|
getStyleProperty(element, "color") ??
|
||||||
|
element.style.color;
|
||||||
|
return value?.replace(/['"]+/g, "") || null;
|
||||||
|
},
|
||||||
|
renderHTML: (attributes) => {
|
||||||
|
if (!attributes.color) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
// --text-color lets CSS derive a legible dark-mode variant for
|
||||||
|
// arbitrary (imported) colors.
|
||||||
|
return {
|
||||||
|
"data-text-color": attributes.color,
|
||||||
|
style: `color: ${attributes.color}; --text-color: ${attributes.color}`,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
});
|
||||||
Generated
+288
-200
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -6,12 +6,12 @@ patchedDependencies:
|
|||||||
overrides:
|
overrides:
|
||||||
prosemirror-changeset: 2.4.0
|
prosemirror-changeset: 2.4.0
|
||||||
glob: 13.0.6
|
glob: 13.0.6
|
||||||
ws: 8.21.3
|
ws: 8.21.0
|
||||||
dompurify: 3.4.13
|
dompurify: 3.4.13
|
||||||
mermaid: 11.16.1
|
mermaid: 11.16.1
|
||||||
undici: 7.29.0
|
undici: 7.29.0
|
||||||
tmp: 0.2.7
|
tmp: 0.2.7
|
||||||
nanoid@^3: 3.3.18
|
nanoid@^3: 3.3.17
|
||||||
lodash-es: 4.18.1
|
lodash-es: 4.18.1
|
||||||
express-rate-limit: 8.2.2
|
express-rate-limit: 8.2.2
|
||||||
flatted: 3.4.2
|
flatted: 3.4.2
|
||||||
|
|||||||
Reference in New Issue
Block a user