mirror of
https://github.com/docmost/docmost.git
synced 2026-05-08 23:33:09 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 33d9f0a458 | |||
| f99d8c2808 |
+39
-39
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "client",
|
||||
"private": true,
|
||||
"version": "0.70.3",
|
||||
"version": "0.70.1",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
@@ -10,76 +10,76 @@
|
||||
"format": "prettier --write \"src/**/*.tsx\" \"src/**/*.ts\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@casl/react": "^5.0.1",
|
||||
"@casl/react": "^4.0.0",
|
||||
"@docmost/editor-ext": "workspace:*",
|
||||
"@emoji-mart/data": "^1.2.1",
|
||||
"@emoji-mart/react": "^1.1.1",
|
||||
"@excalidraw/excalidraw": "0.18.0-3a5ef40",
|
||||
"@mantine/core": "^8.3.18",
|
||||
"@mantine/dates": "^8.3.18",
|
||||
"@mantine/form": "^8.3.18",
|
||||
"@mantine/hooks": "^8.3.18",
|
||||
"@mantine/modals": "^8.3.18",
|
||||
"@mantine/notifications": "^8.3.18",
|
||||
"@mantine/spotlight": "^8.3.18",
|
||||
"@tabler/icons-react": "^3.40.0",
|
||||
"@tanstack/react-query": "5.90.17",
|
||||
"@mantine/core": "^8.3.14",
|
||||
"@mantine/dates": "^8.3.14",
|
||||
"@mantine/form": "^8.3.14",
|
||||
"@mantine/hooks": "^8.3.14",
|
||||
"@mantine/modals": "^8.3.14",
|
||||
"@mantine/notifications": "^8.3.14",
|
||||
"@mantine/spotlight": "^8.3.14",
|
||||
"@tabler/icons-react": "^3.36.1",
|
||||
"@tanstack/react-query": "^5.90.17",
|
||||
"alfaaz": "^1.1.0",
|
||||
"axios": "^1.13.6",
|
||||
"axios": "^1.13.5",
|
||||
"blueimp-load-image": "^5.16.0",
|
||||
"clsx": "^2.1.1",
|
||||
"emoji-mart": "^5.6.0",
|
||||
"file-saver": "^2.0.5",
|
||||
"highlightjs-sap-abap": "^0.3.0",
|
||||
"i18next": "^25.10.1",
|
||||
"i18next-http-backend": "^3.0.2",
|
||||
"jotai": "^2.18.1",
|
||||
"i18next": "^23.16.8",
|
||||
"i18next-http-backend": "^2.7.3",
|
||||
"jotai": "^2.16.2",
|
||||
"jotai-optics": "^0.4.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"katex": "0.16.40",
|
||||
"katex": "0.16.27",
|
||||
"lowlight": "^3.3.0",
|
||||
"mantine-form-zod-resolver": "^1.3.0",
|
||||
"mermaid": "^11.13.0",
|
||||
"mermaid": "^11.12.2",
|
||||
"mitt": "^3.0.1",
|
||||
"posthog-js": "1.363.1",
|
||||
"posthog-js": "1.345.5",
|
||||
"react": "^18.3.1",
|
||||
"react-arborist": "3.4.0",
|
||||
"react-clear-modal": "^2.0.18",
|
||||
"react-clear-modal": "^2.0.17",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-drawio": "^1.0.7",
|
||||
"react-error-boundary": "^6.1.1",
|
||||
"react-helmet-async": "^3.0.0",
|
||||
"react-i18next": "^16.5.8",
|
||||
"react-router-dom": "^7.13.1",
|
||||
"semver": "^7.7.4",
|
||||
"react-error-boundary": "^4.1.2",
|
||||
"react-helmet-async": "^2.0.5",
|
||||
"react-i18next": "^15.0.1",
|
||||
"react-router-dom": "^7.12.0",
|
||||
"semver": "^7.7.3",
|
||||
"socket.io-client": "^4.8.3",
|
||||
"tiptap-extension-global-drag-handle": "^0.1.18",
|
||||
"zod": "^4.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.28.0",
|
||||
"@tanstack/eslint-plugin-query": "^5.94.4",
|
||||
"@types/blueimp-load-image": "^5.16.6",
|
||||
"@eslint/js": "^9.16.0",
|
||||
"@tanstack/eslint-plugin-query": "^5.62.1",
|
||||
"@types/blueimp-load-image": "^5.16.0",
|
||||
"@types/file-saver": "^2.0.7",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/katex": "^0.16.8",
|
||||
"@types/katex": "^0.16.7",
|
||||
"@types/node": "22.19.1",
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vitejs/plugin-react": "^6.0.0",
|
||||
"eslint": "^9.28.0",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"@vitejs/plugin-react": "^5.1.1",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-plugin-react": "^7.37.2",
|
||||
"eslint-plugin-react-hooks": "^5.1.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.16",
|
||||
"globals": "^15.13.0",
|
||||
"optics-ts": "^2.4.1",
|
||||
"postcss": "^8.5.8",
|
||||
"postcss-preset-mantine": "^1.18.0",
|
||||
"postcss": "^8.4.49",
|
||||
"postcss-preset-mantine": "^1.17.0",
|
||||
"postcss-simple-vars": "^7.0.1",
|
||||
"prettier": "^3.8.1",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript-eslint": "^8.57.1",
|
||||
"vite": "^8.0.1"
|
||||
"prettier": "^3.4.1",
|
||||
"typescript": "^5.7.2",
|
||||
"typescript-eslint": "^8.17.0",
|
||||
"vite": "^7.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,6 +444,7 @@
|
||||
"Toggle space public sharing": "Toggle space public sharing",
|
||||
"Public sharing is disabled at the workspace level": "Public sharing is disabled at the workspace level",
|
||||
"Prevent pages in this space from being shared publicly.": "Prevent pages in this space from being shared publicly.",
|
||||
"Requires an enterprise license": "Requires an enterprise license",
|
||||
"Page permissions": "Page permissions",
|
||||
"Control who can view and edit individual pages. Available with an enterprise license.": "Control who can view and edit individual pages. Available with an enterprise license.",
|
||||
"Enable public sharing": "Enable public sharing",
|
||||
@@ -625,9 +626,7 @@
|
||||
"Generative AI (Ask AI)": "Generative AI (Ask AI)",
|
||||
"Enable AI-powered content generation in the editor. Allows users to generate, improve, translate and transform text.": "Enable AI-powered content generation in the editor. Allows users to generate, improve, translate and transform text.",
|
||||
"Toggle generative AI": "Toggle generative AI",
|
||||
"Upgrade your plan": "Upgrade your plan",
|
||||
"Available with a paid license": "Available with a paid license",
|
||||
"Upgrade your license tier.": "Upgrade your license tier.",
|
||||
"Enterprise feature": "Enterprise feature",
|
||||
"AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "AI is only available in the Docmost enterprise edition. Contact sales@docmost.com.",
|
||||
"AI & MCP": "AI & MCP",
|
||||
"AI": "AI",
|
||||
@@ -635,15 +634,17 @@
|
||||
"Model Context Protocol (MCP)": "Model Context Protocol (MCP)",
|
||||
"Enable the MCP server to allow AI assistants and tools to interact with your workspace content.": "Enable the MCP server to allow AI assistants and tools to interact with your workspace content.",
|
||||
"MCP is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "MCP is only available in the Docmost enterprise edition. Contact sales@docmost.com.",
|
||||
"MCP documentation": "MCP documentation",
|
||||
"MCP Server URL": "MCP Server URL",
|
||||
"Use your API key for authentication. You can manage API keys in your account settings.": "Use your API key for authentication. You can manage API keys in your account settings.",
|
||||
"Supported tools": "Supported tools",
|
||||
"Your workspace has MCP enabled. Use your API key to connect AI assistants.": "Your workspace has MCP enabled. Use your API key to connect AI assistants.",
|
||||
"MCP server URL:": "MCP server URL:",
|
||||
"Learn more": "Learn more",
|
||||
"Manage API keys for all users in the workspace. View the <anchor>API documentation</anchor> for usage details.": "Manage API keys for all users in the workspace. View the <anchor>API documentation</anchor> for usage details.",
|
||||
"View the <anchor>API documentation</anchor> for usage details.": "View the <anchor>API documentation</anchor> for usage details.",
|
||||
"View the <anchor>MCP documentation</anchor>.": "View the <anchor>MCP documentation</anchor>.",
|
||||
"View the": "View the",
|
||||
"for usage details.": "for usage details.",
|
||||
"for setup instructions.": "for setup instructions.",
|
||||
"API documentation": "API documentation",
|
||||
"Sources": "Sources",
|
||||
"AI Answers not available for attachments": "AI Answers not available for attachments",
|
||||
"No answer available": "No answer available",
|
||||
@@ -658,12 +659,12 @@
|
||||
"Mark all as read": "Mark all as read",
|
||||
"Mark as read": "Mark as read",
|
||||
"More options": "More options",
|
||||
"<bold>{{name}}</bold> mentioned you in a comment": "<bold>{{name}}</bold> mentioned you in a comment",
|
||||
"<bold>{{name}}</bold> commented on a page": "<bold>{{name}}</bold> commented on a page",
|
||||
"<bold>{{name}}</bold> resolved a comment": "<bold>{{name}}</bold> resolved a comment",
|
||||
"<bold>{{name}}</bold> mentioned you on a page": "<bold>{{name}}</bold> mentioned you on a page",
|
||||
"<bold>{{name}}</bold> gave you edit access to a page": "<bold>{{name}}</bold> gave you edit access to a page",
|
||||
"<bold>{{name}}</bold> gave you view access to a page": "<bold>{{name}}</bold> gave you view access to a page",
|
||||
"mentioned you in a comment": "mentioned you in a comment",
|
||||
"commented on a page": "commented on a page",
|
||||
"resolved a comment": "resolved a comment",
|
||||
"mentioned you on a page": "mentioned you on a page",
|
||||
"gave you edit access to a page": "gave you edit access to a page",
|
||||
"gave you view access to a page": "gave you view access to a page",
|
||||
"Today": "Today",
|
||||
"Yesterday": "Yesterday",
|
||||
"This week": "This week",
|
||||
|
||||
@@ -21,9 +21,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||
import { useAtom } from "jotai";
|
||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import {
|
||||
prefetchApiKeyManagement,
|
||||
prefetchApiKeys,
|
||||
@@ -41,19 +39,22 @@ import { mobileSidebarAtom } from "@/components/layouts/global/hooks/atoms/sideb
|
||||
import { useToggleSidebar } from "@/components/layouts/global/hooks/hooks/use-toggle-sidebar.ts";
|
||||
import { useSettingsNavigation } from "@/hooks/use-settings-navigation";
|
||||
|
||||
type DataItem = {
|
||||
interface DataItem {
|
||||
label: string;
|
||||
icon: React.ElementType;
|
||||
path: string;
|
||||
feature?: string;
|
||||
role?: "admin" | "owner";
|
||||
env?: "cloud" | "selfhosted";
|
||||
};
|
||||
isCloud?: boolean;
|
||||
isEnterprise?: boolean;
|
||||
isAdmin?: boolean;
|
||||
isOwner?: boolean;
|
||||
isSelfhosted?: boolean;
|
||||
showDisabledInNonEE?: boolean;
|
||||
}
|
||||
|
||||
type DataGroup = {
|
||||
interface DataGroup {
|
||||
heading: string;
|
||||
items: DataItem[];
|
||||
};
|
||||
}
|
||||
|
||||
const groupedData: DataGroup[] = [
|
||||
{
|
||||
@@ -69,7 +70,9 @@ const groupedData: DataGroup[] = [
|
||||
label: "API keys",
|
||||
icon: IconKey,
|
||||
path: "/settings/account/api-keys",
|
||||
feature: Feature.API_KEYS,
|
||||
isCloud: true,
|
||||
isEnterprise: true,
|
||||
showDisabledInNonEE: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -77,20 +80,26 @@ const groupedData: DataGroup[] = [
|
||||
heading: "Workspace",
|
||||
items: [
|
||||
{ label: "General", icon: IconSettings, path: "/settings/workspace" },
|
||||
{ label: "Members", icon: IconUsers, path: "/settings/members" },
|
||||
{
|
||||
label: "Members",
|
||||
icon: IconUsers,
|
||||
path: "/settings/members",
|
||||
},
|
||||
{
|
||||
label: "Billing",
|
||||
icon: IconCoin,
|
||||
path: "/settings/billing",
|
||||
role: "admin",
|
||||
env: "cloud",
|
||||
isCloud: true,
|
||||
isAdmin: true,
|
||||
},
|
||||
{
|
||||
label: "Security & SSO",
|
||||
icon: IconLock,
|
||||
path: "/settings/security",
|
||||
feature: Feature.SECURITY_SETTINGS,
|
||||
role: "admin",
|
||||
isCloud: true,
|
||||
isEnterprise: true,
|
||||
isAdmin: true,
|
||||
showDisabledInNonEE: true,
|
||||
},
|
||||
{ label: "Groups", icon: IconUsersGroup, path: "/settings/groups" },
|
||||
{ label: "Spaces", icon: IconSpaces, path: "/settings/spaces" },
|
||||
@@ -99,22 +108,25 @@ const groupedData: DataGroup[] = [
|
||||
label: "API management",
|
||||
icon: IconKey,
|
||||
path: "/settings/api-keys",
|
||||
feature: Feature.API_KEYS,
|
||||
role: "admin",
|
||||
isCloud: true,
|
||||
isEnterprise: true,
|
||||
isAdmin: true,
|
||||
showDisabledInNonEE: true,
|
||||
},
|
||||
{
|
||||
label: "AI settings",
|
||||
icon: IconSparkles,
|
||||
path: "/settings/ai",
|
||||
role: "admin",
|
||||
isAdmin: true,
|
||||
},
|
||||
{
|
||||
label: "Audit log",
|
||||
icon: IconHistory,
|
||||
path: "/settings/audit",
|
||||
feature: Feature.AUDIT_LOGS,
|
||||
role: "owner",
|
||||
env: "selfhosted",
|
||||
isEnterprise: true,
|
||||
isOwner: true,
|
||||
isSelfhosted: true,
|
||||
showDisabledInNonEE: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -136,8 +148,7 @@ export default function SettingsSidebar() {
|
||||
const [active, setActive] = useState(location.pathname);
|
||||
const { goBack } = useSettingsNavigation();
|
||||
const { isAdmin, isOwner } = useUserRole();
|
||||
const [entitlements] = useAtom(entitlementAtom);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const [workspace] = useAtom(workspaceAtom);
|
||||
const [mobileSidebarOpened] = useAtom(mobileSidebarAtom);
|
||||
const toggleMobileSidebar = useToggleSidebar(mobileSidebarAtom);
|
||||
|
||||
@@ -145,20 +156,43 @@ export default function SettingsSidebar() {
|
||||
setActive(location.pathname);
|
||||
}, [location.pathname]);
|
||||
|
||||
const hasFeature = (f: string) =>
|
||||
entitlements?.features?.includes(f) ?? false;
|
||||
|
||||
const canShowItem = (item: DataItem) => {
|
||||
if (item.env === "cloud" && !isCloud()) return false;
|
||||
if (item.env === "selfhosted" && isCloud()) return false;
|
||||
if (item.role === "admin" && !isAdmin) return false;
|
||||
if (item.role === "owner" && !isOwner) return false;
|
||||
const hasRoleAccess = (item: DataItem) => {
|
||||
if (item.isOwner) return isOwner;
|
||||
if (item.isAdmin) return isAdmin;
|
||||
return true;
|
||||
};
|
||||
|
||||
const canShowItem = (item: DataItem) => {
|
||||
if (item.showDisabledInNonEE && item.isEnterprise) {
|
||||
if (item.isSelfhosted && isCloud()) return false;
|
||||
return hasRoleAccess(item);
|
||||
}
|
||||
|
||||
if (item.isCloud && item.isEnterprise) {
|
||||
if (!(isCloud() || workspace?.hasLicenseKey)) return false;
|
||||
return hasRoleAccess(item);
|
||||
}
|
||||
|
||||
if (item.isCloud) {
|
||||
return isCloud() ? hasRoleAccess(item) : false;
|
||||
}
|
||||
|
||||
if (item.isSelfhosted) {
|
||||
return !isCloud() ? hasRoleAccess(item) : false;
|
||||
}
|
||||
|
||||
if (item.isEnterprise) {
|
||||
return workspace?.hasLicenseKey ? hasRoleAccess(item) : false;
|
||||
}
|
||||
|
||||
return hasRoleAccess(item);
|
||||
};
|
||||
|
||||
const isItemDisabled = (item: DataItem) => {
|
||||
if (!item.feature) return false;
|
||||
return !hasFeature(item.feature);
|
||||
if (item.showDisabledInNonEE && item.isEnterprise) {
|
||||
return !(isCloud() || workspace?.hasLicenseKey);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const menuItems = groupedData.map((group) => {
|
||||
@@ -191,7 +225,7 @@ export default function SettingsSidebar() {
|
||||
prefetchHandler = prefetchBilling;
|
||||
break;
|
||||
case "License & Edition":
|
||||
if (entitlements?.tier !== "free") {
|
||||
if (workspace?.hasLicenseKey) {
|
||||
prefetchHandler = prefetchLicense;
|
||||
}
|
||||
break;
|
||||
@@ -246,7 +280,7 @@ export default function SettingsSidebar() {
|
||||
return (
|
||||
<Tooltip
|
||||
key={item.label}
|
||||
label={upgradeLabel}
|
||||
label={t("Available in enterprise edition")}
|
||||
position="right"
|
||||
withArrow
|
||||
>
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { Group, Text, Switch, MantineSize, Tooltip } from "@mantine/core";
|
||||
import { Group, Text, Switch, MantineSize, Title } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
import useLicense from "@/ee/hooks/use-license.tsx";
|
||||
|
||||
export default function EnableAiSearch() {
|
||||
const { t } = useTranslation();
|
||||
@@ -38,8 +37,9 @@ export function AiSearchToggle({ size, label }: AiSearchToggleProps) {
|
||||
const { t } = useTranslation();
|
||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
||||
const [checked, setChecked] = useState(workspace?.settings?.ai?.search);
|
||||
const hasAccess = useHasFeature(Feature.AI);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const { hasLicenseKey } = useLicense();
|
||||
|
||||
const hasAccess = isCloud() || (!isCloud() && hasLicenseKey);
|
||||
|
||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.currentTarget.checked;
|
||||
@@ -56,16 +56,14 @@ export function AiSearchToggle({ size, label }: AiSearchToggleProps) {
|
||||
};
|
||||
|
||||
return (
|
||||
<Tooltip label={upgradeLabel} disabled={hasAccess} refProp="rootRef">
|
||||
<Switch
|
||||
size={size}
|
||||
label={label}
|
||||
labelPosition="left"
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={!hasAccess}
|
||||
aria-label={t("Toggle AI search")}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Switch
|
||||
size={size}
|
||||
label={label}
|
||||
labelPosition="left"
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={!hasAccess}
|
||||
aria-label={t("Toggle AI search")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
import { Group, Text, Switch, Tooltip } from "@mantine/core";
|
||||
import { Group, Text, Switch } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||
import { useIsCloudEE } from "@/hooks/use-is-cloud-ee.tsx";
|
||||
|
||||
export default function EnableGenerativeAi() {
|
||||
const { t } = useTranslation();
|
||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
||||
const [checked, setChecked] = useState(workspace?.settings?.ai?.generative);
|
||||
const hasAccess = useHasFeature(Feature.AI);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const hasAccess = useIsCloudEE();
|
||||
|
||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.currentTarget.checked;
|
||||
@@ -41,13 +38,11 @@ export default function EnableGenerativeAi() {
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<Tooltip label={upgradeLabel} disabled={hasAccess} refProp="rootRef">
|
||||
<Switch
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={!hasAccess}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Switch
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={!hasAccess}
|
||||
/>
|
||||
</Group>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,12 +13,10 @@ import {
|
||||
import { useAtom } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import React, { useState } from "react";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||
import { useIsCloudEE } from "@/hooks/use-is-cloud-ee.tsx";
|
||||
import { getAppUrl } from "@/lib/config.ts";
|
||||
import { IconCheck, IconCopy, IconInfoCircle } from "@tabler/icons-react";
|
||||
import { CopyButton } from "@/components/common/copy-button.tsx";
|
||||
@@ -27,8 +25,7 @@ export default function McpSettings() {
|
||||
const { t } = useTranslation();
|
||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
||||
const [checked, setChecked] = useState(workspace?.settings?.ai?.mcp);
|
||||
const hasAccess = useHasFeature(Feature.MCP);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const hasAccess = useIsCloudEE();
|
||||
|
||||
const mcpUrl = `${getAppUrl()}/mcp`;
|
||||
|
||||
@@ -49,7 +46,11 @@ export default function McpSettings() {
|
||||
return (
|
||||
<Stack gap="lg">
|
||||
{!hasAccess && (
|
||||
<Alert icon={<IconInfoCircle />} title={upgradeLabel} color="blue">
|
||||
<Alert
|
||||
icon={<IconInfoCircle />}
|
||||
title={t("Enterprise feature")}
|
||||
color="blue"
|
||||
>
|
||||
{t(
|
||||
"MCP is only available in the Docmost enterprise edition. Contact sales@docmost.com.",
|
||||
)}
|
||||
@@ -63,22 +64,23 @@ export default function McpSettings() {
|
||||
{t(
|
||||
"Enable the MCP server to allow AI assistants and tools to interact with your workspace content.",
|
||||
)}{" "}
|
||||
<Trans
|
||||
i18nKey="View the <anchor>MCP documentation</anchor>."
|
||||
components={{
|
||||
anchor: <Anchor href="https://docmost.com/docs/user-guide/mcp" target="_blank" size="sm" />,
|
||||
}}
|
||||
/>
|
||||
{t("View the")}{" "}
|
||||
<Anchor
|
||||
href="https://docmost.com/docs/user-guide/mcp"
|
||||
target="_blank"
|
||||
size="sm"
|
||||
>
|
||||
{t("MCP documentation")}
|
||||
</Anchor>
|
||||
.
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<Tooltip label={upgradeLabel} disabled={hasAccess} refProp="rootRef">
|
||||
<Switch
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={!hasAccess}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Switch
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={!hasAccess}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
{checked && (
|
||||
@@ -87,7 +89,11 @@ export default function McpSettings() {
|
||||
{t("MCP Server URL")}
|
||||
</Text>
|
||||
<Group gap="xs">
|
||||
<TextInput value={mcpUrl} readOnly style={{ flex: 1 }} />
|
||||
<TextInput
|
||||
value={mcpUrl}
|
||||
readOnly
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
<CopyButton value={mcpUrl} timeout={2000}>
|
||||
{({ copied, copy }) => (
|
||||
<Tooltip
|
||||
@@ -117,36 +123,12 @@ export default function McpSettings() {
|
||||
{t("Supported tools")}
|
||||
</Text>
|
||||
<List size="sm" spacing={2}>
|
||||
<List.Item>
|
||||
<Text size="sm" c="dimmed" span>
|
||||
search_pages, get_page, create_page, update_page
|
||||
</Text>
|
||||
</List.Item>
|
||||
<List.Item>
|
||||
<Text size="sm" c="dimmed" span>
|
||||
list_pages, list_child_pages, duplicate_page
|
||||
</Text>
|
||||
</List.Item>
|
||||
<List.Item>
|
||||
<Text size="sm" c="dimmed" span>
|
||||
copy_page_to_space, move_page, move_page_to_space
|
||||
</Text>
|
||||
</List.Item>
|
||||
<List.Item>
|
||||
<Text size="sm" c="dimmed" span>
|
||||
get_space, list_spaces, create_space, update_space
|
||||
</Text>
|
||||
</List.Item>
|
||||
<List.Item>
|
||||
<Text size="sm" c="dimmed" span>
|
||||
get_comments, create_comment, update_comment
|
||||
</Text>
|
||||
</List.Item>
|
||||
<List.Item>
|
||||
<Text size="sm" c="dimmed" span>
|
||||
search_attachments, list_workspace_members, get_current_user
|
||||
</Text>
|
||||
</List.Item>
|
||||
<List.Item><Text size="sm" c="dimmed" span>search_pages, get_page, create_page, update_page</Text></List.Item>
|
||||
<List.Item><Text size="sm" c="dimmed" span>list_pages, list_child_pages, duplicate_page</Text></List.Item>
|
||||
<List.Item><Text size="sm" c="dimmed" span>copy_page_to_space, move_page, move_page_to_space</Text></List.Item>
|
||||
<List.Item><Text size="sm" c="dimmed" span>get_space, list_spaces, create_space, update_space</Text></List.Item>
|
||||
<List.Item><Text size="sm" c="dimmed" span>get_comments, create_comment, update_comment</Text></List.Item>
|
||||
<List.Item><Text size="sm" c="dimmed" span>search_attachments, list_workspace_members, get_current_user</Text></List.Item>
|
||||
</List>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,17 +9,14 @@ import EnableGenerativeAi from "@/ee/ai/components/enable-generative-ai.tsx";
|
||||
import McpSettings from "@/ee/ai/components/mcp-settings.tsx";
|
||||
import { Alert, Stack, Tabs } from "@mantine/core";
|
||||
import { IconInfoCircle } from "@tabler/icons-react";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||
import { useIsCloudEE } from "@/hooks/use-is-cloud-ee.tsx";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
|
||||
export default function AiSettings() {
|
||||
const { t } = useTranslation();
|
||||
const { isAdmin } = useUserRole();
|
||||
const hasAccess = useHasFeature(Feature.AI);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const hasAccess = useIsCloudEE();
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -58,7 +55,7 @@ export default function AiSettings() {
|
||||
{!hasAccess && (
|
||||
<Alert
|
||||
icon={<IconInfoCircle />}
|
||||
title={upgradeLabel}
|
||||
title={t("Enterprise feature")}
|
||||
color="blue"
|
||||
mb="lg"
|
||||
>
|
||||
|
||||
@@ -5,14 +5,12 @@ import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import useEnterpriseAccess from "@/ee/hooks/use-enterprise-access.tsx";
|
||||
import {
|
||||
ResponsiveSettingsRow,
|
||||
ResponsiveSettingsContent,
|
||||
ResponsiveSettingsControl,
|
||||
} from "@/components/ui/responsive-settings-row";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label.ts";
|
||||
|
||||
export default function RestrictApiToAdmins() {
|
||||
const { t } = useTranslation();
|
||||
@@ -20,8 +18,7 @@ export default function RestrictApiToAdmins() {
|
||||
const [checked, setChecked] = useState(
|
||||
workspace?.settings?.api?.restrictToAdmins === true,
|
||||
);
|
||||
const hasAccess = useHasFeature(Feature.API_KEYS);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const hasAccess = useEnterpriseAccess();
|
||||
|
||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.currentTarget.checked;
|
||||
@@ -54,7 +51,7 @@ export default function RestrictApiToAdmins() {
|
||||
|
||||
<ResponsiveSettingsControl>
|
||||
<Tooltip
|
||||
label={upgradeLabel}
|
||||
label={t("Requires an enterprise license")}
|
||||
disabled={hasAccess}
|
||||
refProp="rootRef"
|
||||
>
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useState } from "react";
|
||||
import { Anchor, Alert, Button, Group, Space, Text } from "@mantine/core";
|
||||
import { IconInfoCircle } from "@tabler/icons-react";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import SettingsTitle from "@/components/settings/settings-title";
|
||||
import { getAppName, getAppUrl } from "@/lib/config";
|
||||
import { ApiKeyTable } from "@/ee/api-key/components/api-key-table";
|
||||
@@ -58,12 +58,11 @@ export default function UserApiKeys() {
|
||||
<SettingsTitle title={t("API keys")} />
|
||||
|
||||
<Text size="sm" c="dimmed" mb="md">
|
||||
<Trans
|
||||
i18nKey="View the <anchor>API documentation</anchor> for usage details."
|
||||
components={{
|
||||
anchor: <Anchor href="https://docmost.com/api-docs" target="_blank" size="sm" />,
|
||||
}}
|
||||
/>
|
||||
{t("View the")}{" "}
|
||||
<Anchor href="https://docmost.com/api-docs" target="_blank" size="sm">
|
||||
{t("API documentation")}
|
||||
</Anchor>{" "}
|
||||
{t("for usage details.")}
|
||||
</Text>
|
||||
|
||||
{mcpEnabled && canCreate && (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState } from "react";
|
||||
import { Anchor, Button, Divider, Group, Space, Text } from "@mantine/core";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import SettingsTitle from "@/components/settings/settings-title";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import { ApiKeyTable } from "@/ee/api-key/components/api-key-table";
|
||||
@@ -56,12 +56,12 @@ export default function WorkspaceApiKeys() {
|
||||
<SettingsTitle title={t("API management")} />
|
||||
|
||||
<Text size="sm" c="dimmed" mb="md">
|
||||
<Trans
|
||||
i18nKey="Manage API keys for all users in the workspace. View the <anchor>API documentation</anchor> for usage details."
|
||||
components={{
|
||||
anchor: <Anchor href="https://docmost.com/api-docs" target="_blank" size="sm" />,
|
||||
}}
|
||||
/>
|
||||
{t("Manage API keys for all users in the workspace.")}{" "}
|
||||
{t("View the")}{" "}
|
||||
<Anchor href="https://docmost.com/api-docs" target="_blank" size="sm">
|
||||
{t("API documentation")}
|
||||
</Anchor>{" "}
|
||||
{t("for usage details.")}
|
||||
</Text>
|
||||
|
||||
<RestrictApiToAdmins />
|
||||
|
||||
@@ -6,6 +6,7 @@ import { IAuthProvider } from "@/ee/security/types/security.types.ts";
|
||||
import { buildSsoLoginUrl } from "@/ee/security/sso.utils.ts";
|
||||
import { SSO_PROVIDER } from "@/ee/security/contants.ts";
|
||||
import { GoogleIcon } from "@/components/icons/google-icon.tsx";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
import { LdapLoginModal } from "@/ee/components/ldap-login-modal.tsx";
|
||||
|
||||
export default function SsoLogin() {
|
||||
@@ -56,7 +57,7 @@ export default function SsoLogin() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{data.authProviders.length > 0 && (
|
||||
{(isCloud() || data.hasLicenseKey) && (
|
||||
<>
|
||||
<Stack align="stretch" justify="center" gap="sm">
|
||||
{data.authProviders.map((provider) => (
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { atomWithStorage } from "jotai/utils";
|
||||
import type { Entitlements } from "./entitlement.types";
|
||||
|
||||
export const entitlementAtom = atomWithStorage<Entitlements | null>(
|
||||
"entitlements",
|
||||
null,
|
||||
);
|
||||
@@ -1,7 +0,0 @@
|
||||
import api from "@/lib/api-client";
|
||||
import { Entitlements } from "./entitlement.types";
|
||||
|
||||
export async function getEntitlements(): Promise<Entitlements> {
|
||||
const req = await api.post<Entitlements>("/workspace/entitlements");
|
||||
return req.data as Entitlements;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
export type Tier = "free" | "standard" | "business" | "enterprise";
|
||||
|
||||
export type Entitlements = {
|
||||
cloud: boolean;
|
||||
tier: Tier;
|
||||
features: string[];
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
import { useQuery, UseQueryResult } from "@tanstack/react-query";
|
||||
import { getEntitlements } from "./entitlement-service";
|
||||
import { Entitlements } from "./entitlement.types";
|
||||
|
||||
export function useEntitlements(): UseQueryResult<Entitlements> {
|
||||
return useQuery({
|
||||
queryKey: ["entitlements"],
|
||||
queryFn: getEntitlements,
|
||||
staleTime: 5 * 60 * 1000,
|
||||
});
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
export const Feature = {
|
||||
SSO_CUSTOM: 'sso:custom',
|
||||
SSO_GOOGLE: 'sso:google',
|
||||
MFA: 'mfa',
|
||||
API_KEYS: 'api:keys',
|
||||
COMMENT_RESOLUTION: 'comment:resolution',
|
||||
PAGE_PERMISSIONS: 'page:permissions',
|
||||
AI: 'ai',
|
||||
CONFLUENCE_IMPORT: 'import:confluence',
|
||||
DOCX_IMPORT: 'import:docx',
|
||||
ATTACHMENT_INDEXING: 'attachment:indexing',
|
||||
SECURITY_SETTINGS: 'security:settings',
|
||||
MCP: 'mcp',
|
||||
SCIM: 'scim',
|
||||
PAGE_VERIFICATION: 'page:verification',
|
||||
AUDIT_LOGS: 'audit:logs',
|
||||
RETENTION: 'retention',
|
||||
SHARING_CONTROLS: 'sharing:controls',
|
||||
} as const;
|
||||
@@ -0,0 +1,12 @@
|
||||
import { isCloud } from "@/lib/config";
|
||||
import useLicense from "@/ee/hooks/use-license";
|
||||
import usePlan from "@/ee/hooks/use-plan";
|
||||
|
||||
const useEnterpriseAccess = () => {
|
||||
const { hasLicenseKey } = useLicense();
|
||||
const { isBusiness } = usePlan();
|
||||
|
||||
return (isCloud() && isBusiness) || (!isCloud() && hasLicenseKey);
|
||||
};
|
||||
|
||||
export default useEnterpriseAccess;
|
||||
@@ -1,7 +0,0 @@
|
||||
import { useAtom } from "jotai";
|
||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
||||
|
||||
export const useHasFeature = (feature: string): boolean => {
|
||||
const [entitlements] = useAtom(entitlementAtom);
|
||||
return entitlements?.features?.includes(feature) ?? false;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { useAtom } from "jotai";
|
||||
import { currentUserAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
|
||||
export const useLicense = () => {
|
||||
const [currentUser] = useAtom(currentUserAtom);
|
||||
return { hasLicenseKey: currentUser?.workspace?.hasLicenseKey };
|
||||
};
|
||||
|
||||
export default useLicense;
|
||||
@@ -1,16 +0,0 @@
|
||||
import { useAtom } from "jotai";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
||||
import { isCloud } from "@/lib/config";
|
||||
|
||||
export function useUpgradeLabel(): string {
|
||||
const { t } = useTranslation();
|
||||
const [entitlements] = useAtom(entitlementAtom);
|
||||
|
||||
if (!isCloud()) {
|
||||
return entitlements != null && entitlements.tier !== "free"
|
||||
? t("Upgrade your license tier.")
|
||||
: t("Available with a paid license");
|
||||
}
|
||||
return t("Upgrade your plan");
|
||||
}
|
||||
@@ -7,22 +7,21 @@ import { useTranslation } from "react-i18next";
|
||||
import { useActivateMutation } from "@/ee/licence/queries/license-query.ts";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { useAtom } from "jotai";
|
||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import RemoveLicense from "@/ee/licence/components/remove-license.tsx";
|
||||
|
||||
export default function ActivateLicense() {
|
||||
const { t } = useTranslation();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [entitlements] = useAtom(entitlementAtom);
|
||||
const hasLicense = entitlements != null && entitlements.tier !== "free";
|
||||
const [workspace] = useAtom(workspaceAtom);
|
||||
|
||||
return (
|
||||
<Group justify="flex-end" wrap="nowrap" mb="sm">
|
||||
<Button onClick={open}>
|
||||
{hasLicense ? t("Update license") : t("Add license")}
|
||||
{workspace?.hasLicenseKey ? t("Update license") : t("Add license")}
|
||||
</Button>
|
||||
|
||||
{hasLicense && <RemoveLicense />}
|
||||
{workspace?.hasLicenseKey && <RemoveLicense />}
|
||||
|
||||
<Modal
|
||||
size="550"
|
||||
@@ -60,7 +59,7 @@ export function ActivateLicenseForm({ onClose }: ActivateLicenseFormProps) {
|
||||
async function handleSubmit(data: { licenseKey: string }) {
|
||||
await activateLicenseMutation.mutateAsync(data.licenseKey);
|
||||
form.reset();
|
||||
onClose?.();
|
||||
onClose();
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -31,8 +31,7 @@ export default function LicenseDetails() {
|
||||
<Table.Tr>
|
||||
<Table.Th w={160}>Edition</Table.Th>
|
||||
<Table.Td>
|
||||
{license.licenseType === "business" ? "Business" : "Enterprise"}{" "}
|
||||
{license.trial && <Badge color="green">Trial</Badge>}
|
||||
Enterprise {license.trial && <Badge color="green">Trial</Badge>}
|
||||
</Table.Td>
|
||||
</Table.Tr>
|
||||
|
||||
|
||||
@@ -8,11 +8,10 @@ import ActivateLicenseForm from "@/ee/licence/components/activate-license-modal.
|
||||
import InstallationDetails from "@/ee/licence/components/installation-details.tsx";
|
||||
import OssDetails from "@/ee/licence/components/oss-details.tsx";
|
||||
import { useAtom } from "jotai/index";
|
||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
|
||||
export default function License() {
|
||||
const [entitlements] = useAtom(entitlementAtom);
|
||||
const hasLicense = entitlements != null && entitlements.tier !== "free";
|
||||
const [workspace] = useAtom(workspaceAtom);
|
||||
const { isAdmin } = useUserRole();
|
||||
|
||||
if (!isAdmin) {
|
||||
@@ -30,7 +29,7 @@ export default function License() {
|
||||
|
||||
<InstallationDetails />
|
||||
|
||||
{hasLicense ? <LicenseDetails /> : <OssDetails />}
|
||||
{workspace?.hasLicenseKey ? <LicenseDetails /> : <OssDetails />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ export function useActivateMutation() {
|
||||
queryKey: ["license"],
|
||||
});
|
||||
queryClient.refetchQueries({ queryKey: ["currentUser"] });
|
||||
queryClient.refetchQueries({ queryKey: ["entitlements"] });
|
||||
},
|
||||
onError: (error) => {
|
||||
const errorMessage = error["response"]?.data?.message;
|
||||
@@ -48,7 +47,6 @@ export function useRemoveLicenseMutation() {
|
||||
onSuccess: () => {
|
||||
queryClient.refetchQueries({ queryKey: ["license"] });
|
||||
queryClient.refetchQueries({ queryKey: ["currentUser"] });
|
||||
queryClient.refetchQueries({ queryKey: ["entitlements"] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
export type LicenseType = 'business' | 'enterprise';
|
||||
|
||||
export interface ILicenseInfo {
|
||||
id: string;
|
||||
customerName: string;
|
||||
seatCount: number;
|
||||
licenseType: LicenseType;
|
||||
issuedAt: Date;
|
||||
expiresAt: Date;
|
||||
trial: boolean;
|
||||
|
||||
@@ -7,9 +7,8 @@ import { getMfaStatus } from "@/ee/mfa";
|
||||
import { MfaSetupModal } from "@/ee/mfa";
|
||||
import { MfaDisableModal } from "@/ee/mfa";
|
||||
import { MfaBackupCodesModal } from "@/ee/mfa";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
import useLicense from "@/ee/hooks/use-license.tsx";
|
||||
import { ResponsiveSettingsRow, ResponsiveSettingsContent, ResponsiveSettingsControl } from "@/components/ui/responsive-settings-row";
|
||||
|
||||
export function MfaSettings() {
|
||||
@@ -18,8 +17,7 @@ export function MfaSettings() {
|
||||
const [setupModalOpen, setSetupModalOpen] = useState(false);
|
||||
const [disableModalOpen, setDisableModalOpen] = useState(false);
|
||||
const [backupCodesModalOpen, setBackupCodesModalOpen] = useState(false);
|
||||
const canUseMfa = useHasFeature(Feature.MFA);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const { hasLicenseKey } = useLicense();
|
||||
|
||||
const { data: mfaStatus, isLoading } = useQuery({
|
||||
queryKey: ["mfa-status"],
|
||||
@@ -30,6 +28,8 @@ export function MfaSettings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const canUseMfa = isCloud() || hasLicenseKey;
|
||||
|
||||
// Check if MFA is truly enabled
|
||||
const isMfaEnabled = mfaStatus?.isEnabled === true;
|
||||
|
||||
@@ -69,7 +69,7 @@ export function MfaSettings() {
|
||||
<ResponsiveSettingsControl>
|
||||
{!isMfaEnabled ? (
|
||||
<Tooltip
|
||||
label={upgradeLabel}
|
||||
label={t("Available in enterprise edition")}
|
||||
disabled={canUseMfa}
|
||||
>
|
||||
<Button
|
||||
|
||||
@@ -19,8 +19,7 @@ import { usePageRestrictionInfoQuery } from "@/ee/page-permission/queries/page-p
|
||||
import { PagePermissionTab } from "@/ee/page-permission";
|
||||
import { PublishTab } from "./publish-tab";
|
||||
import { useShareForPageQuery } from "@/features/share/queries/share-query";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useIsCloudEE } from "@/hooks/use-is-cloud-ee";
|
||||
import { useAtom } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom";
|
||||
import { useSpaceQuery } from "@/features/space/queries/space-query";
|
||||
@@ -34,9 +33,9 @@ export function PageShareModal({ readOnly }: PageShareModalProps) {
|
||||
const { pageSlug, spaceSlug } = useParams();
|
||||
const pageSlugId = extractPageSlugId(pageSlug);
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const hasPagePermissions = useHasFeature(Feature.PAGE_PERMISSIONS);
|
||||
const isCloudEE = useIsCloudEE();
|
||||
const [activeTab, setActiveTab] = useState<string | null>(
|
||||
hasPagePermissions ? "access" : "publish",
|
||||
isCloudEE ? "access" : "publish",
|
||||
);
|
||||
|
||||
const [workspace] = useAtom(workspaceAtom);
|
||||
@@ -52,7 +51,7 @@ export function PageShareModal({ readOnly }: PageShareModalProps) {
|
||||
const isPubliclyShared = !!share;
|
||||
|
||||
const { data: restrictionInfo, isLoading: restrictionLoading } =
|
||||
usePageRestrictionInfoQuery(opened && hasPagePermissions ? pageId : undefined);
|
||||
usePageRestrictionInfoQuery(opened && isCloudEE ? pageId : undefined);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -93,7 +92,7 @@ export function PageShareModal({ readOnly }: PageShareModalProps) {
|
||||
</Tabs.List>
|
||||
|
||||
<Tabs.Panel value="access">
|
||||
{!hasPagePermissions ? (
|
||||
{!isCloudEE ? (
|
||||
<Stack align="center" py="md">
|
||||
<IconLock size={20} stroke={1.5} />
|
||||
<Text size="sm" ta="center" fw={500}>
|
||||
|
||||
@@ -6,23 +6,21 @@ import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label.ts";
|
||||
import useEnterpriseAccess from "@/ee/hooks/use-enterprise-access.tsx";
|
||||
|
||||
export default function DisablePublicSharing() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Group justify="space-between" wrap="nowrap" gap="xl">
|
||||
<div>
|
||||
<Text size="md">{t("Disable public sharing")}</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
{t("Prevent members from sharing pages publicly.")}
|
||||
</Text>
|
||||
</div>
|
||||
<div>
|
||||
<Text size="md">{t("Disable public sharing")}</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
{t("Prevent members from sharing pages publicly.")}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<DisablePublicSharingToggle />
|
||||
<DisablePublicSharingToggle />
|
||||
</Group>
|
||||
);
|
||||
}
|
||||
@@ -33,8 +31,7 @@ function DisablePublicSharingToggle() {
|
||||
const [checked, setChecked] = useState(
|
||||
workspace?.settings?.sharing?.disabled === true,
|
||||
);
|
||||
const hasSharingControls = useHasFeature(Feature.SHARING_CONTROLS);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const hasAccess = useEnterpriseAccess();
|
||||
|
||||
const applyChange = async (value: boolean) => {
|
||||
try {
|
||||
@@ -75,11 +72,15 @@ function DisablePublicSharingToggle() {
|
||||
};
|
||||
|
||||
return (
|
||||
<Tooltip label={upgradeLabel} disabled={hasSharingControls} refProp="rootRef">
|
||||
<Tooltip
|
||||
label={t("Requires an enterprise license")}
|
||||
disabled={hasAccess}
|
||||
refProp="rootRef"
|
||||
>
|
||||
<Switch
|
||||
checked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={!hasSharingControls}
|
||||
disabled={!hasAccess}
|
||||
aria-label={t("Toggle public sharing")}
|
||||
/>
|
||||
</Tooltip>
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
import {
|
||||
Group,
|
||||
Text,
|
||||
Switch,
|
||||
MantineSize,
|
||||
Title,
|
||||
Tooltip,
|
||||
} from "@mantine/core";
|
||||
import { Group, Text, Switch, MantineSize, Title } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature.ts";
|
||||
import { Feature } from "@/ee/features.ts";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label.ts";
|
||||
|
||||
export default function EnforceMfa() {
|
||||
const { t } = useTranslation();
|
||||
@@ -43,8 +33,6 @@ export function EnforceMfaToggle({ size, label }: EnforceMfaToggleProps) {
|
||||
const { t } = useTranslation();
|
||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
||||
const [checked, setChecked] = useState(workspace?.enforceMfa);
|
||||
const hasAccess = useHasFeature(Feature.MFA);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
|
||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.currentTarget.checked;
|
||||
@@ -61,16 +49,13 @@ export function EnforceMfaToggle({ size, label }: EnforceMfaToggleProps) {
|
||||
};
|
||||
|
||||
return (
|
||||
<Tooltip label={upgradeLabel} disabled={hasAccess} refProp="rootRef">
|
||||
<Switch
|
||||
size={size}
|
||||
label={label}
|
||||
labelPosition="left"
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={!hasAccess}
|
||||
aria-label={t("Toggle MFA enforcement")}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Switch
|
||||
size={size}
|
||||
label={label}
|
||||
labelPosition="left"
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
aria-label={t("Toggle MFA enforcement")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import { Group, Text, Switch, MantineSize, Tooltip } from "@mantine/core";
|
||||
import { Group, Text, Switch, MantineSize } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature.ts";
|
||||
import { Feature } from "@/ee/features.ts";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label.ts";
|
||||
|
||||
export default function EnforceSso() {
|
||||
const { t } = useTranslation();
|
||||
@@ -36,8 +33,6 @@ export function EnforceSsoToggle({ size, label }: EnforceSsoToggleProps) {
|
||||
const { t } = useTranslation();
|
||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
||||
const [checked, setChecked] = useState(workspace?.enforceSso);
|
||||
const hasAccess = useHasFeature(Feature.SSO_CUSTOM);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
|
||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.currentTarget.checked;
|
||||
@@ -54,16 +49,13 @@ export function EnforceSsoToggle({ size, label }: EnforceSsoToggleProps) {
|
||||
};
|
||||
|
||||
return (
|
||||
<Tooltip label={upgradeLabel} disabled={hasAccess} refProp="rootRef">
|
||||
<Switch
|
||||
size={size}
|
||||
label={label}
|
||||
labelPosition="left"
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={!hasAccess}
|
||||
aria-label={t("Toggle sso enforcement")}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Switch
|
||||
size={size}
|
||||
label={label}
|
||||
labelPosition="left"
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
aria-label={t("Toggle sso enforcement")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,6 @@ import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ISpace } from "@/features/space/types/space.types.ts";
|
||||
import { useUpdateSpaceMutation } from "@/features/space/queries/space-query.ts";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature.ts";
|
||||
import { Feature } from "@/ee/features.ts";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label.ts";
|
||||
|
||||
type SpacePublicSharingToggleProps = {
|
||||
space: ISpace;
|
||||
@@ -20,9 +17,6 @@ export default function SpacePublicSharingToggle({
|
||||
const { t } = useTranslation();
|
||||
const [workspace] = useAtom(workspaceAtom);
|
||||
const workspaceDisabled = workspace?.settings?.sharing?.disabled === true;
|
||||
const hasSharingControls = useHasFeature(Feature.SHARING_CONTROLS);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const isDisabled = !hasSharingControls || workspaceDisabled;
|
||||
const [checked, setChecked] = useState(
|
||||
space.settings?.sharing?.disabled === true,
|
||||
);
|
||||
@@ -74,14 +68,14 @@ export default function SpacePublicSharingToggle({
|
||||
</Text>
|
||||
</div>
|
||||
<Tooltip
|
||||
label={!hasSharingControls ? upgradeLabel : t("Public sharing is disabled at the workspace level")}
|
||||
disabled={!isDisabled}
|
||||
label={t("Public sharing is disabled at the workspace level")}
|
||||
disabled={!workspaceDisabled}
|
||||
refProp="rootRef"
|
||||
>
|
||||
<Switch
|
||||
checked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={isDisabled}
|
||||
disabled={workspaceDisabled}
|
||||
aria-label={t("Toggle space public sharing")}
|
||||
/>
|
||||
</Tooltip>
|
||||
|
||||
@@ -12,18 +12,13 @@ import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label.ts";
|
||||
import useEnterpriseAccess from "@/ee/hooks/use-enterprise-access.tsx";
|
||||
|
||||
type RetentionUnit = "days" | "months" | "years";
|
||||
|
||||
const DEFAULT_RETENTION_DAYS = 30;
|
||||
|
||||
function daysToRetention(days: number): {
|
||||
amount: number;
|
||||
unit: RetentionUnit;
|
||||
} {
|
||||
function daysToRetention(days: number): { amount: number; unit: RetentionUnit } {
|
||||
if (days >= 365 && days % 365 === 0) {
|
||||
return { amount: days / 365, unit: "years" };
|
||||
}
|
||||
@@ -41,19 +36,14 @@ function retentionToDays(amount: number, unit: RetentionUnit): number {
|
||||
|
||||
export default function TrashRetention() {
|
||||
const { t } = useTranslation();
|
||||
const hasRetention = useHasFeature(Feature.RETENTION);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const hasAccess = useEnterpriseAccess();
|
||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
||||
|
||||
const currentDays = workspace?.trashRetentionDays ?? DEFAULT_RETENTION_DAYS;
|
||||
const parsed = daysToRetention(currentDays);
|
||||
|
||||
const [retentionAmount, setRetentionAmount] = useState<number | string>(
|
||||
parsed.amount,
|
||||
);
|
||||
const [retentionUnit, setRetentionUnit] = useState<RetentionUnit>(
|
||||
parsed.unit,
|
||||
);
|
||||
const [retentionAmount, setRetentionAmount] = useState<number | string>(parsed.amount);
|
||||
const [retentionUnit, setRetentionUnit] = useState<RetentionUnit>(parsed.unit);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -73,17 +63,14 @@ export default function TrashRetention() {
|
||||
|
||||
setSaving(true);
|
||||
try {
|
||||
const updatedWorkspace = await updateWorkspace({
|
||||
trashRetentionDays: days,
|
||||
});
|
||||
const updatedWorkspace = await updateWorkspace({ trashRetentionDays: days });
|
||||
setWorkspace(updatedWorkspace);
|
||||
notifications.show({
|
||||
message: t("Trash retention updated"),
|
||||
});
|
||||
} catch (err: any) {
|
||||
notifications.show({
|
||||
message:
|
||||
err?.response?.data?.message || t("Failed to update trash retention"),
|
||||
message: err?.response?.data?.message || t("Failed to update trash retention"),
|
||||
color: "red",
|
||||
});
|
||||
const { amount, unit } = daysToRetention(currentDays);
|
||||
@@ -94,11 +81,10 @@ export default function TrashRetention() {
|
||||
}
|
||||
};
|
||||
|
||||
const isDirty =
|
||||
retentionToDays(
|
||||
typeof retentionAmount === "number" ? retentionAmount : 1,
|
||||
retentionUnit,
|
||||
) !== currentDays;
|
||||
const isDirty = retentionToDays(
|
||||
typeof retentionAmount === "number" ? retentionAmount : 1,
|
||||
retentionUnit,
|
||||
) !== currentDays;
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -107,7 +93,10 @@ export default function TrashRetention() {
|
||||
{t("Pages in trash will be permanently deleted after this period.")}
|
||||
</Text>
|
||||
|
||||
<Tooltip label={upgradeLabel} disabled={hasRetention}>
|
||||
<Tooltip
|
||||
label={t("Requires an enterprise license")}
|
||||
disabled={hasAccess}
|
||||
>
|
||||
<Group gap="xs" wrap="nowrap" maw={320}>
|
||||
<NumberInput
|
||||
value={retentionAmount}
|
||||
@@ -116,7 +105,7 @@ export default function TrashRetention() {
|
||||
hideControls
|
||||
size="sm"
|
||||
w={60}
|
||||
disabled={!hasRetention}
|
||||
disabled={!hasAccess}
|
||||
/>
|
||||
<Select
|
||||
data={[
|
||||
@@ -132,13 +121,13 @@ export default function TrashRetention() {
|
||||
}}
|
||||
size="sm"
|
||||
style={{ flex: 1 }}
|
||||
disabled={!hasRetention}
|
||||
disabled={!hasAccess}
|
||||
/>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleSave}
|
||||
loading={saving}
|
||||
disabled={!hasRetention || !isDirty}
|
||||
disabled={!hasAccess || !isDirty}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
|
||||
@@ -12,15 +12,14 @@ import { useTranslation } from "react-i18next";
|
||||
import EnforceMfa from "@/ee/security/components/enforce-mfa.tsx";
|
||||
import DisablePublicSharing from "@/ee/security/components/disable-public-sharing.tsx";
|
||||
import TrashRetention from "@/ee/security/components/trash-retention.tsx";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import useEnterpriseAccess from "@/ee/hooks/use-enterprise-access.tsx";
|
||||
import { useIsCloudEE } from "@/hooks/use-is-cloud-ee.tsx";
|
||||
|
||||
export default function Security() {
|
||||
const { t } = useTranslation();
|
||||
const { isAdmin } = useUserRole();
|
||||
const hasCustomSso = useHasFeature(Feature.SSO_CUSTOM);
|
||||
const hasRetention = useHasFeature(Feature.RETENTION);
|
||||
const hasSharingControls = useHasFeature(Feature.SHARING_CONTROLS);
|
||||
const hasEnterpriseAccess = useEnterpriseAccess();
|
||||
const isCloudEE = useIsCloudEE();
|
||||
|
||||
if (!isAdmin) {
|
||||
return null;
|
||||
@@ -37,27 +36,39 @@ export default function Security() {
|
||||
|
||||
<Divider my="lg" />
|
||||
|
||||
<DisablePublicSharing />
|
||||
<Divider my="lg" />
|
||||
{(!isCloud() || hasEnterpriseAccess) && (
|
||||
<>
|
||||
<DisablePublicSharing />
|
||||
<Divider my="lg" />
|
||||
</>
|
||||
)}
|
||||
|
||||
<TrashRetention />
|
||||
<Divider my="lg" />
|
||||
{!isCloud() && (
|
||||
<>
|
||||
<TrashRetention />
|
||||
<Divider my="lg" />
|
||||
</>
|
||||
)}
|
||||
|
||||
<Title order={4} my="lg">
|
||||
Single sign-on (SSO)
|
||||
</Title>
|
||||
|
||||
<EnforceSso />
|
||||
<Divider my="lg" />
|
||||
{hasEnterpriseAccess && (
|
||||
<>
|
||||
<EnforceSso />
|
||||
<Divider my="lg" />
|
||||
</>
|
||||
)}
|
||||
|
||||
{(isCloud() || hasCustomSso) && (
|
||||
{isCloudEE && (
|
||||
<>
|
||||
<AllowedDomains />
|
||||
<Divider my="lg" />
|
||||
</>
|
||||
)}
|
||||
|
||||
{hasCustomSso && (
|
||||
{hasEnterpriseAccess && (
|
||||
<>
|
||||
<CreateSsoProvider />
|
||||
<Divider size={0} my="lg" />
|
||||
|
||||
@@ -7,8 +7,7 @@ import CommentEditor from "@/features/comment/components/comment-editor";
|
||||
import { pageEditorAtom } from "@/features/editor/atoms/editor-atoms";
|
||||
import CommentActions from "@/features/comment/components/comment-actions";
|
||||
import CommentMenu from "@/features/comment/components/comment-menu";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useIsCloudEE } from "@/hooks/use-is-cloud-ee";
|
||||
import ResolveComment from "@/ee/comment/components/resolve-comment";
|
||||
import { useHover } from "@mantine/hooks";
|
||||
import {
|
||||
@@ -45,7 +44,7 @@ function CommentListItem({
|
||||
const deleteCommentMutation = useDeleteCommentMutation(comment.pageId);
|
||||
const resolveCommentMutation = useResolveCommentMutation();
|
||||
const [currentUser] = useAtom(currentUserAtom);
|
||||
const canResolve = useHasFeature(Feature.COMMENT_RESOLUTION);
|
||||
const isCloudEE = useIsCloudEE();
|
||||
const createdAtAgo = useTimeAgo(comment.createdAt);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -82,7 +81,7 @@ function CommentListItem({
|
||||
}
|
||||
|
||||
async function handleResolveComment() {
|
||||
if (!canResolve) return;
|
||||
if (!isCloudEE) return;
|
||||
|
||||
try {
|
||||
const isResolved = comment.resolvedAt != null;
|
||||
@@ -138,7 +137,7 @@ function CommentListItem({
|
||||
</Text>
|
||||
|
||||
<div style={{ visibility: hovered ? "visible" : "hidden" }}>
|
||||
{!comment.parentCommentId && canComment && canResolve && (
|
||||
{!comment.parentCommentId && canComment && isCloudEE && (
|
||||
<ResolveComment
|
||||
editor={editor}
|
||||
commentId={comment.id}
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
import { ActionIcon, Menu, Tooltip } from "@mantine/core";
|
||||
import {
|
||||
IconDots,
|
||||
IconEdit,
|
||||
IconTrash,
|
||||
IconCircleCheck,
|
||||
IconCircleCheckFilled,
|
||||
} from "@tabler/icons-react";
|
||||
import { IconDots, IconEdit, IconTrash, IconCircleCheck, IconCircleCheckFilled } from "@tabler/icons-react";
|
||||
import { modals } from "@mantine/modals";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||
import { useIsCloudEE } from "@/hooks/use-is-cloud-ee";
|
||||
|
||||
type CommentMenuProps = {
|
||||
onEditComment: () => void;
|
||||
@@ -21,17 +13,16 @@ type CommentMenuProps = {
|
||||
isParentComment?: boolean;
|
||||
};
|
||||
|
||||
function CommentMenu({
|
||||
onEditComment,
|
||||
onDeleteComment,
|
||||
function CommentMenu({
|
||||
onEditComment,
|
||||
onDeleteComment,
|
||||
onResolveComment,
|
||||
canEdit = true,
|
||||
isResolved = false,
|
||||
isParentComment = false,
|
||||
isParentComment = false
|
||||
}: CommentMenuProps) {
|
||||
const { t } = useTranslation();
|
||||
const canResolve = useHasFeature(Feature.COMMENT_RESOLUTION);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const isCloudEE = useIsCloudEE();
|
||||
|
||||
//@ts-ignore
|
||||
const openDeleteModal = () =>
|
||||
@@ -53,34 +44,33 @@ function CommentMenu({
|
||||
|
||||
<Menu.Dropdown>
|
||||
{canEdit && (
|
||||
<Menu.Item
|
||||
onClick={onEditComment}
|
||||
leftSection={<IconEdit size={14} />}
|
||||
>
|
||||
<Menu.Item onClick={onEditComment} leftSection={<IconEdit size={14} />}>
|
||||
{t("Edit comment")}
|
||||
</Menu.Item>
|
||||
)}
|
||||
{isParentComment &&
|
||||
(canResolve ? (
|
||||
<Menu.Item
|
||||
onClick={onResolveComment}
|
||||
{isParentComment && (
|
||||
isCloudEE ? (
|
||||
<Menu.Item
|
||||
onClick={onResolveComment}
|
||||
leftSection={
|
||||
isResolved ? (
|
||||
<IconCircleCheckFilled size={14} />
|
||||
) : (
|
||||
isResolved ?
|
||||
<IconCircleCheckFilled size={14} /> :
|
||||
<IconCircleCheck size={14} />
|
||||
)
|
||||
}
|
||||
>
|
||||
{isResolved ? t("Re-open comment") : t("Resolve comment")}
|
||||
</Menu.Item>
|
||||
) : (
|
||||
<Tooltip label={upgradeLabel} position="left">
|
||||
<Menu.Item disabled leftSection={<IconCircleCheck size={14} />}>
|
||||
<Tooltip label={t("Available in enterprise edition")} position="left">
|
||||
<Menu.Item
|
||||
disabled
|
||||
leftSection={<IconCircleCheck size={14} />}
|
||||
>
|
||||
{t("Resolve comment")}
|
||||
</Menu.Item>
|
||||
</Tooltip>
|
||||
))}
|
||||
)
|
||||
)}
|
||||
<Menu.Item
|
||||
leftSection={<IconTrash size={14} />}
|
||||
onClick={openDeleteModal}
|
||||
|
||||
@@ -10,5 +10,3 @@ export const readOnlyEditorAtom = atom<Editor | null>(null);
|
||||
export const yjsConnectionStatusAtom = atom<string>("");
|
||||
|
||||
export const showAiMenuAtom = atom(false);
|
||||
|
||||
export const showLinkMenuAtom = atom(false);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BubbleMenu, BubbleMenuProps } from "@tiptap/react/menus";
|
||||
import { isNodeSelection, useEditorState } from "@tiptap/react";
|
||||
import type { Editor } from "@tiptap/react";
|
||||
import { FC, useEffect, useRef, useState } from "react";
|
||||
import { FC, SetStateAction, useCallback, useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
IconBold,
|
||||
IconCode,
|
||||
@@ -26,7 +26,7 @@ import { v7 as uuid7 } from "uuid";
|
||||
import { isCellSelection, isTextSelected } from "@docmost/editor-ext";
|
||||
import { LinkSelector } from "@/features/editor/components/bubble-menu/link-selector.tsx";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { showAiMenuAtom, showLinkMenuAtom } from "@/features/editor/atoms/editor-atoms";
|
||||
import { showAiMenuAtom } from "@/features/editor/atoms/editor-atoms";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom";
|
||||
|
||||
export interface BubbleMenuItem {
|
||||
@@ -49,8 +49,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
||||
const [, setDraftCommentId] = useAtom(draftCommentIdAtom);
|
||||
const showCommentPopupRef = useRef(showCommentPopup);
|
||||
const showAiMenuRef = useRef(showAiMenu);
|
||||
const [showLinkMenu] = useAtom(showLinkMenuAtom);
|
||||
const showLinkMenuRef = useRef(showLinkMenu);
|
||||
const isLinkSelectorOpenRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
showCommentPopupRef.current = showCommentPopup;
|
||||
@@ -60,10 +59,6 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
||||
showAiMenuRef.current = showAiMenu;
|
||||
}, [showAiMenu]);
|
||||
|
||||
useEffect(() => {
|
||||
showLinkMenuRef.current = showLinkMenu;
|
||||
}, [showLinkMenu]);
|
||||
|
||||
const editorState = useEditorState({
|
||||
editor: props.editor,
|
||||
selector: (ctx) => {
|
||||
@@ -131,6 +126,10 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
||||
const bubbleMenuProps: EditorBubbleMenuProps = {
|
||||
...props,
|
||||
shouldShow: ({ state, editor }) => {
|
||||
if (isLinkSelectorOpenRef.current) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const { selection } = state;
|
||||
const { empty } = selection;
|
||||
|
||||
@@ -141,7 +140,6 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
||||
isNodeSelection(selection) ||
|
||||
isCellSelection(selection) ||
|
||||
showAiMenuRef.current ||
|
||||
showLinkMenuRef.current ||
|
||||
showCommentPopupRef?.current
|
||||
) {
|
||||
return false;
|
||||
@@ -154,6 +152,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
||||
onHide: () => {
|
||||
setIsNodeSelectorOpen(false);
|
||||
setIsTextAlignmentOpen(false);
|
||||
setIsLinkSelectorOpen(false);
|
||||
setIsColorSelectorOpen(false);
|
||||
},
|
||||
},
|
||||
@@ -161,10 +160,18 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
||||
|
||||
const [isNodeSelectorOpen, setIsNodeSelectorOpen] = useState(false);
|
||||
const [isTextAlignmentSelectorOpen, setIsTextAlignmentOpen] = useState(false);
|
||||
const [isLinkSelectorOpen, _setIsLinkSelectorOpen] = useState(false);
|
||||
const setIsLinkSelectorOpen = useCallback((value: SetStateAction<boolean>) => {
|
||||
_setIsLinkSelectorOpen((prev) => {
|
||||
const next = typeof value === 'function' ? value(prev) : value;
|
||||
isLinkSelectorOpenRef.current = next;
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
const [isColorSelectorOpen, setIsColorSelectorOpen] = useState(false);
|
||||
|
||||
// Hide the bubble menu immediately when AI menu is shown
|
||||
if (showAiMenu || showLinkMenu) return;
|
||||
if (showAiMenu) return;
|
||||
|
||||
return (
|
||||
<BubbleMenu
|
||||
@@ -194,6 +201,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
||||
setIsOpen={() => {
|
||||
setIsNodeSelectorOpen(!isNodeSelectorOpen);
|
||||
setIsTextAlignmentOpen(false);
|
||||
setIsLinkSelectorOpen(false);
|
||||
setIsColorSelectorOpen(false);
|
||||
}}
|
||||
/>
|
||||
@@ -204,6 +212,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
||||
setIsOpen={() => {
|
||||
setIsTextAlignmentOpen(!isTextAlignmentSelectorOpen);
|
||||
setIsNodeSelectorOpen(false);
|
||||
setIsLinkSelectorOpen(false);
|
||||
setIsColorSelectorOpen(false);
|
||||
}}
|
||||
/>
|
||||
@@ -227,7 +236,16 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
||||
))}
|
||||
</ActionIcon.Group>
|
||||
|
||||
<LinkSelector />
|
||||
<LinkSelector
|
||||
editor={props.editor}
|
||||
isOpen={isLinkSelectorOpen}
|
||||
setIsOpen={(value) => {
|
||||
setIsLinkSelectorOpen(value);
|
||||
setIsNodeSelectorOpen(false);
|
||||
setIsTextAlignmentOpen(false);
|
||||
setIsColorSelectorOpen(false);
|
||||
}}
|
||||
/>
|
||||
|
||||
<ColorSelector
|
||||
editor={props.editor}
|
||||
@@ -236,6 +254,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
||||
setIsColorSelectorOpen(!isColorSelectorOpen);
|
||||
setIsNodeSelectorOpen(false);
|
||||
setIsTextAlignmentOpen(false);
|
||||
setIsLinkSelectorOpen(false);
|
||||
}}
|
||||
/>
|
||||
|
||||
|
||||
@@ -1,25 +1,68 @@
|
||||
import { FC } from "react";
|
||||
import { Dispatch, FC, SetStateAction, useCallback } from "react";
|
||||
import { IconLink } from "@tabler/icons-react";
|
||||
import { ActionIcon, Tooltip } from "@mantine/core";
|
||||
import { useSetAtom } from "jotai";
|
||||
import { ActionIcon, Popover, Tooltip } from "@mantine/core";
|
||||
import { useEditor } from "@tiptap/react";
|
||||
import { TextSelection } from "@tiptap/pm/state";
|
||||
import { LinkEditorPanel } from "@/features/editor/components/link/link-editor-panel.tsx";
|
||||
import { normalizeUrl } from "@/features/editor/components/link/link-view";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { showLinkMenuAtom } from "@/features/editor/atoms/editor-atoms";
|
||||
|
||||
export const LinkSelector: FC = () => {
|
||||
interface LinkSelectorProps {
|
||||
editor: ReturnType<typeof useEditor>;
|
||||
isOpen: boolean;
|
||||
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
export const LinkSelector: FC<LinkSelectorProps> = ({
|
||||
editor,
|
||||
isOpen,
|
||||
setIsOpen,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const setShowLinkMenu = useSetAtom(showLinkMenuAtom);
|
||||
const onLink = useCallback(
|
||||
(url: string, internal?: boolean) => {
|
||||
setIsOpen(false);
|
||||
editor
|
||||
.chain()
|
||||
.focus()
|
||||
.setLink({ href: internal ? url : normalizeUrl(url), internal: !!internal } as any)
|
||||
.command(({ tr }) => {
|
||||
tr.setSelection(TextSelection.create(tr.doc, tr.selection.to));
|
||||
return true;
|
||||
})
|
||||
.run();
|
||||
},
|
||||
[editor, setIsOpen],
|
||||
);
|
||||
|
||||
return (
|
||||
<Tooltip label={t("Add link")} withArrow>
|
||||
<ActionIcon
|
||||
variant="default"
|
||||
size="lg"
|
||||
radius="0"
|
||||
style={{ border: "none" }}
|
||||
onClick={() => setShowLinkMenu(true)}
|
||||
>
|
||||
<IconLink size={16} />
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
<Popover
|
||||
width={320}
|
||||
opened={isOpen}
|
||||
trapFocus
|
||||
offset={{ mainAxis: 35, crossAxis: 0 }}
|
||||
withArrow
|
||||
shadow="md"
|
||||
>
|
||||
<Popover.Target>
|
||||
<Tooltip label={t("Add link")} withArrow>
|
||||
<ActionIcon
|
||||
variant="default"
|
||||
size="lg"
|
||||
radius="0"
|
||||
style={{
|
||||
border: "none",
|
||||
}}
|
||||
onClick={() => setIsOpen(!isOpen)}
|
||||
>
|
||||
<IconLink size={16} />
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
</Popover.Target>
|
||||
|
||||
<Popover.Dropdown p="sm">
|
||||
<LinkEditorPanel onSetLink={onLink} />
|
||||
</Popover.Dropdown>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
} from "@/features/editor/components/table/types/types.ts";
|
||||
import {
|
||||
ActionIcon,
|
||||
LoadingOverlay,
|
||||
Modal,
|
||||
Text,
|
||||
Tooltip,
|
||||
@@ -47,8 +46,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
const computedColorScheme = useComputedColorScheme();
|
||||
const isDirtyRef = useRef(false);
|
||||
const isSavingRef = useRef(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const editorState = useEditorState({
|
||||
editor,
|
||||
@@ -143,7 +140,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
if (isSavingRef.current) return;
|
||||
|
||||
isSavingRef.current = true;
|
||||
setIsSaving(true);
|
||||
|
||||
try {
|
||||
const svgString = decodeBase64ToSvgString(svgXml);
|
||||
@@ -171,7 +167,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
isDirtyRef.current = false;
|
||||
} finally {
|
||||
isSavingRef.current = false;
|
||||
setIsSaving(false);
|
||||
}
|
||||
}, [editor, editorState?.attachmentId]);
|
||||
|
||||
@@ -201,7 +196,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
const handleOpen = useCallback(async () => {
|
||||
if (!editorState?.src) return;
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const url = getFileUrl(editorState.src);
|
||||
const request = await fetch(url, {
|
||||
@@ -219,7 +213,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
isDirtyRef.current = false;
|
||||
open();
|
||||
}
|
||||
@@ -314,7 +307,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
size="lg"
|
||||
aria-label={t("Edit")}
|
||||
variant="subtle"
|
||||
loading={isLoading}
|
||||
>
|
||||
<IconEdit size={18} />
|
||||
</ActionIcon>
|
||||
@@ -347,8 +339,7 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
||||
<Modal.Root opened={opened} onClose={handleClose} fullScreen closeOnEscape={false}>
|
||||
<Modal.Overlay />
|
||||
<Modal.Content style={{ overflow: "hidden" }}>
|
||||
<Modal.Body pos="relative">
|
||||
<LoadingOverlay visible={isSaving} />
|
||||
<Modal.Body>
|
||||
<div style={{ height: "100vh" }}>
|
||||
<DrawIoEmbed
|
||||
ref={drawioRef}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { NodeViewProps, NodeViewWrapper } from "@tiptap/react";
|
||||
import {
|
||||
ActionIcon,
|
||||
Card,
|
||||
LoadingOverlay,
|
||||
Modal,
|
||||
Text,
|
||||
useComputedColorScheme,
|
||||
@@ -35,7 +34,6 @@ export default function DrawioView(props: NodeViewProps) {
|
||||
const computedColorScheme = useComputedColorScheme();
|
||||
const isDirtyRef = useRef(false);
|
||||
const isSavingRef = useRef(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
const handleOpen = async () => {
|
||||
if (!editor.isEditable) {
|
||||
@@ -49,7 +47,6 @@ export default function DrawioView(props: NodeViewProps) {
|
||||
if (isSavingRef.current) return;
|
||||
|
||||
isSavingRef.current = true;
|
||||
setIsSaving(true);
|
||||
|
||||
try {
|
||||
const svgString = decodeBase64ToSvgString(svgXml);
|
||||
@@ -82,7 +79,6 @@ export default function DrawioView(props: NodeViewProps) {
|
||||
isDirtyRef.current = false;
|
||||
} finally {
|
||||
isSavingRef.current = false;
|
||||
setIsSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -140,8 +136,7 @@ export default function DrawioView(props: NodeViewProps) {
|
||||
<Modal.Root opened={opened} onClose={handleClose} fullScreen closeOnEscape={false}>
|
||||
<Modal.Overlay />
|
||||
<Modal.Content style={{ overflow: "hidden" }}>
|
||||
<Modal.Body pos="relative">
|
||||
<LoadingOverlay visible={isSaving} />
|
||||
<Modal.Body>
|
||||
<div style={{ height: "100vh" }}>
|
||||
<DrawIoEmbed
|
||||
ref={drawioRef}
|
||||
|
||||
@@ -56,8 +56,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
const computedColorScheme = useComputedColorScheme();
|
||||
const isDirtyRef = useRef(false);
|
||||
const isSavingRef = useRef(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const isInitialLoadRef = useRef(true);
|
||||
const lastFingerprintRef = useRef("");
|
||||
|
||||
@@ -155,7 +153,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
const handleOpen = useCallback(async () => {
|
||||
if (!editorState?.src) return;
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const url = getFileUrl(editorState.src);
|
||||
const request = await fetch(url, {
|
||||
@@ -169,7 +166,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
isDirtyRef.current = false;
|
||||
isInitialLoadRef.current = true;
|
||||
open();
|
||||
@@ -182,7 +178,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
}
|
||||
|
||||
isSavingRef.current = true;
|
||||
setIsSaving(true);
|
||||
|
||||
try {
|
||||
const { exportToSvg } = await import("@excalidraw/excalidraw");
|
||||
@@ -228,7 +223,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
isDirtyRef.current = false;
|
||||
} finally {
|
||||
isSavingRef.current = false;
|
||||
setIsSaving(false);
|
||||
}
|
||||
}, [editor, excalidrawAPI, editorState?.attachmentId]);
|
||||
|
||||
@@ -345,7 +339,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
size="lg"
|
||||
aria-label={t("Edit")}
|
||||
variant="subtle"
|
||||
loading={isLoading}
|
||||
>
|
||||
<IconEdit size={18} />
|
||||
</ActionIcon>
|
||||
@@ -397,7 +390,7 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
||||
bg="var(--mantine-color-body)"
|
||||
p="xs"
|
||||
>
|
||||
<Button onClick={handleSaveAndExit} size={"compact-sm"} loading={isSaving}>
|
||||
<Button onClick={handleSaveAndExit} size={"compact-sm"}>
|
||||
{t("Save & Exit")}
|
||||
</Button>
|
||||
<Button onClick={handleClose} color="red" size={"compact-sm"}>
|
||||
|
||||
@@ -52,7 +52,6 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
||||
|
||||
const isDirtyRef = useRef(false);
|
||||
const isSavingRef = useRef(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const isInitialLoadRef = useRef(true);
|
||||
const lastFingerprintRef = useRef("");
|
||||
|
||||
@@ -71,7 +70,6 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
||||
}
|
||||
|
||||
isSavingRef.current = true;
|
||||
setIsSaving(true);
|
||||
|
||||
try {
|
||||
const { exportToSvg } = await import("@excalidraw/excalidraw");
|
||||
@@ -122,7 +120,6 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
||||
isDirtyRef.current = false;
|
||||
} finally {
|
||||
isSavingRef.current = false;
|
||||
setIsSaving(false);
|
||||
}
|
||||
}, [excalidrawAPI, editor, attachmentId, updateAttributes]);
|
||||
|
||||
@@ -194,7 +191,7 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
||||
bg="var(--mantine-color-body)"
|
||||
p="xs"
|
||||
>
|
||||
<Button onClick={handleSaveAndExit} size={"compact-sm"} loading={isSaving}>
|
||||
<Button onClick={handleSaveAndExit} size={"compact-sm"}>
|
||||
{t("Save & Exit")}
|
||||
</Button>
|
||||
<Button onClick={handleClose} color="red" size={"compact-sm"}>
|
||||
|
||||
@@ -36,7 +36,7 @@ export const LinkEditorPanel = ({
|
||||
includeUsers: false,
|
||||
includePages: true,
|
||||
spaceId: space?.id,
|
||||
limit: state.isSearchQuery ? 10 : 3,
|
||||
limit: state.isSearchQuery ? 10 : 5,
|
||||
preload: true,
|
||||
});
|
||||
|
||||
@@ -105,7 +105,6 @@ export const LinkEditorPanel = ({
|
||||
value={state.url}
|
||||
onChange={state.onChange}
|
||||
onKeyDown={handleKeyDown}
|
||||
data-autofocus
|
||||
autoFocus
|
||||
/>
|
||||
</form>
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
import { FC, useCallback, useEffect, useRef } from "react";
|
||||
import { BubbleMenu } from "@tiptap/react/menus";
|
||||
import type { Editor } from "@tiptap/react";
|
||||
import { useAtom } from "jotai";
|
||||
import { isTextSelected } from "@docmost/editor-ext";
|
||||
import { showLinkMenuAtom } from "@/features/editor/atoms/editor-atoms";
|
||||
import { LinkEditorPanel } from "@/features/editor/components/link/link-editor-panel";
|
||||
import { normalizeUrl } from "@/lib/utils";
|
||||
import { TextSelection } from "@tiptap/pm/state";
|
||||
import { Paper } from "@mantine/core";
|
||||
|
||||
type EditorLinkMenuProps = {
|
||||
editor: Editor;
|
||||
};
|
||||
|
||||
export const EditorLinkMenu: FC<EditorLinkMenuProps> = ({ editor }) => {
|
||||
const [showLinkMenu, setShowLinkMenu] = useAtom(showLinkMenuAtom);
|
||||
const showLinkMenuRef = useRef(showLinkMenu);
|
||||
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
showLinkMenuRef.current = showLinkMenu;
|
||||
if (showLinkMenu) {
|
||||
editor.commands.focus();
|
||||
}
|
||||
}, [showLinkMenu, editor]);
|
||||
|
||||
const focusInput = useCallback(() => {
|
||||
requestAnimationFrame(() => {
|
||||
containerRef.current
|
||||
?.querySelector<HTMLInputElement>("input")
|
||||
?.focus({ preventScroll: true });
|
||||
});
|
||||
}, []);
|
||||
|
||||
const onSetLink = useCallback(
|
||||
(url: string, internal?: boolean) => {
|
||||
editor
|
||||
.chain()
|
||||
.focus()
|
||||
.setLink({
|
||||
href: internal ? url : normalizeUrl(url),
|
||||
internal: !!internal,
|
||||
} as any)
|
||||
.command(({ tr }) => {
|
||||
tr.setSelection(TextSelection.create(tr.doc, tr.selection.to));
|
||||
return true;
|
||||
})
|
||||
.run();
|
||||
setShowLinkMenu(false);
|
||||
},
|
||||
[editor, setShowLinkMenu],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!showLinkMenu) return;
|
||||
|
||||
const dismiss = () => {
|
||||
setShowLinkMenu(false);
|
||||
editor.commands.focus();
|
||||
editor.commands.setTextSelection(editor.state.selection.to);
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") {
|
||||
dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseDown = (e: MouseEvent) => {
|
||||
if (containerRef.current && !containerRef.current.contains(e.target as Node)) {
|
||||
dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("keydown", handleKeyDown);
|
||||
document.addEventListener("mousedown", handleMouseDown);
|
||||
return () => {
|
||||
document.removeEventListener("keydown", handleKeyDown);
|
||||
document.removeEventListener("mousedown", handleMouseDown);
|
||||
};
|
||||
}, [showLinkMenu, setShowLinkMenu]);
|
||||
|
||||
if (!showLinkMenu) return null;
|
||||
|
||||
return (
|
||||
<BubbleMenu
|
||||
editor={editor}
|
||||
shouldShow={({ editor, state }) => {
|
||||
const { empty } = state.selection;
|
||||
return (
|
||||
showLinkMenuRef.current &&
|
||||
editor.isEditable &&
|
||||
!empty &&
|
||||
isTextSelected(editor)
|
||||
);
|
||||
}}
|
||||
options={{
|
||||
placement: "bottom",
|
||||
offset: 8,
|
||||
onShow: focusInput,
|
||||
onHide: () => {
|
||||
setShowLinkMenu(false);
|
||||
},
|
||||
}}
|
||||
style={{ zIndex: 198, position: "relative" }}
|
||||
>
|
||||
<Paper ref={containerRef} w={320} p="sm" shadow="md" radius={6} withBorder>
|
||||
<LinkEditorPanel onSetLink={onSetLink} />
|
||||
</Paper>
|
||||
</BubbleMenu>
|
||||
);
|
||||
};
|
||||
@@ -29,7 +29,12 @@ import { useSharePageQuery } from "@/features/share/queries/share-query.ts";
|
||||
import { buildSharedPageUrl } from "@/features/page/page.utils.ts";
|
||||
import { extractPageSlugId } from "@/lib";
|
||||
import { sanitizeUrl, copyToClipboard } from "@docmost/editor-ext";
|
||||
import { normalizeUrl } from "@/lib/utils";
|
||||
|
||||
export const normalizeUrl = (url: string): string => {
|
||||
if (!url) return url;
|
||||
if (url.startsWith("/") || /^(\S+):(\/\/)?\S+$/.test(url)) return url;
|
||||
return `https://${url}`;
|
||||
};
|
||||
|
||||
const parseInternalLink = (
|
||||
href: string,
|
||||
|
||||
@@ -66,7 +66,6 @@ import { jwtDecode } from "jwt-decode";
|
||||
import { searchSpotlight } from "@/features/search/constants.ts";
|
||||
import { useEditorScroll } from "./hooks/use-editor-scroll";
|
||||
import { EditorAiMenu } from "@/ee/ai/components/editor/ai-menu/ai-menu";
|
||||
import { EditorLinkMenu } from "@/features/editor/components/link/link-menu";
|
||||
import ColumnsMenu from "@/features/editor/components/columns/columns-menu.tsx";
|
||||
|
||||
interface PageEditorProps {
|
||||
@@ -408,7 +407,6 @@ export default function PageEditor({
|
||||
{editor && editorIsEditable && (
|
||||
<div>
|
||||
<EditorAiMenu editor={editor} />
|
||||
<EditorLinkMenu editor={editor} />
|
||||
<EditorBubbleMenu editor={editor} />
|
||||
<TableMenu editor={editor} />
|
||||
<TableCellMenu editor={editor} appendTo={menuContainerRef} />
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from "@tabler/icons-react";
|
||||
import { CustomAvatar } from "@/components/ui/custom-avatar";
|
||||
import { INotification } from "../types/notification.types";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useState } from "react";
|
||||
import { useMarkReadMutation } from "../queries/notification-query";
|
||||
@@ -36,20 +36,20 @@ export function NotificationItem({
|
||||
|
||||
const isUnread = !notification.readAt;
|
||||
|
||||
const getNotificationMessageKey = (): string => {
|
||||
const getNotificationMessage = (): string => {
|
||||
switch (notification.type) {
|
||||
case "comment.user_mention":
|
||||
return "<bold>{{name}}</bold> mentioned you in a comment";
|
||||
return t("mentioned you in a comment");
|
||||
case "comment.created":
|
||||
return "<bold>{{name}}</bold> commented on a page";
|
||||
return t("commented on a page");
|
||||
case "comment.resolved":
|
||||
return "<bold>{{name}}</bold> resolved a comment";
|
||||
return t("resolved a comment");
|
||||
case "page.user_mention":
|
||||
return "<bold>{{name}}</bold> mentioned you on a page";
|
||||
return t("mentioned you on a page");
|
||||
case "page.permission_granted":
|
||||
return notification.data?.role === "writer"
|
||||
? "<bold>{{name}}</bold> gave you edit access to a page"
|
||||
: "<bold>{{name}}</bold> gave you view access to a page";
|
||||
? t("gave you edit access to a page")
|
||||
: t("gave you view access to a page");
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
@@ -95,11 +95,10 @@ export function NotificationItem({
|
||||
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<Text size="sm" lineClamp={2}>
|
||||
<Trans
|
||||
i18nKey={getNotificationMessageKey()}
|
||||
values={{ name: notification.actor?.name }}
|
||||
components={{ bold: <Text span fw={600} /> }}
|
||||
/>
|
||||
<Text span fw={600}>
|
||||
{notification.actor?.name}
|
||||
</Text>{" "}
|
||||
{getNotificationMessage()}
|
||||
</Text>
|
||||
|
||||
{notification.page && (
|
||||
|
||||
@@ -28,11 +28,9 @@ import { IPage } from "@/features/page/types/page.types.ts";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ConfluenceIcon } from "@/components/icons/confluence-icon.tsx";
|
||||
import { getFileImportSizeLimit } from "@/lib/config.ts";
|
||||
import { getFileImportSizeLimit, isCloud } from "@/lib/config.ts";
|
||||
import { formatBytes } from "@/lib";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import { getFileTaskById } from "@/features/file-task/services/file-task-service.ts";
|
||||
import { queryClient } from "@/main.tsx";
|
||||
import { useQueryEmit } from "@/features/websocket/use-query-emit.ts";
|
||||
@@ -84,6 +82,7 @@ interface ImportFormatSelection {
|
||||
function ImportFormatSelection({ spaceId, onClose }: ImportFormatSelection) {
|
||||
const { t } = useTranslation();
|
||||
const [treeData, setTreeData] = useAtom(treeDataAtom);
|
||||
const [workspace] = useAtom(workspaceAtom);
|
||||
const [fileTaskId, setFileTaskId] = useState<string | null>(null);
|
||||
const emit = useQueryEmit();
|
||||
|
||||
@@ -94,9 +93,8 @@ function ImportFormatSelection({ spaceId, onClose }: ImportFormatSelection) {
|
||||
const confluenceFileRef = useRef<() => void>(null);
|
||||
const zipFileRef = useRef<() => void>(null);
|
||||
|
||||
const canUseConfluence = useHasFeature(Feature.CONFLUENCE_IMPORT);
|
||||
const canUseDocx = useHasFeature(Feature.DOCX_IMPORT);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const canUseConfluence = isCloud() || workspace?.hasLicenseKey;
|
||||
const canUseDocx = isCloud() || workspace?.hasLicenseKey;
|
||||
|
||||
const handleZipUpload = async (selectedFile: File, source: string) => {
|
||||
if (!selectedFile) {
|
||||
@@ -362,7 +360,7 @@ function ImportFormatSelection({ spaceId, onClose }: ImportFormatSelection) {
|
||||
>
|
||||
{(props) => (
|
||||
<Tooltip
|
||||
label={upgradeLabel}
|
||||
label={t("Available in enterprise edition")}
|
||||
disabled={canUseDocx}
|
||||
>
|
||||
<Button
|
||||
@@ -401,7 +399,7 @@ function ImportFormatSelection({ spaceId, onClose }: ImportFormatSelection) {
|
||||
>
|
||||
{(props) => (
|
||||
<Tooltip
|
||||
label={upgradeLabel}
|
||||
label={t("Available in enterprise edition")}
|
||||
disabled={canUseConfluence}
|
||||
>
|
||||
<Button
|
||||
|
||||
@@ -110,7 +110,15 @@ export function useUpdatePageMutation() {
|
||||
return useMutation<IPage, Error, Partial<IPageInput>>({
|
||||
mutationFn: (data) => updatePage(data),
|
||||
onSuccess: (data) => {
|
||||
updatePageData(data);
|
||||
updatePage(data);
|
||||
|
||||
invalidateOnUpdatePage(
|
||||
data.spaceId,
|
||||
data.parentPageId,
|
||||
data.id,
|
||||
data.title,
|
||||
data.icon,
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ import {
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useDebouncedValue } from "@mantine/hooks";
|
||||
import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useLicense } from "@/ee/hooks/use-license";
|
||||
import classes from "./search-spotlight-filters.module.css";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
import { useAtom } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
|
||||
@@ -42,7 +42,7 @@ export function SearchSpotlightFilters({
|
||||
isAiMode = false,
|
||||
}: SearchSpotlightFiltersProps) {
|
||||
const { t } = useTranslation();
|
||||
const hasAttachmentIndexing = useHasFeature(Feature.ATTACHMENT_INDEXING);
|
||||
const { hasLicenseKey } = useLicense();
|
||||
const [selectedSpaceId, setSelectedSpaceId] = useState<string | null>(
|
||||
spaceId || null,
|
||||
);
|
||||
@@ -87,7 +87,7 @@ export function SearchSpotlightFilters({
|
||||
{
|
||||
value: "attachment",
|
||||
label: t("Attachments"),
|
||||
disabled: !hasAttachmentIndexing,
|
||||
disabled: !isCloud() && !hasLicenseKey,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -11,16 +11,15 @@ import { useUnifiedSearch } from "../hooks/use-unified-search.ts";
|
||||
import { useAiSearch } from "../../../ee/ai/hooks/use-ai-search.ts";
|
||||
import { SearchResultItem } from "./search-result-item.tsx";
|
||||
import { AiSearchResult } from "../../../ee/ai/components/ai-search-result.tsx";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useLicense } from "@/ee/hooks/use-license.tsx";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
|
||||
interface SearchSpotlightProps {
|
||||
spaceId?: string;
|
||||
}
|
||||
export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
||||
const { t } = useTranslation();
|
||||
const hasAiFeature = useHasFeature(Feature.AI);
|
||||
const hasAttachmentIndexing = useHasFeature(Feature.ATTACHMENT_INDEXING);
|
||||
const { hasLicenseKey } = useLicense();
|
||||
const [query, setQuery] = useState("");
|
||||
const [debouncedSearchQuery] = useDebouncedValue(query, 300);
|
||||
const [filters, setFilters] = useState<{
|
||||
@@ -85,7 +84,7 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
||||
|
||||
// Determine result type for rendering
|
||||
const isAttachmentSearch =
|
||||
filters.contentType === "attachment" && hasAttachmentIndexing;
|
||||
filters.contentType === "attachment" && (hasLicenseKey || isCloud());
|
||||
|
||||
const resultItems = (searchResults || []).map((result) => (
|
||||
<SearchResultItem
|
||||
@@ -135,7 +134,7 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{isAiMode && hasAiFeature && (
|
||||
{isAiMode && hasLicenseKey && (
|
||||
<Button
|
||||
size="xs"
|
||||
leftSection={<IconSparkles size={16} />}
|
||||
|
||||
@@ -8,8 +8,8 @@ import {
|
||||
IPageSearch,
|
||||
IPageSearchParams,
|
||||
} from "@/features/search/types/search.types";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { useLicense } from "@/ee/hooks/use-license";
|
||||
import { isCloud } from "@/lib/config";
|
||||
|
||||
export type UnifiedSearchResult = IPageSearch | IAttachmentSearch;
|
||||
|
||||
@@ -21,10 +21,10 @@ export function useUnifiedSearch(
|
||||
params: UseUnifiedSearchParams,
|
||||
enabled: boolean = true,
|
||||
): UseQueryResult<UnifiedSearchResult[], Error> {
|
||||
const hasAttachmentIndexing = useHasFeature(Feature.ATTACHMENT_INDEXING);
|
||||
const { hasLicenseKey } = useLicense();
|
||||
|
||||
const isAttachmentSearch =
|
||||
params.contentType === "attachment" && hasAttachmentIndexing;
|
||||
params.contentType === "attachment" && (isCloud() || hasLicenseKey);
|
||||
const searchType = isAttachmentSearch ? "attachment" : "page";
|
||||
|
||||
return useQuery({
|
||||
|
||||
@@ -180,7 +180,7 @@ export default function ShareShell({
|
||||
<AppShell.Main>
|
||||
{children}
|
||||
|
||||
{data && shareId && !(data.features?.length > 0) && <ShareBranding />}
|
||||
{data && shareId && !data.hasLicenseKey && <ShareBranding />}
|
||||
</AppShell.Main>
|
||||
|
||||
<AppShell.Aside
|
||||
|
||||
@@ -41,7 +41,7 @@ export interface ISharedPage extends IShare {
|
||||
level: number;
|
||||
sharedPage: { id: string; slugId: string; title: string; icon: string };
|
||||
};
|
||||
features?: string[];
|
||||
hasLicenseKey: boolean;
|
||||
}
|
||||
|
||||
export interface IShareForPage extends IShare {
|
||||
@@ -71,5 +71,5 @@ export interface IShareInfoInput {
|
||||
export interface ISharedPageTree {
|
||||
share: IShare;
|
||||
pageTree: Partial<IPage[]>;
|
||||
features?: string[];
|
||||
hasLicenseKey: boolean;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
ResponsiveSettingsRow,
|
||||
} from "@/components/ui/responsive-settings-row.tsx";
|
||||
import SpacePublicSharingToggle from "@/ee/security/components/space-public-sharing-toggle.tsx";
|
||||
import useEnterpriseAccess from "@/ee/hooks/use-enterprise-access.tsx";
|
||||
|
||||
interface SpaceDetailsProps {
|
||||
spaceId: string;
|
||||
@@ -27,7 +28,8 @@ interface SpaceDetailsProps {
|
||||
export default function SpaceDetails({ spaceId, readOnly }: SpaceDetailsProps) {
|
||||
const { t } = useTranslation();
|
||||
const { data: space, isLoading, refetch } = useSpaceQuery(spaceId);
|
||||
const showSharingToggle = !readOnly;
|
||||
const hasEnterpriseAccess = useEnterpriseAccess();
|
||||
const showSharingToggle = !readOnly && hasEnterpriseAccess;
|
||||
const [exportOpened, { open: openExportModal, close: closeExportModal }] =
|
||||
useDisclosure(false);
|
||||
const [isIconUploading, setIsIconUploading] = useState(false);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useAtom, useSetAtom } from "jotai";
|
||||
import { useAtom } from "jotai";
|
||||
import { currentUserAtom } from "@/features/user/atoms/current-user-atom";
|
||||
import React, { useEffect } from "react";
|
||||
import useCurrentUser from "@/features/user/hooks/use-current-user";
|
||||
@@ -11,14 +11,10 @@ import { useTreeSocket } from "@/features/websocket/use-tree-socket.ts";
|
||||
import { useNotificationSocket } from "@/features/notification/hooks/use-notification-socket.ts";
|
||||
import { useCollabToken } from "@/features/auth/queries/auth-query.tsx";
|
||||
import { Error404 } from "@/components/ui/error-404.tsx";
|
||||
import { useEntitlements } from "@/ee/entitlement/use-entitlements";
|
||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
||||
|
||||
export function UserProvider({ children }: React.PropsWithChildren) {
|
||||
const [, setCurrentUser] = useAtom(currentUserAtom);
|
||||
const setEntitlements = useSetAtom(entitlementAtom);
|
||||
const { data, isLoading, error, isError } = useCurrentUser();
|
||||
const { data: entitlements } = useEntitlements();
|
||||
const { i18n } = useTranslation();
|
||||
const [, setSocket] = useAtom(socketAtom);
|
||||
// fetch collab token on load
|
||||
@@ -60,12 +56,6 @@ export function UserProvider({ children }: React.PropsWithChildren) {
|
||||
}
|
||||
}, [data, isLoading]);
|
||||
|
||||
useEffect(() => {
|
||||
if (entitlements) {
|
||||
setEntitlements(entitlements);
|
||||
}
|
||||
}, [entitlements]);
|
||||
|
||||
if (isLoading) return <></>;
|
||||
|
||||
if (isError && error?.["response"]?.status === 404) {
|
||||
|
||||
@@ -20,6 +20,7 @@ export interface IWorkspace {
|
||||
emailDomains: string[];
|
||||
memberCount?: number;
|
||||
plan?: string;
|
||||
hasLicenseKey?: boolean;
|
||||
enforceMfa?: boolean;
|
||||
aiSearch?: boolean;
|
||||
generativeAi?: boolean;
|
||||
@@ -83,6 +84,7 @@ export interface IPublicWorkspace {
|
||||
hostname: string;
|
||||
enforceSso: boolean;
|
||||
authProviders: IAuthProvider[];
|
||||
hasLicenseKey?: boolean;
|
||||
}
|
||||
|
||||
export interface IVersion {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { isCloud } from "@/lib/config";
|
||||
import { useLicense } from "@/ee/hooks/use-license";
|
||||
|
||||
export const useIsCloudEE = () => {
|
||||
const { hasLicenseKey } = useLicense();
|
||||
return isCloud() || !!hasLicenseKey;
|
||||
};
|
||||
@@ -94,12 +94,6 @@ export function getPageIcon(icon: string, size = 18): string | ReactNode {
|
||||
);
|
||||
}
|
||||
|
||||
export const normalizeUrl = (url: string): string => {
|
||||
if (!url) return url;
|
||||
if (url.startsWith("/") || /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(url)) return url;
|
||||
return `https://${url}`;
|
||||
};
|
||||
|
||||
export function castToBoolean(value: unknown): boolean {
|
||||
if (value == null) {
|
||||
return false;
|
||||
|
||||
@@ -68,7 +68,7 @@ export default function SharedPage() {
|
||||
/>
|
||||
</Container>
|
||||
|
||||
{data && !shareId && !(data.features?.length > 0) && <ShareBranding />}
|
||||
{data && !shareId && !data.hasLicenseKey && <ShareBranding />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineConfig, loadEnv } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import * as path from "path";
|
||||
|
||||
const envPath = path.resolve(process.cwd(), "..", "..");
|
||||
export const envPath = path.resolve(process.cwd(), "..", "..");
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const {
|
||||
@@ -35,20 +35,6 @@ export default defineConfig(({ mode }) => {
|
||||
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
||||
},
|
||||
plugins: [react()],
|
||||
build: {
|
||||
rolldownOptions: {
|
||||
output: {
|
||||
codeSplitting: {
|
||||
groups: [
|
||||
{ name: "vendor-mantine", test: /@mantine/ },
|
||||
{ name: "vendor-mermaid", test: /mermaid|cytoscape|elkjs/ },
|
||||
{ name: "vendor-excalidraw", test: /excalidraw/ },
|
||||
{ name: "vendor-katex", test: /katex/ },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": "/src",
|
||||
|
||||
+55
-55
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "server",
|
||||
"version": "0.70.3",
|
||||
"version": "0.70.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
@@ -30,123 +30,123 @@
|
||||
"test:e2e": "jest --config test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ai-sdk/google": "^3.0.52",
|
||||
"@ai-sdk/openai": "^3.0.47",
|
||||
"@ai-sdk/openai-compatible": "^2.0.37",
|
||||
"@aws-sdk/client-s3": "3.1014.0",
|
||||
"@aws-sdk/lib-storage": "3.1014.0",
|
||||
"@aws-sdk/s3-request-presigner": "3.1014.0",
|
||||
"@clickhouse/client": "^1.18.2",
|
||||
"@ai-sdk/google": "^3.0.29",
|
||||
"@ai-sdk/openai": "^3.0.29",
|
||||
"@ai-sdk/openai-compatible": "^2.0.30",
|
||||
"@aws-sdk/client-s3": "3.1000.0",
|
||||
"@aws-sdk/lib-storage": "3.1000.0",
|
||||
"@aws-sdk/s3-request-presigner": "3.1000.0",
|
||||
"@clickhouse/client": "^1.17.0",
|
||||
"@fastify/cookie": "^11.0.2",
|
||||
"@fastify/multipart": "^9.4.0",
|
||||
"@fastify/static": "^9.0.0",
|
||||
"@keyv/redis": "^5.1.6",
|
||||
"@langchain/core": "1.1.34",
|
||||
"@langchain/core": "1.1.29",
|
||||
"@langchain/textsplitters": "1.0.1",
|
||||
"@modelcontextprotocol/sdk": "^1.27.1",
|
||||
"@nestjs-labs/nestjs-ioredis": "^11.0.4",
|
||||
"@nestjs/bullmq": "^11.0.4",
|
||||
"@nestjs/cache-manager": "^3.1.0",
|
||||
"@nestjs/common": "^11.1.17",
|
||||
"@nestjs/common": "^11.1.14",
|
||||
"@nestjs/config": "^4.0.3",
|
||||
"@nestjs/core": "^11.1.17",
|
||||
"@nestjs/core": "^11.1.14",
|
||||
"@nestjs/event-emitter": "^3.0.1",
|
||||
"@nestjs/jwt": "11.0.2",
|
||||
"@nestjs/jwt": "11.0.0",
|
||||
"@nestjs/mapped-types": "^2.1.0",
|
||||
"@nestjs/passport": "^11.0.5",
|
||||
"@nestjs/platform-fastify": "^11.1.17",
|
||||
"@nestjs/platform-socket.io": "^11.1.17",
|
||||
"@nestjs/platform-fastify": "^11.1.14",
|
||||
"@nestjs/platform-socket.io": "^11.1.14",
|
||||
"@nestjs/schedule": "^6.1.1",
|
||||
"@nestjs/terminus": "^11.1.1",
|
||||
"@nestjs/websockets": "^11.1.17",
|
||||
"@nestjs/websockets": "^11.1.14",
|
||||
"@node-saml/passport-saml": "^5.1.0",
|
||||
"@react-email/components": "1.0.10",
|
||||
"@react-email/components": "1.0.7",
|
||||
"@react-email/render": "2.0.4",
|
||||
"@socket.io/redis-adapter": "^8.3.0",
|
||||
"ai": "^6.0.134",
|
||||
"ai-sdk-ollama": "^3.8.1",
|
||||
"ai": "^6.0.86",
|
||||
"ai-sdk-ollama": "^3.7.0",
|
||||
"bcrypt": "^6.0.0",
|
||||
"bullmq": "^5.71.0",
|
||||
"bullmq": "^5.70.1",
|
||||
"cache-manager": "^7.2.8",
|
||||
"cheerio": "^1.2.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.15.1",
|
||||
"cookie": "^1.1.1",
|
||||
"fs-extra": "^11.3.4",
|
||||
"happy-dom": "20.8.4",
|
||||
"ioredis": "^5.10.1",
|
||||
"fs-extra": "^11.3.3",
|
||||
"happy-dom": "20.1.0",
|
||||
"ioredis": "^5.4.1",
|
||||
"jsonwebtoken": "^9.0.3",
|
||||
"kysely": "^0.28.14",
|
||||
"kysely": "^0.28.2",
|
||||
"kysely-migration-cli": "^0.4.2",
|
||||
"kysely-postgres-js": "^3.0.0",
|
||||
"ldapts": "^8.1.7",
|
||||
"ldapts": "^7.4.0",
|
||||
"lib0": "^0.2.117",
|
||||
"mammoth": "^1.12.0",
|
||||
"mime-types": "^3.0.2",
|
||||
"msgpackr": "^1.11.9",
|
||||
"nanoid": "5.1.7",
|
||||
"mammoth": "^1.11.0",
|
||||
"mime-types": "^2.1.35",
|
||||
"msgpackr": "^1.11.8",
|
||||
"nanoid": "3.3.11",
|
||||
"nestjs-cls": "^6.2.0",
|
||||
"nestjs-kysely": "^3.1.2",
|
||||
"nestjs-pino": "^4.6.1",
|
||||
"nodemailer": "^8.0.3",
|
||||
"openid-client": "^6.8.2",
|
||||
"otpauth": "^9.5.0",
|
||||
"p-limit": "^7.3.0",
|
||||
"nestjs-kysely": "^1.2.0",
|
||||
"nestjs-pino": "^4.5.0",
|
||||
"nodemailer": "^7.0.12",
|
||||
"openid-client": "^5.7.1",
|
||||
"otpauth": "^9.4.1",
|
||||
"p-limit": "^6.2.0",
|
||||
"passport-google-oauth20": "^2.0.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"pdfjs-dist": "^5.5.207",
|
||||
"pdfjs-dist": "^5.4.394",
|
||||
"pg-tsquery": "^8.4.2",
|
||||
"pgvector": "^0.2.1",
|
||||
"pino-http": "^11.0.0",
|
||||
"pino-pretty": "^13.1.3",
|
||||
"postgres": "^3.4.8",
|
||||
"postmark": "^4.0.7",
|
||||
"postmark": "^4.0.5",
|
||||
"react": "^18.3.1",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.2",
|
||||
"sanitize-filename-ts": "1.0.2",
|
||||
"socket.io": "^4.8.3",
|
||||
"stripe": "^17.7.0",
|
||||
"stripe": "^17.5.0",
|
||||
"tlds": "^1.261.0",
|
||||
"tmp-promise": "^3.0.3",
|
||||
"tseep": "^1.3.1",
|
||||
"typesense": "^3.0.3",
|
||||
"typesense": "^2.1.0",
|
||||
"ws": "^8.19.0",
|
||||
"yauzl": "^3.2.1",
|
||||
"yauzl": "^3.2.0",
|
||||
"zod": "^4.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.28.0",
|
||||
"@eslint/js": "^9.20.0",
|
||||
"@nestjs/cli": "^11.0.16",
|
||||
"@nestjs/schematics": "^11.0.9",
|
||||
"@nestjs/testing": "^11.1.17",
|
||||
"@types/bcrypt": "^6.0.0",
|
||||
"@nestjs/schematics": "^11.0.1",
|
||||
"@nestjs/testing": "^11.0.10",
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/debounce": "^1.2.4",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/mime-types": "^3.0.1",
|
||||
"@types/node": "^25.5.0",
|
||||
"@types/nodemailer": "^7.0.11",
|
||||
"@types/passport-google-oauth20": "^2.0.17",
|
||||
"@types/mime-types": "^2.1.4",
|
||||
"@types/node": "^22.13.4",
|
||||
"@types/nodemailer": "^6.4.17",
|
||||
"@types/passport-google-oauth20": "^2.0.16",
|
||||
"@types/passport-jwt": "^4.0.1",
|
||||
"@types/supertest": "^6.0.3",
|
||||
"@types/ws": "^8.18.1",
|
||||
"@types/yauzl": "^2.10.3",
|
||||
"eslint": "^9.28.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"globals": "^17.4.0",
|
||||
"jest": "^30.3.0",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"globals": "^15.15.0",
|
||||
"jest": "^30.2.0",
|
||||
"kysely-codegen": "^0.20.0",
|
||||
"prettier": "^3.8.1",
|
||||
"react-email": "5.2.10",
|
||||
"prettier": "^3.5.1",
|
||||
"react-email": "5.2.8",
|
||||
"source-map-support": "^0.5.21",
|
||||
"supertest": "^7.2.2",
|
||||
"ts-jest": "^29.4.6",
|
||||
"ts-loader": "^9.5.4",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsconfig-paths": "^4.2.0",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript-eslint": "^8.57.1"
|
||||
"typescript": "^5.7.3",
|
||||
"typescript-eslint": "^8.24.1"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
|
||||
@@ -116,7 +116,7 @@ export class CollaborationGateway {
|
||||
|
||||
// Forward close events
|
||||
client.on('close', (code: number, reason: Buffer) => {
|
||||
this.redisSync!.onSocketClose(socketId, code, reason.buffer as ArrayBuffer);
|
||||
this.redisSync!.onSocketClose(socketId, code, reason);
|
||||
});
|
||||
|
||||
// Forward pong events for keepalive
|
||||
|
||||
@@ -91,6 +91,15 @@ export function extractBearerTokenFromHeader(
|
||||
return type === 'Bearer' ? token : undefined;
|
||||
}
|
||||
|
||||
export function hasLicenseOrEE(opts: {
|
||||
licenseKey: string;
|
||||
plan: string;
|
||||
isCloud: boolean;
|
||||
}): boolean {
|
||||
const { licenseKey, plan, isCloud } = opts;
|
||||
return Boolean(licenseKey) || (isCloud && plan === 'business');
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a database URL for postgres.js compatibility.
|
||||
* - Removes `sslmode=no-verify` (not supported by postgres.js), keeps other sslmode values
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import type { StringValue } from 'ms';
|
||||
import { EnvironmentService } from '../../../integrations/environment/environment.service';
|
||||
import {
|
||||
JwtApiKeyPayload,
|
||||
@@ -97,7 +96,7 @@ export class TokenService {
|
||||
apiKeyId: string;
|
||||
user: User;
|
||||
workspaceId: string;
|
||||
expiresIn?: StringValue | number;
|
||||
expiresIn?: string | number;
|
||||
}): Promise<string> {
|
||||
const { apiKeyId, user, workspaceId, expiresIn } = opts;
|
||||
if (isUserDisabled(user)) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
import type { StringValue } from 'ms';
|
||||
import { EnvironmentService } from '../../integrations/environment/environment.service';
|
||||
import { TokenService } from './services/token.service';
|
||||
|
||||
@@ -11,7 +10,7 @@ import { TokenService } from './services/token.service';
|
||||
return {
|
||||
secret: environmentService.getAppSecret(),
|
||||
signOptions: {
|
||||
expiresIn: environmentService.getJwtTokenExpiresIn() as StringValue,
|
||||
expiresIn: environmentService.getJwtTokenExpiresIn(),
|
||||
issuer: 'Docmost',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -91,15 +91,9 @@ export class SearchService {
|
||||
return { items: [] };
|
||||
}
|
||||
|
||||
const isRestricted =
|
||||
await this.pagePermissionRepo.hasRestrictedAncestor(share.pageId);
|
||||
if (isRestricted) {
|
||||
return { items: [] };
|
||||
}
|
||||
|
||||
const pageIdsToSearch = [];
|
||||
if (share.includeSubPages) {
|
||||
const pageList = await this.pageRepo.getPageAndDescendantsExcludingRestricted(
|
||||
const pageList = await this.pageRepo.getPageAndDescendants(
|
||||
share.pageId,
|
||||
{
|
||||
includeContent: false,
|
||||
|
||||
@@ -28,7 +28,8 @@ import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
||||
import { Public } from '../../common/decorators/public.decorator';
|
||||
import { ShareRepo } from '@docmost/db/repos/share/share.repo';
|
||||
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
||||
import { LicenseCheckService } from '../../integrations/environment/license-check.service';
|
||||
import { EnvironmentService } from '../../integrations/environment/environment.service';
|
||||
import { hasLicenseOrEE } from '../../common/helpers';
|
||||
import { AuditEvent, AuditResource } from '../../common/events/audit-events';
|
||||
import {
|
||||
AUDIT_SERVICE,
|
||||
@@ -44,7 +45,7 @@ export class ShareController {
|
||||
private readonly pageRepo: PageRepo,
|
||||
private readonly pagePermissionRepo: PagePermissionRepo,
|
||||
private readonly pageAccessService: PageAccessService,
|
||||
private readonly licenseCheckService: LicenseCheckService,
|
||||
private readonly environmentService: EnvironmentService,
|
||||
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
||||
) {}
|
||||
|
||||
@@ -80,10 +81,11 @@ export class ShareController {
|
||||
|
||||
return {
|
||||
...shareData,
|
||||
features: this.licenseCheckService.resolveFeatures(
|
||||
workspace.licenseKey,
|
||||
workspace.plan,
|
||||
),
|
||||
hasLicenseKey: hasLicenseOrEE({
|
||||
licenseKey: workspace.licenseKey,
|
||||
isCloud: this.environmentService.isCloud(),
|
||||
plan: workspace.plan,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -257,10 +259,11 @@ export class ShareController {
|
||||
|
||||
return {
|
||||
...treeData,
|
||||
features: this.licenseCheckService.resolveFeatures(
|
||||
workspace.licenseKey,
|
||||
workspace.plan,
|
||||
),
|
||||
hasLicenseKey: hasLicenseOrEE({
|
||||
licenseKey: workspace.licenseKey,
|
||||
isCloud: this.environmentService.isCloud(),
|
||||
plan: workspace.plan,
|
||||
}),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,10 +139,10 @@ export class SpaceService {
|
||||
});
|
||||
|
||||
if (
|
||||
!this.licenseCheckService.hasFeature(workspace.licenseKey, 'security:settings', workspace.plan)
|
||||
!this.licenseCheckService.isValidEELicense(workspace.licenseKey)
|
||||
) {
|
||||
throw new ForbiddenException(
|
||||
'This feature requires a valid license',
|
||||
'This feature requires a valid enterprise license',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ export class UserController {
|
||||
const workspaceInfo = {
|
||||
...rest,
|
||||
memberCount,
|
||||
hasLicenseKey: Boolean(licenseKey),
|
||||
};
|
||||
|
||||
return { user: authUser, workspace: workspaceInfo };
|
||||
|
||||
@@ -32,10 +32,8 @@ import {
|
||||
} from '../../casl/interfaces/workspace-ability.type';
|
||||
import { FastifyReply } from 'fastify';
|
||||
import { EnvironmentService } from '../../../integrations/environment/environment.service';
|
||||
import { LicenseCheckService } from '../../../integrations/environment/license-check.service';
|
||||
import { CheckHostnameDto } from '../dto/check-hostname.dto';
|
||||
import { RemoveWorkspaceUserDto } from '../dto/remove-workspace-user.dto';
|
||||
import { WorkspaceRepo } from '@docmost/db/repos/workspace/workspace.repo';
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('workspace')
|
||||
@@ -44,9 +42,7 @@ export class WorkspaceController {
|
||||
private readonly workspaceService: WorkspaceService,
|
||||
private readonly workspaceInvitationService: WorkspaceInvitationService,
|
||||
private readonly workspaceAbility: WorkspaceAbilityFactory,
|
||||
private readonly workspaceRepo: WorkspaceRepo,
|
||||
private environmentService: EnvironmentService,
|
||||
private licenseCheckService: LicenseCheckService,
|
||||
) {}
|
||||
|
||||
@Public()
|
||||
@@ -62,23 +58,6 @@ export class WorkspaceController {
|
||||
return this.workspaceService.getWorkspaceInfo(workspace.id);
|
||||
}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post('entitlements')
|
||||
async getEntitlements(@AuthWorkspace() workspace: Workspace) {
|
||||
let { licenseKey } = workspace;
|
||||
const { plan } = workspace;
|
||||
|
||||
if (!licenseKey) {
|
||||
licenseKey = await this.workspaceRepo.findLicenseKeyById(workspace.id);
|
||||
}
|
||||
|
||||
return {
|
||||
cloud: this.environmentService.isCloud(),
|
||||
tier: this.licenseCheckService.resolveTier(licenseKey, plan),
|
||||
features: this.licenseCheckService.resolveFeatures(licenseKey, plan),
|
||||
};
|
||||
}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post('update')
|
||||
async updateWorkspace(
|
||||
|
||||
@@ -85,7 +85,7 @@ export class WorkspaceService {
|
||||
async getWorkspacePublicData(workspaceId: string) {
|
||||
const workspace = await this.db
|
||||
.selectFrom('workspaces')
|
||||
.select(['id', 'name', 'logo', 'hostname', 'enforceSso', 'licenseKey', 'plan'])
|
||||
.select(['id', 'name', 'logo', 'hostname', 'enforceSso', 'licenseKey'])
|
||||
.select((eb) =>
|
||||
jsonArrayFrom(
|
||||
eb
|
||||
@@ -106,9 +106,12 @@ export class WorkspaceService {
|
||||
throw new NotFoundException('Workspace not found');
|
||||
}
|
||||
|
||||
const { licenseKey, plan, ...rest } = workspace;
|
||||
const { licenseKey, ...rest } = workspace;
|
||||
|
||||
return rest;
|
||||
return {
|
||||
...rest,
|
||||
hasLicenseKey: Boolean(licenseKey),
|
||||
};
|
||||
}
|
||||
|
||||
async create(
|
||||
@@ -329,32 +332,14 @@ export class WorkspaceService {
|
||||
) {
|
||||
const ws = await this.db
|
||||
.selectFrom('workspaces')
|
||||
.select(['id', 'licenseKey', 'plan', 'trashRetentionDays'])
|
||||
.select(['id', 'licenseKey', 'trashRetentionDays'])
|
||||
.where('id', '=', workspaceId)
|
||||
.executeTakeFirst();
|
||||
|
||||
if (!ws) {
|
||||
throw new NotFoundException('Workspace not found');
|
||||
}
|
||||
|
||||
if (typeof updateWorkspaceDto.mcpEnabled !== 'undefined') {
|
||||
if (!this.licenseCheckService.hasFeature(ws.licenseKey, 'mcp', ws.plan)) {
|
||||
throw new ForbiddenException(
|
||||
'This feature requires a valid license',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
typeof updateWorkspaceDto.disablePublicSharing !== 'undefined' ||
|
||||
typeof updateWorkspaceDto.trashRetentionDays !== 'undefined' ||
|
||||
typeof updateWorkspaceDto.restrictApiToAdmins !== 'undefined'
|
||||
) {
|
||||
if (!this.licenseCheckService.hasFeature(ws.licenseKey, 'security:settings', ws.plan)) {
|
||||
throw new ForbiddenException(
|
||||
'This feature requires a valid license',
|
||||
);
|
||||
}
|
||||
if (!this.licenseCheckService.isValidEELicense(ws.licenseKey)) {
|
||||
throw new ForbiddenException(
|
||||
'This feature requires a valid enterprise license',
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -518,7 +503,10 @@ export class WorkspaceService {
|
||||
}
|
||||
|
||||
const { licenseKey, ...rest } = workspace;
|
||||
return rest;
|
||||
return {
|
||||
...rest,
|
||||
hasLicenseKey: Boolean(licenseKey),
|
||||
};
|
||||
}
|
||||
|
||||
async getWorkspaceUsers(
|
||||
|
||||
+1
-1
Submodule apps/server/src/ee updated: c2755be37c...47e76280fd
@@ -25,75 +25,4 @@ export class LicenseCheckService {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
hasFeature(licenseKey: string, feature: string, plan?: string): boolean {
|
||||
if (this.environmentService.isCloud()) {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const { getFeaturesForCloudPlan } = require('../../ee/licence/feature-registry');
|
||||
return getFeaturesForCloudPlan(plan).has(feature);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const LicenseModule = require('../../ee/licence/license.service');
|
||||
const licenseService = this.moduleRef.get(LicenseModule.LicenseService, {
|
||||
strict: false,
|
||||
});
|
||||
return licenseService.hasFeature(licenseKey, feature);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
getFeatures(licenseKey: string): string[] {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const LicenseModule = require('../../ee/licence/license.service');
|
||||
const licenseService = this.moduleRef.get(LicenseModule.LicenseService, {
|
||||
strict: false,
|
||||
});
|
||||
return licenseService.getFeatures(licenseKey);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
resolveFeatures(licenseKey: string, plan: string): string[] {
|
||||
if (this.environmentService.isCloud()) {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const { getFeaturesForCloudPlan } = require('../../ee/licence/feature-registry');
|
||||
return [...getFeaturesForCloudPlan(plan)];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
return this.getFeatures(licenseKey);
|
||||
}
|
||||
|
||||
resolveTier(licenseKey: string, plan: string): string {
|
||||
if (this.environmentService.isCloud()) {
|
||||
return plan ?? 'standard';
|
||||
}
|
||||
|
||||
return this.getLicenseType(licenseKey) ?? 'free';
|
||||
}
|
||||
|
||||
private getLicenseType(licenseKey: string): string | null {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const LicenseModule = require('../../ee/licence/license.service');
|
||||
const licenseService = this.moduleRef.get(LicenseModule.LicenseService, {
|
||||
strict: false,
|
||||
});
|
||||
return licenseService.getLicenseType(licenseKey);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ import { PageRepo } from '@docmost/db/repos/page/page.repo';
|
||||
import { PagePermissionRepo } from '@docmost/db/repos/page/page-permission.repo';
|
||||
import { Node } from '@tiptap/pm/model';
|
||||
import { EditorState } from '@tiptap/pm/state';
|
||||
import slugify from '@sindresorhus/slugify';
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
import slugify = require('@sindresorhus/slugify');
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const packageJson = require('../../../package.json');
|
||||
import { EnvironmentService } from '../environment/environment.service';
|
||||
|
||||
@@ -4,7 +4,8 @@ import * as path from 'path';
|
||||
import { v7 } from 'uuid';
|
||||
import { InsertableBacklink } from '@docmost/db/types/entity.types';
|
||||
import { Cheerio, CheerioAPI, load } from 'cheerio';
|
||||
import slugify from '@sindresorhus/slugify';
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
import slugify = require('@sindresorhus/slugify');
|
||||
|
||||
// Check if text contains Unicode characters (for emojis/icons)
|
||||
function isUnicodeCharacter(text: string): boolean {
|
||||
|
||||
@@ -17,6 +17,5 @@
|
||||
},
|
||||
"affected": {
|
||||
"defaultBase": "main"
|
||||
},
|
||||
"analytics": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+64
-62
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "docmost",
|
||||
"homepage": "https://docmost.com",
|
||||
"version": "0.70.3",
|
||||
"version": "0.70.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "nx run-many -t build",
|
||||
@@ -19,71 +19,73 @@
|
||||
"clean": "rm -rf apps/*/dist packages/*/dist apps/client/node_modules/.vite"
|
||||
},
|
||||
"dependencies": {
|
||||
"@braintree/sanitize-url": "^7.1.2",
|
||||
"@braintree/sanitize-url": "^7.1.0",
|
||||
"@casl/ability": "6.8.0",
|
||||
"@docmost/editor-ext": "workspace:*",
|
||||
"@floating-ui/dom": "^1.7.3",
|
||||
"@hocuspocus/provider": "3.4.4",
|
||||
"@hocuspocus/server": "3.4.4",
|
||||
"@hocuspocus/transformer": "3.4.4",
|
||||
"@joplin/turndown": "^4.0.82",
|
||||
"@joplin/turndown-plugin-gfm": "^1.0.64",
|
||||
"@sindresorhus/slugify": "3.0.0",
|
||||
"@tiptap/core": "3.20.4",
|
||||
"@tiptap/extension-code-block": "3.20.4",
|
||||
"@tiptap/extension-collaboration": "3.20.4",
|
||||
"@tiptap/extension-collaboration-caret": "3.20.4",
|
||||
"@tiptap/extension-color": "3.20.4",
|
||||
"@tiptap/extension-document": "3.20.4",
|
||||
"@tiptap/extension-heading": "3.20.4",
|
||||
"@tiptap/extension-highlight": "3.20.4",
|
||||
"@tiptap/extension-history": "3.20.4",
|
||||
"@tiptap/extension-image": "3.20.4",
|
||||
"@tiptap/extension-link": "3.20.4",
|
||||
"@tiptap/extension-list": "3.20.4",
|
||||
"@tiptap/extension-placeholder": "3.20.4",
|
||||
"@tiptap/extension-subscript": "3.20.4",
|
||||
"@tiptap/extension-superscript": "3.20.4",
|
||||
"@tiptap/extension-table": "3.20.4",
|
||||
"@tiptap/extension-text": "3.20.4",
|
||||
"@tiptap/extension-text-align": "3.20.4",
|
||||
"@tiptap/extension-text-style": "3.20.4",
|
||||
"@tiptap/extension-typography": "3.20.4",
|
||||
"@tiptap/extension-unique-id": "3.20.4",
|
||||
"@tiptap/extension-youtube": "3.20.4",
|
||||
"@tiptap/html": "3.20.4",
|
||||
"@tiptap/pm": "3.20.4",
|
||||
"@tiptap/react": "3.20.4",
|
||||
"@tiptap/starter-kit": "3.20.4",
|
||||
"@tiptap/suggestion": "3.20.4",
|
||||
"@tiptap/y-tiptap": "3.0.2",
|
||||
"@joplin/turndown": "^4.0.74",
|
||||
"@joplin/turndown-plugin-gfm": "^1.0.56",
|
||||
"@sindresorhus/slugify": "1.1.0",
|
||||
"@tiptap/core": "3.17.1",
|
||||
"@tiptap/extension-code-block": "3.17.1",
|
||||
"@tiptap/extension-collaboration": "3.17.1",
|
||||
"@tiptap/extension-collaboration-caret": "3.17.1",
|
||||
"@tiptap/extension-color": "3.17.1",
|
||||
"@tiptap/extension-document": "3.17.1",
|
||||
"@tiptap/extension-heading": "3.17.1",
|
||||
"@tiptap/extension-highlight": "3.17.1",
|
||||
"@tiptap/extension-history": "3.17.1",
|
||||
"@tiptap/extension-image": "3.17.1",
|
||||
"@tiptap/extension-link": "3.17.1",
|
||||
"@tiptap/extension-list": "3.17.1",
|
||||
"@tiptap/extension-placeholder": "3.17.1",
|
||||
"@tiptap/extension-subscript": "3.17.1",
|
||||
"@tiptap/extension-superscript": "3.17.1",
|
||||
"@tiptap/extension-table": "3.17.1",
|
||||
"@tiptap/extension-text": "3.17.1",
|
||||
"@tiptap/extension-text-align": "3.17.1",
|
||||
"@tiptap/extension-text-style": "3.17.1",
|
||||
"@tiptap/extension-typography": "3.17.1",
|
||||
"@tiptap/extension-unique-id": "^3.17.1",
|
||||
"@tiptap/extension-youtube": "3.17.1",
|
||||
"@tiptap/html": "3.17.1",
|
||||
"@tiptap/pm": "3.17.1",
|
||||
"@tiptap/react": "3.17.1",
|
||||
"@tiptap/starter-kit": "3.17.1",
|
||||
"@tiptap/suggestion": "3.17.1",
|
||||
"@tiptap/y-tiptap": "^3.0.2",
|
||||
"@types/qrcode": "^1.5.5",
|
||||
"bytes": "^3.1.2",
|
||||
"cross-env": "^10.1.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"date-fns": "^4.1.0",
|
||||
"diff": "8.0.3",
|
||||
"dompurify": "^3.3.3",
|
||||
"dompurify": "^3.3.1",
|
||||
"fractional-indexing-jittered": "^1.0.0",
|
||||
"highlight.js": "^11.11.1",
|
||||
"image-dimensions": "^2.5.0",
|
||||
"ioredis": "^5.4.1",
|
||||
"jszip": "^3.10.1",
|
||||
"linkifyjs": "^4.3.2",
|
||||
"marked": "17.0.5",
|
||||
"marked": "13.0.3",
|
||||
"ms": "3.0.0-canary.1",
|
||||
"qrcode": "^1.5.4",
|
||||
"rfc6902": "5.2.0",
|
||||
"uuid": "^13.0.0",
|
||||
"rfc6902": "5.1.2",
|
||||
"uuid": "^11.1.0",
|
||||
"y-indexeddb": "^9.0.12",
|
||||
"y-prosemirror": "1.3.7",
|
||||
"yjs": "^13.6.30"
|
||||
"yjs": "^13.6.29"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nx/js": "22.6.1",
|
||||
"@nx/js": "22.5.3",
|
||||
"@types/bytes": "^3.1.5",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/turndown": "^5.0.6",
|
||||
"concurrently": "^9.2.1",
|
||||
"nx": "22.6.1",
|
||||
"tsx": "^4.21.0"
|
||||
"@types/uuid": "^10.0.0",
|
||||
"concurrently": "^9.1.2",
|
||||
"nx": "22.5.3",
|
||||
"tsx": "^4.19.3"
|
||||
},
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
@@ -98,28 +100,28 @@
|
||||
"@tiptap/core": "patches/@tiptap__core.patch"
|
||||
},
|
||||
"overrides": {
|
||||
"prosemirror-changeset": "2.4.0",
|
||||
"jsdom": "25.0.1",
|
||||
"jsonwebtoken": "9.0.3",
|
||||
"prosemirror-changeset": "2.3.1",
|
||||
"y-prosemirror": "1.3.7",
|
||||
"glob": "13.0.6",
|
||||
"qs": "6.14.2",
|
||||
"glob": "10.5.0",
|
||||
"lodash": "4.17.23",
|
||||
"ws": "8.19.0",
|
||||
"dompurify": "3.3.3",
|
||||
"cross-spawn": "7.0.5",
|
||||
"dompurify": "3.3.1",
|
||||
"tmp": "0.2.5",
|
||||
"hono": "4.12.8",
|
||||
"mermaid": "11.13.0",
|
||||
"nanoid@^3": "3.3.8",
|
||||
"socket.io-parser": "4.2.6",
|
||||
"serialize-javascript": "7.0.3",
|
||||
"lodash-es": "4.17.23",
|
||||
"@hono/node-server": "1.19.10",
|
||||
"undici": "7.24.0",
|
||||
"ajv@^6": "6.14.0",
|
||||
"ajv@^8": "8.18.0",
|
||||
"underscore": "1.13.8",
|
||||
"immutable": "4.3.8",
|
||||
"express-rate-limit": "8.2.2",
|
||||
"minimatch@^3": "3.1.5",
|
||||
"minimatch@^5": "5.1.8",
|
||||
"flatted": "3.4.2"
|
||||
"markdown-it": "14.1.1",
|
||||
"@tiptap/core": "3.17.1",
|
||||
"@tiptap/pm": "3.17.1",
|
||||
"@tiptap/starter-kit": "3.17.1",
|
||||
"@tiptap/extension-blockquote": "3.17.1",
|
||||
"@tiptap/extension-bold": "3.17.0",
|
||||
"@tiptap/extension-bubble-menu": "3.17.1",
|
||||
"@tiptap/extension-bullet-list": "3.17.1",
|
||||
"@tiptap/extension-list": "3.17.1",
|
||||
"@tiptap/extension-code": "3.17.1"
|
||||
},
|
||||
"neverBuiltDependencies": []
|
||||
}
|
||||
|
||||
@@ -1,111 +1,80 @@
|
||||
import { findChildren } from '@tiptap/core';
|
||||
import type { Node as ProsemirrorNode } from '@tiptap/pm/model';
|
||||
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
||||
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
||||
import { findChildren } from '@tiptap/core'
|
||||
import type { Node as ProsemirrorNode } from '@tiptap/pm/model'
|
||||
import { Plugin, PluginKey } from '@tiptap/pm/state'
|
||||
import { Decoration, DecorationSet } from '@tiptap/pm/view'
|
||||
// @ts-ignore
|
||||
import highlight from 'highlight.js/lib/core';
|
||||
import highlight from 'highlight.js/lib/core'
|
||||
|
||||
function parseNodes(
|
||||
nodes: any[],
|
||||
className: string[] = [],
|
||||
): { text: string; classes: string[] }[] {
|
||||
function parseNodes(nodes: any[], className: string[] = []): { text: string; classes: string[] }[] {
|
||||
return nodes
|
||||
.map((node) => {
|
||||
const classes = [
|
||||
...className,
|
||||
...(node.properties ? node.properties.className : []),
|
||||
];
|
||||
.map(node => {
|
||||
const classes = [...className, ...(node.properties ? node.properties.className : [])]
|
||||
|
||||
if (node.children) {
|
||||
return parseNodes(node.children, classes);
|
||||
return parseNodes(node.children, classes)
|
||||
}
|
||||
|
||||
return {
|
||||
text: node.value,
|
||||
classes,
|
||||
};
|
||||
}
|
||||
})
|
||||
.flat();
|
||||
.flat()
|
||||
}
|
||||
|
||||
function getHighlightNodes(result: any) {
|
||||
// `.value` for lowlight v1, `.children` for lowlight v2
|
||||
return result.value || result.children || [];
|
||||
return result.value || result.children || []
|
||||
}
|
||||
|
||||
function registered(aliasOrLanguage: string) {
|
||||
return Boolean(highlight.getLanguage(aliasOrLanguage));
|
||||
return Boolean(highlight.getLanguage(aliasOrLanguage))
|
||||
}
|
||||
|
||||
// Max characters to sample for auto-detection to avoid performance issues with large code blocks
|
||||
const AUTO_DETECT_SAMPLE_SIZE = 3000;
|
||||
|
||||
function getDecorations({
|
||||
doc,
|
||||
name,
|
||||
lowlight,
|
||||
defaultLanguage,
|
||||
}: {
|
||||
doc: ProsemirrorNode;
|
||||
name: string;
|
||||
lowlight: any;
|
||||
defaultLanguage: string | null | undefined;
|
||||
doc: ProsemirrorNode
|
||||
name: string
|
||||
lowlight: any
|
||||
defaultLanguage: string | null | undefined
|
||||
}) {
|
||||
const decorations: Decoration[] = [];
|
||||
const decorations: Decoration[] = []
|
||||
|
||||
findChildren(doc, (node) => node.type.name === name).forEach((block) => {
|
||||
let from = block.pos + 1;
|
||||
const language = block.node.attrs.language || defaultLanguage;
|
||||
const languages = lowlight.listLanguages();
|
||||
const textContent = block.node.textContent;
|
||||
findChildren(doc, node => node.type.name === name).forEach(block => {
|
||||
let from = block.pos + 1
|
||||
const language = block.node.attrs.language || defaultLanguage
|
||||
const languages = lowlight.listLanguages()
|
||||
|
||||
let nodes;
|
||||
if (
|
||||
language &&
|
||||
(languages.includes(language) ||
|
||||
registered(language) ||
|
||||
lowlight.registered?.(language))
|
||||
) {
|
||||
nodes = getHighlightNodes(lowlight.highlight(language, textContent));
|
||||
} else {
|
||||
// For auto-detection, sample a limited portion to detect the language,
|
||||
// then highlight the full content with the detected language
|
||||
const sample =
|
||||
textContent.length > AUTO_DETECT_SAMPLE_SIZE
|
||||
? textContent.slice(0, AUTO_DETECT_SAMPLE_SIZE)
|
||||
: textContent;
|
||||
const autoResult = lowlight.highlightAuto(sample);
|
||||
const detectedLanguage = autoResult.data?.language;
|
||||
if (detectedLanguage && textContent.length > AUTO_DETECT_SAMPLE_SIZE) {
|
||||
nodes = getHighlightNodes(
|
||||
lowlight.highlight(detectedLanguage, textContent),
|
||||
);
|
||||
} else {
|
||||
nodes = getHighlightNodes(autoResult);
|
||||
}
|
||||
}
|
||||
const nodes =
|
||||
language && (languages.includes(language) || registered(language) || lowlight.registered?.(language))
|
||||
? getHighlightNodes(lowlight.highlight(language, block.node.textContent))
|
||||
: getHighlightNodes(lowlight.highlightAuto(block.node.textContent))
|
||||
|
||||
parseNodes(nodes).forEach((node) => {
|
||||
const to = from + node.text.length;
|
||||
parseNodes(nodes).forEach(node => {
|
||||
const to = from + node.text.length
|
||||
|
||||
if (node.classes.length) {
|
||||
const decoration = Decoration.inline(from, to, {
|
||||
class: node.classes.join(' '),
|
||||
});
|
||||
})
|
||||
|
||||
decorations.push(decoration);
|
||||
decorations.push(decoration)
|
||||
}
|
||||
|
||||
from = to;
|
||||
});
|
||||
});
|
||||
from = to
|
||||
})
|
||||
})
|
||||
|
||||
return DecorationSet.create(doc, decorations);
|
||||
return DecorationSet.create(doc, decorations)
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
function isFunction(param: any): param is Function {
|
||||
return typeof param === 'function';
|
||||
return typeof param === 'function'
|
||||
}
|
||||
|
||||
export function LowlightPlugin({
|
||||
@@ -113,18 +82,12 @@ export function LowlightPlugin({
|
||||
lowlight,
|
||||
defaultLanguage,
|
||||
}: {
|
||||
name: string;
|
||||
lowlight: any;
|
||||
defaultLanguage: string | null | undefined;
|
||||
name: string
|
||||
lowlight: any
|
||||
defaultLanguage: string | null | undefined
|
||||
}) {
|
||||
if (
|
||||
!['highlight', 'highlightAuto', 'listLanguages'].every((api) =>
|
||||
isFunction(lowlight[api]),
|
||||
)
|
||||
) {
|
||||
throw Error(
|
||||
'You should provide an instance of lowlight to use the code-block-lowlight extension',
|
||||
);
|
||||
if (!['highlight', 'highlightAuto', 'listLanguages'].every(api => isFunction(lowlight[api]))) {
|
||||
throw Error('You should provide an instance of lowlight to use the code-block-lowlight extension')
|
||||
}
|
||||
|
||||
const lowlightPlugin: Plugin<any> = new Plugin({
|
||||
@@ -139,16 +102,10 @@ export function LowlightPlugin({
|
||||
defaultLanguage,
|
||||
}),
|
||||
apply: (transaction, decorationSet, oldState, newState) => {
|
||||
const oldNodeName = oldState.selection.$head.parent.type.name;
|
||||
const newNodeName = newState.selection.$head.parent.type.name;
|
||||
const oldNodes = findChildren(
|
||||
oldState.doc,
|
||||
(node) => node.type.name === name,
|
||||
);
|
||||
const newNodes = findChildren(
|
||||
newState.doc,
|
||||
(node) => node.type.name === name,
|
||||
);
|
||||
const oldNodeName = oldState.selection.$head.parent.type.name
|
||||
const newNodeName = newState.selection.$head.parent.type.name
|
||||
const oldNodes = findChildren(oldState.doc, node => node.type.name === name)
|
||||
const newNodes = findChildren(newState.doc, node => node.type.name === name)
|
||||
|
||||
if (
|
||||
transaction.docChanged &&
|
||||
@@ -160,23 +117,23 @@ export function LowlightPlugin({
|
||||
// OR transaction has changes that completely encapsulte a node
|
||||
// (for example, a transaction that affects the entire document).
|
||||
// Such transactions can happen during collab syncing via y-prosemirror, for example.
|
||||
transaction.steps.some((step) => {
|
||||
transaction.steps.some(step => {
|
||||
// @ts-ignore
|
||||
return (
|
||||
// @ts-ignore
|
||||
step.from !== undefined &&
|
||||
// @ts-ignore
|
||||
step.to !== undefined &&
|
||||
oldNodes.some((node) => {
|
||||
oldNodes.some(node => {
|
||||
// @ts-ignore
|
||||
return (
|
||||
// @ts-ignore
|
||||
node.pos >= step.from &&
|
||||
// @ts-ignore
|
||||
node.pos + node.node.nodeSize <= step.to
|
||||
);
|
||||
)
|
||||
})
|
||||
);
|
||||
)
|
||||
}))
|
||||
) {
|
||||
return getDecorations({
|
||||
@@ -184,19 +141,19 @@ export function LowlightPlugin({
|
||||
name,
|
||||
lowlight,
|
||||
defaultLanguage,
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
return decorationSet.map(transaction.mapping, transaction.doc);
|
||||
return decorationSet.map(transaction.mapping, transaction.doc)
|
||||
},
|
||||
},
|
||||
|
||||
props: {
|
||||
decorations(state) {
|
||||
return lowlightPlugin.getState(state);
|
||||
return lowlightPlugin.getState(state)
|
||||
},
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
return lowlightPlugin;
|
||||
}
|
||||
return lowlightPlugin
|
||||
}
|
||||
Generated
+3772
-4260
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user