mirror of
https://github.com/docmost/docmost.git
synced 2026-05-09 07:43:06 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d2b8d2077a | |||
| d7d14c2acf | |||
| 6e5efc3757 | |||
| bf692e8b08 | |||
| ff01355ec3 | |||
| 78c3839ae7 | |||
| 73ed0c54e5 |
+39
-39
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.70.3",
|
"version": "0.70.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
@@ -10,76 +10,76 @@
|
|||||||
"format": "prettier --write \"src/**/*.tsx\" \"src/**/*.ts\""
|
"format": "prettier --write \"src/**/*.tsx\" \"src/**/*.ts\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@casl/react": "^5.0.1",
|
"@casl/react": "^4.0.0",
|
||||||
"@docmost/editor-ext": "workspace:*",
|
"@docmost/editor-ext": "workspace:*",
|
||||||
"@emoji-mart/data": "^1.2.1",
|
"@emoji-mart/data": "^1.2.1",
|
||||||
"@emoji-mart/react": "^1.1.1",
|
"@emoji-mart/react": "^1.1.1",
|
||||||
"@excalidraw/excalidraw": "0.18.0-3a5ef40",
|
"@excalidraw/excalidraw": "0.18.0-3a5ef40",
|
||||||
"@mantine/core": "^8.3.18",
|
"@mantine/core": "^8.3.14",
|
||||||
"@mantine/dates": "^8.3.18",
|
"@mantine/dates": "^8.3.14",
|
||||||
"@mantine/form": "^8.3.18",
|
"@mantine/form": "^8.3.14",
|
||||||
"@mantine/hooks": "^8.3.18",
|
"@mantine/hooks": "^8.3.14",
|
||||||
"@mantine/modals": "^8.3.18",
|
"@mantine/modals": "^8.3.14",
|
||||||
"@mantine/notifications": "^8.3.18",
|
"@mantine/notifications": "^8.3.14",
|
||||||
"@mantine/spotlight": "^8.3.18",
|
"@mantine/spotlight": "^8.3.14",
|
||||||
"@tabler/icons-react": "^3.40.0",
|
"@tabler/icons-react": "^3.36.1",
|
||||||
"@tanstack/react-query": "5.90.17",
|
"@tanstack/react-query": "^5.90.17",
|
||||||
"alfaaz": "^1.1.0",
|
"alfaaz": "^1.1.0",
|
||||||
"axios": "^1.13.6",
|
"axios": "^1.13.5",
|
||||||
"blueimp-load-image": "^5.16.0",
|
"blueimp-load-image": "^5.16.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"emoji-mart": "^5.6.0",
|
"emoji-mart": "^5.6.0",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"highlightjs-sap-abap": "^0.3.0",
|
"highlightjs-sap-abap": "^0.3.0",
|
||||||
"i18next": "^25.10.1",
|
"i18next": "^23.16.8",
|
||||||
"i18next-http-backend": "^3.0.2",
|
"i18next-http-backend": "^2.7.3",
|
||||||
"jotai": "^2.18.1",
|
"jotai": "^2.16.2",
|
||||||
"jotai-optics": "^0.4.0",
|
"jotai-optics": "^0.4.0",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"jwt-decode": "^4.0.0",
|
"jwt-decode": "^4.0.0",
|
||||||
"katex": "0.16.40",
|
"katex": "0.16.27",
|
||||||
"lowlight": "^3.3.0",
|
"lowlight": "^3.3.0",
|
||||||
"mantine-form-zod-resolver": "^1.3.0",
|
"mantine-form-zod-resolver": "^1.3.0",
|
||||||
"mermaid": "^11.13.0",
|
"mermaid": "^11.12.2",
|
||||||
"mitt": "^3.0.1",
|
"mitt": "^3.0.1",
|
||||||
"posthog-js": "1.363.1",
|
"posthog-js": "1.345.5",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-arborist": "3.4.0",
|
"react-arborist": "3.4.0",
|
||||||
"react-clear-modal": "^2.0.18",
|
"react-clear-modal": "^2.0.17",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-drawio": "^1.0.7",
|
"react-drawio": "^1.0.7",
|
||||||
"react-error-boundary": "^6.1.1",
|
"react-error-boundary": "^4.1.2",
|
||||||
"react-helmet-async": "^3.0.0",
|
"react-helmet-async": "^2.0.5",
|
||||||
"react-i18next": "^16.5.8",
|
"react-i18next": "^15.0.1",
|
||||||
"react-router-dom": "^7.13.1",
|
"react-router-dom": "^7.12.0",
|
||||||
"semver": "^7.7.4",
|
"semver": "^7.7.3",
|
||||||
"socket.io-client": "^4.8.3",
|
"socket.io-client": "^4.8.3",
|
||||||
"tiptap-extension-global-drag-handle": "^0.1.18",
|
"tiptap-extension-global-drag-handle": "^0.1.18",
|
||||||
"zod": "^4.3.6"
|
"zod": "^4.3.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.28.0",
|
"@eslint/js": "^9.16.0",
|
||||||
"@tanstack/eslint-plugin-query": "^5.94.4",
|
"@tanstack/eslint-plugin-query": "^5.62.1",
|
||||||
"@types/blueimp-load-image": "^5.16.6",
|
"@types/blueimp-load-image": "^5.16.0",
|
||||||
"@types/file-saver": "^2.0.7",
|
"@types/file-saver": "^2.0.7",
|
||||||
"@types/js-cookie": "^3.0.6",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"@types/katex": "^0.16.8",
|
"@types/katex": "^0.16.7",
|
||||||
"@types/node": "22.19.1",
|
"@types/node": "22.19.1",
|
||||||
"@types/react": "^18.3.12",
|
"@types/react": "^18.3.12",
|
||||||
"@types/react-dom": "^18.3.1",
|
"@types/react-dom": "^18.3.1",
|
||||||
"@vitejs/plugin-react": "^6.0.0",
|
"@vitejs/plugin-react": "^5.1.1",
|
||||||
"eslint": "^9.28.0",
|
"eslint": "^9.39.2",
|
||||||
"eslint-plugin-react": "^7.37.5",
|
"eslint-plugin-react": "^7.37.2",
|
||||||
"eslint-plugin-react-hooks": "^7.0.1",
|
"eslint-plugin-react-hooks": "^5.1.0",
|
||||||
"eslint-plugin-react-refresh": "^0.5.2",
|
"eslint-plugin-react-refresh": "^0.4.16",
|
||||||
"globals": "^15.13.0",
|
"globals": "^15.13.0",
|
||||||
"optics-ts": "^2.4.1",
|
"optics-ts": "^2.4.1",
|
||||||
"postcss": "^8.5.8",
|
"postcss": "^8.4.49",
|
||||||
"postcss-preset-mantine": "^1.18.0",
|
"postcss-preset-mantine": "^1.17.0",
|
||||||
"postcss-simple-vars": "^7.0.1",
|
"postcss-simple-vars": "^7.0.1",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.4.1",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.7.2",
|
||||||
"typescript-eslint": "^8.57.1",
|
"typescript-eslint": "^8.17.0",
|
||||||
"vite": "^8.0.1"
|
"vite": "^7.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -442,9 +442,6 @@
|
|||||||
"Prevent members from sharing pages publicly.": "Prevent members from sharing pages publicly.",
|
"Prevent members from sharing pages publicly.": "Prevent members from sharing pages publicly.",
|
||||||
"Toggle public sharing": "Toggle public sharing",
|
"Toggle public sharing": "Toggle public sharing",
|
||||||
"Toggle space public sharing": "Toggle space public sharing",
|
"Toggle space public sharing": "Toggle space public sharing",
|
||||||
"Allow viewers to comment": "Allow viewers to comment",
|
|
||||||
"Allow viewers to add comments on pages in this space.": "Allow viewers to add comments on pages in this space.",
|
|
||||||
"Toggle viewer comments": "Toggle viewer comments",
|
|
||||||
"Public sharing is disabled at the workspace level": "Public sharing is disabled at the workspace level",
|
"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.",
|
"Prevent pages in this space from being shared publicly.": "Prevent pages in this space from being shared publicly.",
|
||||||
"Page permissions": "Page permissions",
|
"Page permissions": "Page permissions",
|
||||||
@@ -711,20 +708,5 @@
|
|||||||
"Resend verification email": "Resend verification email",
|
"Resend verification email": "Resend verification email",
|
||||||
"Verification email sent. Please check your inbox.": "Verification email sent. Please check your inbox.",
|
"Verification email sent. Please check your inbox.": "Verification email sent. Please check your inbox.",
|
||||||
"Failed to resend verification email. Please try again.": "Failed to resend verification email. Please try again.",
|
"Failed to resend verification email. Please try again.": "Failed to resend verification email. Please try again.",
|
||||||
"We've sent you an email with your associated workspaces.": "We've sent you an email with your associated workspaces.",
|
"We've sent you an email with your associated workspaces.": "We've sent you an email with your associated workspaces."
|
||||||
"Load more": "Load more",
|
|
||||||
"Log out of all devices": "Log out of all devices",
|
|
||||||
"Log out of all sessions except this device": "Log out of all sessions except this device",
|
|
||||||
"This Device": "This Device",
|
|
||||||
"Unknown device": "Unknown device",
|
|
||||||
"No active sessions": "No active sessions",
|
|
||||||
"Session revoked": "Session revoked",
|
|
||||||
"All other sessions revoked": "All other sessions revoked",
|
|
||||||
"Last used": "Last used",
|
|
||||||
"Created": "Created",
|
|
||||||
"Rename": "Rename",
|
|
||||||
"Publish": "Publish",
|
|
||||||
"Security": "Security",
|
|
||||||
"Enforce SSO": "Enforce SSO",
|
|
||||||
"Once enforced, members will not be able to login with email and password.": "Once enforced, members will not be able to login with email and password."
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import { useTranslation } from "react-i18next";
|
|||||||
import JoinedWorkspaces from "@/ee/components/joined-workspaces.tsx";
|
import JoinedWorkspaces from "@/ee/components/joined-workspaces.tsx";
|
||||||
import { useJoinedWorkspacesQuery } from "@/ee/cloud/query/cloud-query.ts";
|
import { useJoinedWorkspacesQuery } from "@/ee/cloud/query/cloud-query.ts";
|
||||||
import { findWorkspacesByEmail } from "@/ee/cloud/service/cloud-service.ts";
|
import { findWorkspacesByEmail } from "@/ee/cloud/service/cloud-service.ts";
|
||||||
import { AuthLayout } from "@/features/auth/components/auth-layout.tsx";
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
hostname: z.string().min(1, { message: "subdomain is required" }),
|
hostname: z.string().min(1, { message: "subdomain is required" }),
|
||||||
@@ -83,7 +82,7 @@ export function CloudLoginForm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout>
|
<div>
|
||||||
<Container size={420} className={classes.container}>
|
<Container size={420} className={classes.container}>
|
||||||
<Box p="xl" className={classes.containerBox}>
|
<Box p="xl" className={classes.containerBox}>
|
||||||
<Title order={2} ta="center" fw={500} mb="md">
|
<Title order={2} ta="center" fw={500} mb="md">
|
||||||
@@ -146,12 +145,12 @@ export function CloudLoginForm() {
|
|||||||
</Box>
|
</Box>
|
||||||
</Container>
|
</Container>
|
||||||
|
|
||||||
<Text ta="center" mb="xl">
|
<Text ta="center">
|
||||||
{t("Don't have a workspace?")}{" "}
|
{t("Don't have a workspace?")}{" "}
|
||||||
<Anchor component={Link} to={APP_ROUTE.AUTH.CREATE_WORKSPACE} fw={500}>
|
<Anchor component={Link} to={APP_ROUTE.AUTH.CREATE_WORKSPACE} fw={500}>
|
||||||
{t("Create new workspace")}
|
{t("Create new workspace")}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
</Text>
|
</Text>
|
||||||
</AuthLayout>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,4 @@ export const Feature = {
|
|||||||
AUDIT_LOGS: 'audit:logs',
|
AUDIT_LOGS: 'audit:logs',
|
||||||
RETENTION: 'retention',
|
RETENTION: 'retention',
|
||||||
SHARING_CONTROLS: 'sharing:controls',
|
SHARING_CONTROLS: 'sharing:controls',
|
||||||
VIEWER_COMMENTS: 'comment:viewer',
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod/v4";
|
import { z } from "zod/v4";
|
||||||
import React, { useRef } from "react";
|
import React from "react";
|
||||||
import { Button, Divider, Group, Modal, Stack, Textarea } from "@mantine/core";
|
import { Button, Group, Modal, Textarea } from "@mantine/core";
|
||||||
import { useForm } from "@mantine/form";
|
import { useForm } from "@mantine/form";
|
||||||
import { zod4Resolver } from "mantine-form-zod-resolver";
|
import { zod4Resolver } from "mantine-form-zod-resolver";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -49,7 +49,6 @@ interface ActivateLicenseFormProps {
|
|||||||
export function ActivateLicenseForm({ onClose }: ActivateLicenseFormProps) {
|
export function ActivateLicenseForm({ onClose }: ActivateLicenseFormProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const activateLicenseMutation = useActivateMutation();
|
const activateLicenseMutation = useActivateMutation();
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
||||||
|
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
validate: zod4Resolver(formSchema),
|
validate: zod4Resolver(formSchema),
|
||||||
@@ -64,68 +63,29 @@ export function ActivateLicenseForm({ onClose }: ActivateLicenseFormProps) {
|
|||||||
onClose?.();
|
onClose?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFileUpload(event: React.ChangeEvent<HTMLInputElement>) {
|
|
||||||
const file = event.target.files?.[0];
|
|
||||||
if (!file) return;
|
|
||||||
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = (e) => {
|
|
||||||
const content = (e.target?.result as string)?.trim();
|
|
||||||
if (content) {
|
|
||||||
form.setFieldValue("licenseKey", content);
|
|
||||||
handleSubmit({ licenseKey: content });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
reader.readAsText(file);
|
|
||||||
|
|
||||||
if (fileInputRef.current) {
|
|
||||||
fileInputRef.current.value = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={form.onSubmit(handleSubmit)}>
|
<form onSubmit={form.onSubmit(handleSubmit)}>
|
||||||
<input
|
<Textarea
|
||||||
type="file"
|
label={t("License key")}
|
||||||
accept=".txt"
|
description="Enter a valid enterprise license key. Contact sales@docmost.com to purchase one."
|
||||||
ref={fileInputRef}
|
placeholder={t("e.g eyJhb.....")}
|
||||||
onChange={handleFileUpload}
|
variant="filled"
|
||||||
hidden
|
autosize
|
||||||
|
minRows={3}
|
||||||
|
maxRows={5}
|
||||||
|
data-autofocus
|
||||||
|
{...form.getInputProps("licenseKey")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Stack gap="xs">
|
<Group justify="flex-end" mt="md">
|
||||||
<Textarea
|
<Button
|
||||||
label={t("License key")}
|
type="submit"
|
||||||
placeholder={t("e.g eyJhb.....")}
|
disabled={activateLicenseMutation.isPending}
|
||||||
variant="filled"
|
loading={activateLicenseMutation.isPending}
|
||||||
autosize
|
>
|
||||||
minRows={3}
|
{t("Save")}
|
||||||
maxRows={5}
|
</Button>
|
||||||
data-autofocus
|
</Group>
|
||||||
{...form.getInputProps("licenseKey")}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Group justify="flex-end">
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
disabled={activateLicenseMutation.isPending}
|
|
||||||
loading={activateLicenseMutation.isPending}
|
|
||||||
>
|
|
||||||
{t("Save")}
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
|
|
||||||
<Divider label={t("Or")} labelPosition="center" />
|
|
||||||
|
|
||||||
<Group justify="center">
|
|
||||||
<Button
|
|
||||||
variant="light"
|
|
||||||
onClick={() => fileInputRef.current?.click()}
|
|
||||||
>
|
|
||||||
{t("Upload license file")}
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,11 +68,7 @@ export default function OssDetails() {
|
|||||||
</List>
|
</List>
|
||||||
|
|
||||||
<Text size="sm" c="dimmed">
|
<Text size="sm" c="dimmed">
|
||||||
Get an enterprise trial key at <a href="https://customers.docmost.com/" target="_blank" rel="noopener noreferrer">customers.docmost.com</a>.
|
Contact <a href="mailto:sales@docmost.com?subject=Enterprise%20License%20Inquiry">sales@docmost.com </a> to purchase an enterprise license.
|
||||||
</Text>
|
|
||||||
|
|
||||||
<Text size="sm" c="dimmed">
|
|
||||||
Visit <a href="https://docmost.com/pricing" target="_blank" rel="noopener noreferrer">docmost.com/pricing</a> to purchase an enterprise license.
|
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import APP_ROUTE, { getPostLoginRedirect } from "@/lib/app-route";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { z } from "zod/v4";
|
import { z } from "zod/v4";
|
||||||
import { MfaBackupCodeInput } from "./mfa-backup-code-input";
|
import { MfaBackupCodeInput } from "./mfa-backup-code-input";
|
||||||
import { AuthLayout } from "@/features/auth/components/auth-layout.tsx";
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
code: z
|
code: z
|
||||||
@@ -67,7 +66,6 @@ export function MfaChallenge() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout>
|
|
||||||
<Container size={420} className={classes.container}>
|
<Container size={420} className={classes.container}>
|
||||||
<Paper radius="lg" p={40} className={classes.paper}>
|
<Paper radius="lg" p={40} className={classes.paper}>
|
||||||
<Stack align="center" gap="xl">
|
<Stack align="center" gap="xl">
|
||||||
@@ -159,6 +157,5 @@ export function MfaChallenge() {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Container>
|
</Container>
|
||||||
</AuthLayout>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { MfaSetupModal } from "@/ee/mfa";
|
import { MfaSetupModal } from "@/ee/mfa";
|
||||||
import APP_ROUTE, { getPostLoginRedirect } from "@/lib/app-route.ts";
|
import APP_ROUTE, { getPostLoginRedirect } from "@/lib/app-route.ts";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { AuthLayout } from "@/features/auth/components/auth-layout.tsx";
|
|
||||||
|
|
||||||
export default function MfaSetupRequired() {
|
export default function MfaSetupRequired() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -16,7 +15,6 @@ export default function MfaSetupRequired() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout>
|
|
||||||
<Container size="sm" py="xl">
|
<Container size="sm" py="xl">
|
||||||
<Paper shadow="sm" p="xl" radius="md" withBorder>
|
<Paper shadow="sm" p="xl" radius="md" withBorder>
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -46,6 +44,5 @@ export default function MfaSetupRequired() {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Container>
|
</Container>
|
||||||
</AuthLayout>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
import APP_ROUTE from "@/lib/app-route.ts";
|
import APP_ROUTE from "@/lib/app-route.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { AuthLayout } from "@/features/auth/components/auth-layout.tsx";
|
|
||||||
|
|
||||||
export default function VerifyEmail() {
|
export default function VerifyEmail() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -60,23 +59,20 @@ export default function VerifyEmail() {
|
|||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
return (
|
return (
|
||||||
<AuthLayout>
|
<Container size={420} className={classes.container}>
|
||||||
<Container size={420} className={classes.container}>
|
<Box p="xl" className={classes.containerBox}>
|
||||||
<Box p="xl" className={classes.containerBox}>
|
<Title order={2} ta="center" fw={500} mb="md">
|
||||||
<Title order={2} ta="center" fw={500} mb="md">
|
{t("Verifying your email")}
|
||||||
{t("Verifying your email")}
|
</Title>
|
||||||
</Title>
|
<Text ta="center" c="dimmed">
|
||||||
<Text ta="center" c="dimmed">
|
{t("Please wait...")}
|
||||||
{t("Please wait...")}
|
</Text>
|
||||||
</Text>
|
</Box>
|
||||||
</Box>
|
</Container>
|
||||||
</Container>
|
|
||||||
</AuthLayout>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout>
|
|
||||||
<Container size={420} className={classes.container}>
|
<Container size={420} className={classes.container}>
|
||||||
<Box p="xl" className={classes.containerBox}>
|
<Box p="xl" className={classes.containerBox}>
|
||||||
<Title order={2} ta="center" fw={500} mb="md">
|
<Title order={2} ta="center" fw={500} mb="md">
|
||||||
@@ -107,6 +103,5 @@ export default function VerifyEmail() {
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Container>
|
</Container>
|
||||||
</AuthLayout>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
import { Group, Text, Switch, Tooltip } from "@mantine/core";
|
|
||||||
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 SpaceViewerCommentsToggleProps = {
|
|
||||||
space: ISpace;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function SpaceViewerCommentsToggle({
|
|
||||||
space,
|
|
||||||
}: SpaceViewerCommentsToggleProps) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const hasViewerComments = useHasFeature(Feature.VIEWER_COMMENTS);
|
|
||||||
const upgradeLabel = useUpgradeLabel();
|
|
||||||
const isDisabled = !hasViewerComments;
|
|
||||||
const [checked, setChecked] = useState(
|
|
||||||
space.settings?.comments?.allowViewerComments === true,
|
|
||||||
);
|
|
||||||
const updateSpaceMutation = useUpdateSpaceMutation();
|
|
||||||
|
|
||||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
const value = event.currentTarget.checked;
|
|
||||||
try {
|
|
||||||
await updateSpaceMutation.mutateAsync({
|
|
||||||
spaceId: space.id,
|
|
||||||
allowViewerComments: value,
|
|
||||||
});
|
|
||||||
setChecked(value);
|
|
||||||
} catch {
|
|
||||||
// error handled by mutation
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Group justify="space-between" wrap="nowrap" gap="xl">
|
|
||||||
<div>
|
|
||||||
<Text size="md">{t("Allow viewers to comment")}</Text>
|
|
||||||
<Text size="sm" c="dimmed">
|
|
||||||
{t("Allow viewers to add comments on pages in this space.")}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
<Tooltip
|
|
||||||
label={upgradeLabel}
|
|
||||||
disabled={!isDisabled}
|
|
||||||
refProp="rootRef"
|
|
||||||
>
|
|
||||||
<Switch
|
|
||||||
checked={checked}
|
|
||||||
onChange={handleChange}
|
|
||||||
disabled={isDisabled}
|
|
||||||
aria-label={t("Toggle viewer comments")}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</Group>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { Group, Text } from "@mantine/core";
|
|
||||||
import classes from "./auth.module.css";
|
|
||||||
|
|
||||||
type AuthLayoutProps = {
|
|
||||||
children: React.ReactNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function AuthLayout({ children }: AuthLayoutProps) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Group justify="center" gap={8} className={classes.logo}>
|
|
||||||
<img
|
|
||||||
src="/icons/favicon-32x32.png"
|
|
||||||
alt="Docmost"
|
|
||||||
width={22}
|
|
||||||
height={22}
|
|
||||||
/>
|
|
||||||
<Text size="28px" fw={700} style={{ userSelect: "none" }}>
|
|
||||||
Docmost
|
|
||||||
</Text>
|
|
||||||
</Group>
|
|
||||||
{children}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,20 +1,12 @@
|
|||||||
.logo {
|
|
||||||
margin-top: 80px;
|
|
||||||
|
|
||||||
@media (max-width: $mantine-breakpoint-sm) {
|
|
||||||
margin-top: 30px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
box-shadow: rgba(0, 0, 0, 0.07) 0px 2px 45px 4px;
|
box-shadow: rgba(0, 0, 0, 0.07) 0px 2px 45px 4px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background: light-dark(var(--mantine-color-body), rgba(0, 0, 0, 0.1));
|
background: light-dark(var(--mantine-color-body), rgba(0, 0, 0, 0.1));
|
||||||
margin-top: 40px;
|
margin-top: 150px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
|
|
||||||
@media (max-width: $mantine-breakpoint-sm) {
|
@media (max-width: $mantine-breakpoint-sm) {
|
||||||
margin-top: 20px;
|
margin-top: 50px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { Box, Button, Container, Text, TextInput, Title } from "@mantine/core";
|
|||||||
import classes from "./auth.module.css";
|
import classes from "./auth.module.css";
|
||||||
import { useRedirectIfAuthenticated } from "@/features/auth/hooks/use-redirect-if-authenticated.ts";
|
import { useRedirectIfAuthenticated } from "@/features/auth/hooks/use-redirect-if-authenticated.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { AuthLayout } from "./auth-layout.tsx";
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
email: z
|
email: z
|
||||||
@@ -36,7 +35,6 @@ export function ForgotPasswordForm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout>
|
|
||||||
<Container size={420} className={classes.container}>
|
<Container size={420} className={classes.container}>
|
||||||
<Box p="xl" className={classes.containerBox}>
|
<Box p="xl" className={classes.containerBox}>
|
||||||
<Title order={2} ta="center" fw={500} mb="md">
|
<Title order={2} ta="center" fw={500} mb="md">
|
||||||
@@ -71,6 +69,5 @@ export function ForgotPasswordForm() {
|
|||||||
</form>
|
</form>
|
||||||
</Box>
|
</Box>
|
||||||
</Container>
|
</Container>
|
||||||
</AuthLayout>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import { useGetInvitationQuery } from "@/features/workspace/queries/workspace-qu
|
|||||||
import { useRedirectIfAuthenticated } from "@/features/auth/hooks/use-redirect-if-authenticated.ts";
|
import { useRedirectIfAuthenticated } from "@/features/auth/hooks/use-redirect-if-authenticated.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import SsoLogin from "@/ee/components/sso-login.tsx";
|
import SsoLogin from "@/ee/components/sso-login.tsx";
|
||||||
import { AuthLayout } from "./auth-layout.tsx";
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
name: z.string().trim().min(1),
|
name: z.string().trim().min(1),
|
||||||
@@ -67,7 +66,6 @@ export function InviteSignUpForm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout>
|
|
||||||
<Container size={420} className={classes.container}>
|
<Container size={420} className={classes.container}>
|
||||||
<Box p="xl" className={classes.containerBox}>
|
<Box p="xl" className={classes.containerBox}>
|
||||||
<Title order={2} ta="center" fw={500} mb="md">
|
<Title order={2} ta="center" fw={500} mb="md">
|
||||||
@@ -113,6 +111,5 @@ export function InviteSignUpForm() {
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Container>
|
</Container>
|
||||||
</AuthLayout>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import SsoLogin from "@/ee/components/sso-login.tsx";
|
|||||||
import { useWorkspacePublicDataQuery } from "@/features/workspace/queries/workspace-query.ts";
|
import { useWorkspacePublicDataQuery } from "@/features/workspace/queries/workspace-query.ts";
|
||||||
import { Error404 } from "@/components/ui/error-404.tsx";
|
import { Error404 } from "@/components/ui/error-404.tsx";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { AuthLayout } from "./auth-layout.tsx";
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
email: z
|
email: z
|
||||||
@@ -63,54 +62,52 @@ export function LoginForm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout>
|
<Container size={420} className={classes.container}>
|
||||||
<Container size={420} className={classes.container}>
|
<Box p="xl" className={classes.containerBox}>
|
||||||
<Box p="xl" className={classes.containerBox}>
|
<Title order={2} ta="center" fw={500} mb="md">
|
||||||
<Title order={2} ta="center" fw={500} mb="md">
|
{t("Login")}
|
||||||
{t("Login")}
|
</Title>
|
||||||
</Title>
|
|
||||||
|
|
||||||
<SsoLogin />
|
<SsoLogin />
|
||||||
|
|
||||||
{!data?.enforceSso && (
|
{!data?.enforceSso && (
|
||||||
<>
|
<>
|
||||||
<form onSubmit={form.onSubmit(onSubmit)}>
|
<form onSubmit={form.onSubmit(onSubmit)}>
|
||||||
<TextInput
|
<TextInput
|
||||||
id="email"
|
id="email"
|
||||||
type="email"
|
type="email"
|
||||||
label={t("Email")}
|
label={t("Email")}
|
||||||
placeholder="email@example.com"
|
placeholder="email@example.com"
|
||||||
variant="filled"
|
variant="filled"
|
||||||
{...form.getInputProps("email")}
|
{...form.getInputProps("email")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
label={t("Password")}
|
label={t("Password")}
|
||||||
placeholder={t("Your password")}
|
placeholder={t("Your password")}
|
||||||
variant="filled"
|
variant="filled"
|
||||||
mt="md"
|
mt="md"
|
||||||
{...form.getInputProps("password")}
|
{...form.getInputProps("password")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Group justify="flex-end" mt="sm">
|
<Group justify="flex-end" mt="sm">
|
||||||
<Anchor
|
<Anchor
|
||||||
to={APP_ROUTE.AUTH.FORGOT_PASSWORD}
|
to={APP_ROUTE.AUTH.FORGOT_PASSWORD}
|
||||||
component={Link}
|
component={Link}
|
||||||
underline="never"
|
underline="never"
|
||||||
size="sm"
|
size="sm"
|
||||||
>
|
>
|
||||||
{t("Forgot your password?")}
|
{t("Forgot your password?")}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Button type="submit" fullWidth mt="md" loading={isLoading}>
|
<Button type="submit" fullWidth mt="md" loading={isLoading}>
|
||||||
{t("Sign In")}
|
{t("Sign In")}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Container>
|
</Container>
|
||||||
</AuthLayout>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { Box, Button, Container, PasswordInput, Title } from "@mantine/core";
|
|||||||
import classes from "./auth.module.css";
|
import classes from "./auth.module.css";
|
||||||
import { useRedirectIfAuthenticated } from "@/features/auth/hooks/use-redirect-if-authenticated.ts";
|
import { useRedirectIfAuthenticated } from "@/features/auth/hooks/use-redirect-if-authenticated.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { AuthLayout } from "./auth-layout.tsx";
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
newPassword: z
|
newPassword: z
|
||||||
@@ -39,7 +38,6 @@ export function PasswordResetForm({ resetToken }: PasswordResetFormProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout>
|
|
||||||
<Container size={420} className={classes.container}>
|
<Container size={420} className={classes.container}>
|
||||||
<Box p="xl" className={classes.containerBox}>
|
<Box p="xl" className={classes.containerBox}>
|
||||||
<Title order={2} ta="center" fw={500} mb="md">
|
<Title order={2} ta="center" fw={500} mb="md">
|
||||||
@@ -61,6 +59,5 @@ export function PasswordResetForm({ resetToken }: PasswordResetFormProps) {
|
|||||||
</form>
|
</form>
|
||||||
</Box>
|
</Box>
|
||||||
</Container>
|
</Container>
|
||||||
</AuthLayout>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import SsoCloudSignup from "@/ee/components/sso-cloud-signup.tsx";
|
|||||||
import { isCloud } from "@/lib/config.ts";
|
import { isCloud } from "@/lib/config.ts";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import APP_ROUTE from "@/lib/app-route.ts";
|
import APP_ROUTE from "@/lib/app-route.ts";
|
||||||
import { AuthLayout } from "./auth-layout.tsx";
|
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
workspaceName: z.string().trim().max(50).optional(),
|
workspaceName: z.string().trim().max(50).optional(),
|
||||||
@@ -51,7 +50,7 @@ export function SetupWorkspaceForm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthLayout>
|
<div>
|
||||||
<Container size={420} className={classes.container}>
|
<Container size={420} className={classes.container}>
|
||||||
<Box p="xl" className={classes.containerBox}>
|
<Box p="xl" className={classes.containerBox}>
|
||||||
<Title order={2} ta="center" fw={500} mb="md">
|
<Title order={2} ta="center" fw={500} mb="md">
|
||||||
@@ -118,6 +117,6 @@ export function SetupWorkspaceForm() {
|
|||||||
</Anchor>
|
</Anchor>
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</AuthLayout>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,3 @@ import { atom } from 'jotai';
|
|||||||
export const showCommentPopupAtom = atom<boolean>(false);
|
export const showCommentPopupAtom = atom<boolean>(false);
|
||||||
export const activeCommentIdAtom = atom<string>('');
|
export const activeCommentIdAtom = atom<string>('');
|
||||||
export const draftCommentIdAtom = atom<string>('');
|
export const draftCommentIdAtom = atom<string>('');
|
||||||
|
|
||||||
// Read-only comment state
|
|
||||||
export const showReadOnlyCommentPopupAtom = atom<boolean>(false);
|
|
||||||
export type YjsSelection = {
|
|
||||||
anchor: any;
|
|
||||||
head: any;
|
|
||||||
};
|
|
||||||
export type ReadOnlyCommentData = {
|
|
||||||
yjsSelection: YjsSelection;
|
|
||||||
selectedText: string;
|
|
||||||
};
|
|
||||||
export const readOnlyCommentDataAtom = atom<ReadOnlyCommentData | null>(null);
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import {
|
|||||||
activeCommentIdAtom,
|
activeCommentIdAtom,
|
||||||
draftCommentIdAtom,
|
draftCommentIdAtom,
|
||||||
showCommentPopupAtom,
|
showCommentPopupAtom,
|
||||||
showReadOnlyCommentPopupAtom,
|
|
||||||
readOnlyCommentDataAtom,
|
|
||||||
} from "@/features/comment/atoms/comment-atom";
|
} from "@/features/comment/atoms/comment-atom";
|
||||||
import CommentEditor from "@/features/comment/components/comment-editor";
|
import CommentEditor from "@/features/comment/components/comment-editor";
|
||||||
import CommentActions from "@/features/comment/components/comment-actions";
|
import CommentActions from "@/features/comment/components/comment-actions";
|
||||||
@@ -21,15 +19,12 @@ import { useTranslation } from "react-i18next";
|
|||||||
interface CommentDialogProps {
|
interface CommentDialogProps {
|
||||||
editor: ReturnType<typeof useEditor>;
|
editor: ReturnType<typeof useEditor>;
|
||||||
pageId: string;
|
pageId: string;
|
||||||
readOnly?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CommentDialog({ editor, pageId, readOnly }: CommentDialogProps) {
|
function CommentDialog({ editor, pageId }: CommentDialogProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [comment, setComment] = useState("");
|
const [comment, setComment] = useState("");
|
||||||
const [, setShowCommentPopup] = useAtom(showCommentPopupAtom);
|
const [, setShowCommentPopup] = useAtom(showCommentPopupAtom);
|
||||||
const [, setShowReadOnlyCommentPopup] = useAtom(showReadOnlyCommentPopupAtom);
|
|
||||||
const [readOnlyCommentData, setReadOnlyCommentData] = useAtom(readOnlyCommentDataAtom);
|
|
||||||
const [, setActiveCommentId] = useAtom(activeCommentIdAtom);
|
const [, setActiveCommentId] = useAtom(activeCommentIdAtom);
|
||||||
const [draftCommentId, setDraftCommentId] = useAtom(draftCommentIdAtom);
|
const [draftCommentId, setDraftCommentId] = useAtom(draftCommentIdAtom);
|
||||||
const [currentUser] = useAtom(currentUserAtom);
|
const [currentUser] = useAtom(currentUserAtom);
|
||||||
@@ -39,17 +34,11 @@ function CommentDialog({ editor, pageId, readOnly }: CommentDialogProps) {
|
|||||||
handleDialogClose();
|
handleDialogClose();
|
||||||
});
|
});
|
||||||
const createCommentMutation = useCreateCommentMutation();
|
const createCommentMutation = useCreateCommentMutation();
|
||||||
const isPending = createCommentMutation.isPending;
|
const { isPending } = createCommentMutation;
|
||||||
|
|
||||||
const handleDialogClose = () => {
|
const handleDialogClose = () => {
|
||||||
if (readOnly) {
|
setShowCommentPopup(false);
|
||||||
setShowReadOnlyCommentPopup(false);
|
editor.chain().focus().unsetCommentDecoration().run();
|
||||||
// @ts-ignore
|
|
||||||
setReadOnlyCommentData(null);
|
|
||||||
} else {
|
|
||||||
setShowCommentPopup(false);
|
|
||||||
editor.chain().focus().unsetCommentDecoration().run();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSelectedText = () => {
|
const getSelectedText = () => {
|
||||||
@@ -58,11 +47,6 @@ function CommentDialog({ editor, pageId, readOnly }: CommentDialogProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleAddComment = async () => {
|
const handleAddComment = async () => {
|
||||||
if (readOnly) {
|
|
||||||
await handleAddReadOnlyComment();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const selectedText = getSelectedText();
|
const selectedText = getSelectedText();
|
||||||
const commentData = {
|
const commentData = {
|
||||||
@@ -81,6 +65,7 @@ function CommentDialog({ editor, pageId, readOnly }: CommentDialogProps) {
|
|||||||
.run();
|
.run();
|
||||||
setActiveCommentId(createdComment.id);
|
setActiveCommentId(createdComment.id);
|
||||||
|
|
||||||
|
//unselect text to close bubble menu
|
||||||
editor.commands.setTextSelection({ from: editor.view.state.selection.from, to: editor.view.state.selection.from });
|
editor.commands.setTextSelection({ from: editor.view.state.selection.from, to: editor.view.state.selection.from });
|
||||||
|
|
||||||
setAsideState({ tab: "comments", isAsideOpen: true });
|
setAsideState({ tab: "comments", isAsideOpen: true });
|
||||||
@@ -100,33 +85,6 @@ function CommentDialog({ editor, pageId, readOnly }: CommentDialogProps) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddReadOnlyComment = async () => {
|
|
||||||
if (!readOnlyCommentData) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const createdComment = await createCommentMutation.mutateAsync({
|
|
||||||
pageId,
|
|
||||||
content: JSON.stringify(comment),
|
|
||||||
selection: readOnlyCommentData.selectedText,
|
|
||||||
type: "inline",
|
|
||||||
yjsSelection: readOnlyCommentData.yjsSelection,
|
|
||||||
});
|
|
||||||
|
|
||||||
setActiveCommentId(createdComment.id);
|
|
||||||
setAsideState({ tab: "comments", isAsideOpen: true });
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
const selector = `div[data-comment-id="${createdComment.id}"]`;
|
|
||||||
const commentElement = document.querySelector(selector);
|
|
||||||
commentElement?.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
||||||
}, 400);
|
|
||||||
} finally {
|
|
||||||
setShowReadOnlyCommentPopup(false);
|
|
||||||
// @ts-ignore
|
|
||||||
setReadOnlyCommentData(null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCommentEditorChange = (newContent: any) => {
|
const handleCommentEditorChange = (newContent: any) => {
|
||||||
setComment(newContent);
|
setComment(newContent);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,9 +44,7 @@ function CommentListWithTabs() {
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { data: space } = useGetSpaceBySlugQuery(page?.space?.slug);
|
const { data: space } = useGetSpaceBySlugQuery(page?.space?.slug);
|
||||||
|
|
||||||
const canComment =
|
const canComment = page?.permissions?.canEdit ?? false;
|
||||||
(page?.permissions?.canEdit ?? false) ||
|
|
||||||
(space?.settings?.comments?.allowViewerComments === true);
|
|
||||||
|
|
||||||
// Separate active and resolved comments
|
// Separate active and resolved comments
|
||||||
const { activeComments, resolvedComments } = useMemo(() => {
|
const { activeComments, resolvedComments } = useMemo(() => {
|
||||||
@@ -155,7 +153,7 @@ function CommentListWithTabs() {
|
|||||||
)}
|
)}
|
||||||
</Paper>
|
</Paper>
|
||||||
),
|
),
|
||||||
[comments, handleAddReply, isLoading, space?.membership?.role, canComment],
|
[comments, handleAddReply, isLoading, space?.membership?.role],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isCommentsLoading) {
|
if (isCommentsLoading) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ function CommentMenu({
|
|||||||
{isResolved ? t("Re-open comment") : t("Resolve comment")}
|
{isResolved ? t("Re-open comment") : t("Resolve comment")}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
) : (
|
) : (
|
||||||
<Tooltip label={upgradeLabel} position="left" withPortal={false}>
|
<Tooltip label={upgradeLabel} position="left">
|
||||||
<Menu.Item disabled leftSection={<IconCircleCheck size={14} />}>
|
<Menu.Item disabled leftSection={<IconCircleCheck size={14} />}>
|
||||||
{t("Resolve comment")}
|
{t("Resolve comment")}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ export interface IComment {
|
|||||||
deletedAt?: Date;
|
deletedAt?: Date;
|
||||||
creator: IUser;
|
creator: IUser;
|
||||||
resolvedBy?: IUser;
|
resolvedBy?: IUser;
|
||||||
yjsSelection?: {
|
|
||||||
anchor: any;
|
|
||||||
head: any;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICommentData {
|
export interface ICommentData {
|
||||||
|
|||||||
@@ -10,5 +10,3 @@ export const readOnlyEditorAtom = atom<Editor | null>(null);
|
|||||||
export const yjsConnectionStatusAtom = atom<string>("");
|
export const yjsConnectionStatusAtom = atom<string>("");
|
||||||
|
|
||||||
export const showAiMenuAtom = atom(false);
|
export const showAiMenuAtom = atom(false);
|
||||||
|
|
||||||
export const showLinkMenuAtom = atom(false);
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import { v7 as uuid7 } from "uuid";
|
|||||||
import { isCellSelection, isTextSelected } from "@docmost/editor-ext";
|
import { isCellSelection, isTextSelected } from "@docmost/editor-ext";
|
||||||
import { LinkSelector } from "@/features/editor/components/bubble-menu/link-selector.tsx";
|
import { LinkSelector } from "@/features/editor/components/bubble-menu/link-selector.tsx";
|
||||||
import { useTranslation } from "react-i18next";
|
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";
|
import { workspaceAtom } from "@/features/user/atoms/current-user-atom";
|
||||||
|
|
||||||
export interface BubbleMenuItem {
|
export interface BubbleMenuItem {
|
||||||
@@ -49,8 +49,6 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
const [, setDraftCommentId] = useAtom(draftCommentIdAtom);
|
const [, setDraftCommentId] = useAtom(draftCommentIdAtom);
|
||||||
const showCommentPopupRef = useRef(showCommentPopup);
|
const showCommentPopupRef = useRef(showCommentPopup);
|
||||||
const showAiMenuRef = useRef(showAiMenu);
|
const showAiMenuRef = useRef(showAiMenu);
|
||||||
const [showLinkMenu] = useAtom(showLinkMenuAtom);
|
|
||||||
const showLinkMenuRef = useRef(showLinkMenu);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
showCommentPopupRef.current = showCommentPopup;
|
showCommentPopupRef.current = showCommentPopup;
|
||||||
@@ -60,10 +58,6 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
showAiMenuRef.current = showAiMenu;
|
showAiMenuRef.current = showAiMenu;
|
||||||
}, [showAiMenu]);
|
}, [showAiMenu]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
showLinkMenuRef.current = showLinkMenu;
|
|
||||||
}, [showLinkMenu]);
|
|
||||||
|
|
||||||
const editorState = useEditorState({
|
const editorState = useEditorState({
|
||||||
editor: props.editor,
|
editor: props.editor,
|
||||||
selector: (ctx) => {
|
selector: (ctx) => {
|
||||||
@@ -141,7 +135,6 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
isNodeSelection(selection) ||
|
isNodeSelection(selection) ||
|
||||||
isCellSelection(selection) ||
|
isCellSelection(selection) ||
|
||||||
showAiMenuRef.current ||
|
showAiMenuRef.current ||
|
||||||
showLinkMenuRef.current ||
|
|
||||||
showCommentPopupRef?.current
|
showCommentPopupRef?.current
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
@@ -154,6 +147,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
onHide: () => {
|
onHide: () => {
|
||||||
setIsNodeSelectorOpen(false);
|
setIsNodeSelectorOpen(false);
|
||||||
setIsTextAlignmentOpen(false);
|
setIsTextAlignmentOpen(false);
|
||||||
|
setIsLinkSelectorOpen(false);
|
||||||
setIsColorSelectorOpen(false);
|
setIsColorSelectorOpen(false);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -161,10 +155,11 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
|
|
||||||
const [isNodeSelectorOpen, setIsNodeSelectorOpen] = useState(false);
|
const [isNodeSelectorOpen, setIsNodeSelectorOpen] = useState(false);
|
||||||
const [isTextAlignmentSelectorOpen, setIsTextAlignmentOpen] = useState(false);
|
const [isTextAlignmentSelectorOpen, setIsTextAlignmentOpen] = useState(false);
|
||||||
|
const [isLinkSelectorOpen, setIsLinkSelectorOpen] = useState(false);
|
||||||
const [isColorSelectorOpen, setIsColorSelectorOpen] = useState(false);
|
const [isColorSelectorOpen, setIsColorSelectorOpen] = useState(false);
|
||||||
|
|
||||||
// Hide the bubble menu immediately when AI menu is shown
|
// Hide the bubble menu immediately when AI menu is shown
|
||||||
if (showAiMenu || showLinkMenu) return;
|
if (showAiMenu) return;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BubbleMenu
|
<BubbleMenu
|
||||||
@@ -194,6 +189,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
setIsOpen={() => {
|
setIsOpen={() => {
|
||||||
setIsNodeSelectorOpen(!isNodeSelectorOpen);
|
setIsNodeSelectorOpen(!isNodeSelectorOpen);
|
||||||
setIsTextAlignmentOpen(false);
|
setIsTextAlignmentOpen(false);
|
||||||
|
setIsLinkSelectorOpen(false);
|
||||||
setIsColorSelectorOpen(false);
|
setIsColorSelectorOpen(false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -204,6 +200,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
setIsOpen={() => {
|
setIsOpen={() => {
|
||||||
setIsTextAlignmentOpen(!isTextAlignmentSelectorOpen);
|
setIsTextAlignmentOpen(!isTextAlignmentSelectorOpen);
|
||||||
setIsNodeSelectorOpen(false);
|
setIsNodeSelectorOpen(false);
|
||||||
|
setIsLinkSelectorOpen(false);
|
||||||
setIsColorSelectorOpen(false);
|
setIsColorSelectorOpen(false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -227,7 +224,16 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
))}
|
))}
|
||||||
</ActionIcon.Group>
|
</ActionIcon.Group>
|
||||||
|
|
||||||
<LinkSelector />
|
<LinkSelector
|
||||||
|
editor={props.editor}
|
||||||
|
isOpen={isLinkSelectorOpen}
|
||||||
|
setIsOpen={(value) => {
|
||||||
|
setIsLinkSelectorOpen(value);
|
||||||
|
setIsNodeSelectorOpen(false);
|
||||||
|
setIsTextAlignmentOpen(false);
|
||||||
|
setIsColorSelectorOpen(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<ColorSelector
|
<ColorSelector
|
||||||
editor={props.editor}
|
editor={props.editor}
|
||||||
@@ -236,6 +242,7 @@ export const EditorBubbleMenu: FC<EditorBubbleMenuProps> = (props) => {
|
|||||||
setIsColorSelectorOpen(!isColorSelectorOpen);
|
setIsColorSelectorOpen(!isColorSelectorOpen);
|
||||||
setIsNodeSelectorOpen(false);
|
setIsNodeSelectorOpen(false);
|
||||||
setIsTextAlignmentOpen(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 { IconLink } from "@tabler/icons-react";
|
||||||
import { ActionIcon, Tooltip } from "@mantine/core";
|
import { ActionIcon, Popover, Tooltip } from "@mantine/core";
|
||||||
import { useSetAtom } from "jotai";
|
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 { 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 { 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 (
|
return (
|
||||||
<Tooltip label={t("Add link")} withArrow>
|
<Popover
|
||||||
<ActionIcon
|
width={320}
|
||||||
variant="default"
|
opened={isOpen}
|
||||||
size="lg"
|
trapFocus
|
||||||
radius="0"
|
offset={{ mainAxis: 35, crossAxis: 0 }}
|
||||||
style={{ border: "none" }}
|
withArrow
|
||||||
onClick={() => setShowLinkMenu(true)}
|
shadow="md"
|
||||||
>
|
>
|
||||||
<IconLink size={16} />
|
<Popover.Target>
|
||||||
</ActionIcon>
|
<Tooltip label={t("Add link")} withArrow>
|
||||||
</Tooltip>
|
<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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,159 +0,0 @@
|
|||||||
import type { Editor } from "@tiptap/react";
|
|
||||||
import { TextSelection } from "@tiptap/pm/state";
|
|
||||||
import { FC, useCallback, useEffect, useRef, useState } from "react";
|
|
||||||
import { IconMessage } from "@tabler/icons-react";
|
|
||||||
import classes from "./bubble-menu.module.css";
|
|
||||||
import { ActionIcon, Tooltip } from "@mantine/core";
|
|
||||||
import { useAtom } from "jotai";
|
|
||||||
import {
|
|
||||||
showReadOnlyCommentPopupAtom,
|
|
||||||
readOnlyCommentDataAtom,
|
|
||||||
} from "@/features/comment/atoms/comment-atom";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { getRelativeSelection, ySyncPluginKey } from "@tiptap/y-tiptap";
|
|
||||||
|
|
||||||
type ReadonlyBubbleMenuProps = {
|
|
||||||
editor: Editor;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ReadonlyBubbleMenu: FC<ReadonlyBubbleMenuProps> = ({ editor }) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const [showReadOnlyCommentPopup, setShowReadOnlyCommentPopup] = useAtom(
|
|
||||||
showReadOnlyCommentPopupAtom,
|
|
||||||
);
|
|
||||||
const [, setReadOnlyCommentData] = useAtom(readOnlyCommentDataAtom);
|
|
||||||
const menuRef = useRef<HTMLDivElement>(null);
|
|
||||||
const [visible, setVisible] = useState(false);
|
|
||||||
const [position, setPosition] = useState({ top: 0, left: 0 });
|
|
||||||
const isInteractingRef = useRef(false);
|
|
||||||
|
|
||||||
const updateMenuPosition = useCallback(() => {
|
|
||||||
if (isInteractingRef.current) return;
|
|
||||||
|
|
||||||
const pmSelection = editor.state.selection;
|
|
||||||
if (!(pmSelection instanceof TextSelection) || pmSelection.empty) {
|
|
||||||
setVisible(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const selection = window.getSelection();
|
|
||||||
if (
|
|
||||||
!selection ||
|
|
||||||
selection.isCollapsed ||
|
|
||||||
selection.rangeCount === 0 ||
|
|
||||||
showReadOnlyCommentPopup
|
|
||||||
) {
|
|
||||||
setVisible(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const editorDom = editor.view.dom;
|
|
||||||
if (
|
|
||||||
!editorDom.contains(selection.anchorNode) ||
|
|
||||||
!editorDom.contains(selection.focusNode)
|
|
||||||
) {
|
|
||||||
setVisible(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const range = selection.getRangeAt(0);
|
|
||||||
const rect = range.getBoundingClientRect();
|
|
||||||
|
|
||||||
if (rect.width === 0) {
|
|
||||||
setVisible(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const editorRect = editorDom
|
|
||||||
.closest(".editor-container")
|
|
||||||
?.getBoundingClientRect();
|
|
||||||
if (!editorRect) {
|
|
||||||
setVisible(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPosition({
|
|
||||||
top: rect.top - editorRect.top - 44,
|
|
||||||
left: rect.left - editorRect.left + rect.width / 2,
|
|
||||||
});
|
|
||||||
setVisible(true);
|
|
||||||
}, [editor, showReadOnlyCommentPopup]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handleSelectionChange = () => {
|
|
||||||
updateMenuPosition();
|
|
||||||
};
|
|
||||||
|
|
||||||
document.addEventListener("selectionchange", handleSelectionChange);
|
|
||||||
return () => {
|
|
||||||
document.removeEventListener("selectionchange", handleSelectionChange);
|
|
||||||
};
|
|
||||||
}, [updateMenuPosition]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (showReadOnlyCommentPopup) {
|
|
||||||
setVisible(false);
|
|
||||||
}
|
|
||||||
}, [showReadOnlyCommentPopup]);
|
|
||||||
|
|
||||||
const handleCommentClick = () => {
|
|
||||||
if (!editor) return;
|
|
||||||
|
|
||||||
const view = editor.view;
|
|
||||||
const ystate = ySyncPluginKey.getState(view.state);
|
|
||||||
|
|
||||||
if (ystate?.binding) {
|
|
||||||
const selection = getRelativeSelection(ystate.binding, view.state);
|
|
||||||
const { from, to } = editor.state.selection;
|
|
||||||
const selectedText = editor.state.doc.textBetween(from, to);
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
setReadOnlyCommentData({
|
|
||||||
yjsSelection: {
|
|
||||||
anchor: selection.anchor,
|
|
||||||
head: selection.head,
|
|
||||||
},
|
|
||||||
selectedText,
|
|
||||||
});
|
|
||||||
|
|
||||||
setShowReadOnlyCommentPopup(true);
|
|
||||||
setVisible(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!visible) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
ref={menuRef}
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
top: position.top,
|
|
||||||
left: position.left,
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
zIndex: 199,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className={classes.bubbleMenu}>
|
|
||||||
<Tooltip label={t("Comment")} withArrow withinPortal={false}>
|
|
||||||
<ActionIcon
|
|
||||||
variant="default"
|
|
||||||
size="lg"
|
|
||||||
radius="6px"
|
|
||||||
aria-label={t("Comment")}
|
|
||||||
style={{ border: "none" }}
|
|
||||||
onMouseDown={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
isInteractingRef.current = true;
|
|
||||||
handleCommentClick();
|
|
||||||
isInteractingRef.current = false;
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<IconMessage size={16} stroke={2} />
|
|
||||||
</ActionIcon>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
} from "@/features/editor/components/table/types/types.ts";
|
} from "@/features/editor/components/table/types/types.ts";
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
LoadingOverlay,
|
|
||||||
Modal,
|
Modal,
|
||||||
Text,
|
Text,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
@@ -47,8 +46,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
|||||||
const computedColorScheme = useComputedColorScheme();
|
const computedColorScheme = useComputedColorScheme();
|
||||||
const isDirtyRef = useRef(false);
|
const isDirtyRef = useRef(false);
|
||||||
const isSavingRef = useRef(false);
|
const isSavingRef = useRef(false);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
|
|
||||||
const editorState = useEditorState({
|
const editorState = useEditorState({
|
||||||
editor,
|
editor,
|
||||||
@@ -143,7 +140,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
|||||||
if (isSavingRef.current) return;
|
if (isSavingRef.current) return;
|
||||||
|
|
||||||
isSavingRef.current = true;
|
isSavingRef.current = true;
|
||||||
setIsSaving(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const svgString = decodeBase64ToSvgString(svgXml);
|
const svgString = decodeBase64ToSvgString(svgXml);
|
||||||
@@ -171,7 +167,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
|||||||
isDirtyRef.current = false;
|
isDirtyRef.current = false;
|
||||||
} finally {
|
} finally {
|
||||||
isSavingRef.current = false;
|
isSavingRef.current = false;
|
||||||
setIsSaving(false);
|
|
||||||
}
|
}
|
||||||
}, [editor, editorState?.attachmentId]);
|
}, [editor, editorState?.attachmentId]);
|
||||||
|
|
||||||
@@ -201,7 +196,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
|||||||
const handleOpen = useCallback(async () => {
|
const handleOpen = useCallback(async () => {
|
||||||
if (!editorState?.src) return;
|
if (!editorState?.src) return;
|
||||||
|
|
||||||
setIsLoading(true);
|
|
||||||
try {
|
try {
|
||||||
const url = getFileUrl(editorState.src);
|
const url = getFileUrl(editorState.src);
|
||||||
const request = await fetch(url, {
|
const request = await fetch(url, {
|
||||||
@@ -219,7 +213,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
|
||||||
isDirtyRef.current = false;
|
isDirtyRef.current = false;
|
||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
@@ -314,7 +307,6 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
|||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Edit")}
|
aria-label={t("Edit")}
|
||||||
variant="subtle"
|
variant="subtle"
|
||||||
loading={isLoading}
|
|
||||||
>
|
>
|
||||||
<IconEdit size={18} />
|
<IconEdit size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -347,8 +339,7 @@ export function DrawioMenu({ editor }: EditorMenuProps) {
|
|||||||
<Modal.Root opened={opened} onClose={handleClose} fullScreen closeOnEscape={false}>
|
<Modal.Root opened={opened} onClose={handleClose} fullScreen closeOnEscape={false}>
|
||||||
<Modal.Overlay />
|
<Modal.Overlay />
|
||||||
<Modal.Content style={{ overflow: "hidden" }}>
|
<Modal.Content style={{ overflow: "hidden" }}>
|
||||||
<Modal.Body pos="relative">
|
<Modal.Body>
|
||||||
<LoadingOverlay visible={isSaving} />
|
|
||||||
<div style={{ height: "100vh" }}>
|
<div style={{ height: "100vh" }}>
|
||||||
<DrawIoEmbed
|
<DrawIoEmbed
|
||||||
ref={drawioRef}
|
ref={drawioRef}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { NodeViewProps, NodeViewWrapper } from "@tiptap/react";
|
|||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
Card,
|
Card,
|
||||||
LoadingOverlay,
|
|
||||||
Modal,
|
Modal,
|
||||||
Text,
|
Text,
|
||||||
useComputedColorScheme,
|
useComputedColorScheme,
|
||||||
@@ -35,7 +34,6 @@ export default function DrawioView(props: NodeViewProps) {
|
|||||||
const computedColorScheme = useComputedColorScheme();
|
const computedColorScheme = useComputedColorScheme();
|
||||||
const isDirtyRef = useRef(false);
|
const isDirtyRef = useRef(false);
|
||||||
const isSavingRef = useRef(false);
|
const isSavingRef = useRef(false);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
|
||||||
|
|
||||||
const handleOpen = async () => {
|
const handleOpen = async () => {
|
||||||
if (!editor.isEditable) {
|
if (!editor.isEditable) {
|
||||||
@@ -49,7 +47,6 @@ export default function DrawioView(props: NodeViewProps) {
|
|||||||
if (isSavingRef.current) return;
|
if (isSavingRef.current) return;
|
||||||
|
|
||||||
isSavingRef.current = true;
|
isSavingRef.current = true;
|
||||||
setIsSaving(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const svgString = decodeBase64ToSvgString(svgXml);
|
const svgString = decodeBase64ToSvgString(svgXml);
|
||||||
@@ -82,7 +79,6 @@ export default function DrawioView(props: NodeViewProps) {
|
|||||||
isDirtyRef.current = false;
|
isDirtyRef.current = false;
|
||||||
} finally {
|
} finally {
|
||||||
isSavingRef.current = false;
|
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.Root opened={opened} onClose={handleClose} fullScreen closeOnEscape={false}>
|
||||||
<Modal.Overlay />
|
<Modal.Overlay />
|
||||||
<Modal.Content style={{ overflow: "hidden" }}>
|
<Modal.Content style={{ overflow: "hidden" }}>
|
||||||
<Modal.Body pos="relative">
|
<Modal.Body>
|
||||||
<LoadingOverlay visible={isSaving} />
|
|
||||||
<div style={{ height: "100vh" }}>
|
<div style={{ height: "100vh" }}>
|
||||||
<DrawIoEmbed
|
<DrawIoEmbed
|
||||||
ref={drawioRef}
|
ref={drawioRef}
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
const computedColorScheme = useComputedColorScheme();
|
const computedColorScheme = useComputedColorScheme();
|
||||||
const isDirtyRef = useRef(false);
|
const isDirtyRef = useRef(false);
|
||||||
const isSavingRef = useRef(false);
|
const isSavingRef = useRef(false);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
const isInitialLoadRef = useRef(true);
|
const isInitialLoadRef = useRef(true);
|
||||||
const lastFingerprintRef = useRef("");
|
const lastFingerprintRef = useRef("");
|
||||||
|
|
||||||
@@ -155,7 +153,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
const handleOpen = useCallback(async () => {
|
const handleOpen = useCallback(async () => {
|
||||||
if (!editorState?.src) return;
|
if (!editorState?.src) return;
|
||||||
|
|
||||||
setIsLoading(true);
|
|
||||||
try {
|
try {
|
||||||
const url = getFileUrl(editorState.src);
|
const url = getFileUrl(editorState.src);
|
||||||
const request = await fetch(url, {
|
const request = await fetch(url, {
|
||||||
@@ -169,7 +166,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
|
||||||
isDirtyRef.current = false;
|
isDirtyRef.current = false;
|
||||||
isInitialLoadRef.current = true;
|
isInitialLoadRef.current = true;
|
||||||
open();
|
open();
|
||||||
@@ -182,7 +178,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isSavingRef.current = true;
|
isSavingRef.current = true;
|
||||||
setIsSaving(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { exportToSvg } = await import("@excalidraw/excalidraw");
|
const { exportToSvg } = await import("@excalidraw/excalidraw");
|
||||||
@@ -228,7 +223,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
isDirtyRef.current = false;
|
isDirtyRef.current = false;
|
||||||
} finally {
|
} finally {
|
||||||
isSavingRef.current = false;
|
isSavingRef.current = false;
|
||||||
setIsSaving(false);
|
|
||||||
}
|
}
|
||||||
}, [editor, excalidrawAPI, editorState?.attachmentId]);
|
}, [editor, excalidrawAPI, editorState?.attachmentId]);
|
||||||
|
|
||||||
@@ -345,7 +339,6 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
size="lg"
|
size="lg"
|
||||||
aria-label={t("Edit")}
|
aria-label={t("Edit")}
|
||||||
variant="subtle"
|
variant="subtle"
|
||||||
loading={isLoading}
|
|
||||||
>
|
>
|
||||||
<IconEdit size={18} />
|
<IconEdit size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
@@ -397,7 +390,7 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) {
|
|||||||
bg="var(--mantine-color-body)"
|
bg="var(--mantine-color-body)"
|
||||||
p="xs"
|
p="xs"
|
||||||
>
|
>
|
||||||
<Button onClick={handleSaveAndExit} size={"compact-sm"} loading={isSaving}>
|
<Button onClick={handleSaveAndExit} size={"compact-sm"}>
|
||||||
{t("Save & Exit")}
|
{t("Save & Exit")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handleClose} color="red" size={"compact-sm"}>
|
<Button onClick={handleClose} color="red" size={"compact-sm"}>
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
|||||||
|
|
||||||
const isDirtyRef = useRef(false);
|
const isDirtyRef = useRef(false);
|
||||||
const isSavingRef = useRef(false);
|
const isSavingRef = useRef(false);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
|
||||||
const isInitialLoadRef = useRef(true);
|
const isInitialLoadRef = useRef(true);
|
||||||
const lastFingerprintRef = useRef("");
|
const lastFingerprintRef = useRef("");
|
||||||
|
|
||||||
@@ -71,7 +70,6 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isSavingRef.current = true;
|
isSavingRef.current = true;
|
||||||
setIsSaving(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { exportToSvg } = await import("@excalidraw/excalidraw");
|
const { exportToSvg } = await import("@excalidraw/excalidraw");
|
||||||
@@ -122,7 +120,6 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
|||||||
isDirtyRef.current = false;
|
isDirtyRef.current = false;
|
||||||
} finally {
|
} finally {
|
||||||
isSavingRef.current = false;
|
isSavingRef.current = false;
|
||||||
setIsSaving(false);
|
|
||||||
}
|
}
|
||||||
}, [excalidrawAPI, editor, attachmentId, updateAttributes]);
|
}, [excalidrawAPI, editor, attachmentId, updateAttributes]);
|
||||||
|
|
||||||
@@ -194,7 +191,7 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
|||||||
bg="var(--mantine-color-body)"
|
bg="var(--mantine-color-body)"
|
||||||
p="xs"
|
p="xs"
|
||||||
>
|
>
|
||||||
<Button onClick={handleSaveAndExit} size={"compact-sm"} loading={isSaving}>
|
<Button onClick={handleSaveAndExit} size={"compact-sm"}>
|
||||||
{t("Save & Exit")}
|
{t("Save & Exit")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handleClose} color="red" size={"compact-sm"}>
|
<Button onClick={handleClose} color="red" size={"compact-sm"}>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export const LinkEditorPanel = ({
|
|||||||
includeUsers: false,
|
includeUsers: false,
|
||||||
includePages: true,
|
includePages: true,
|
||||||
spaceId: space?.id,
|
spaceId: space?.id,
|
||||||
limit: state.isSearchQuery ? 10 : 3,
|
limit: state.isSearchQuery ? 10 : 5,
|
||||||
preload: true,
|
preload: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -105,7 +105,6 @@ export const LinkEditorPanel = ({
|
|||||||
value={state.url}
|
value={state.url}
|
||||||
onChange={state.onChange}
|
onChange={state.onChange}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
data-autofocus
|
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
</form>
|
</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 { buildSharedPageUrl } from "@/features/page/page.utils.ts";
|
||||||
import { extractPageSlugId } from "@/lib";
|
import { extractPageSlugId } from "@/lib";
|
||||||
import { sanitizeUrl, copyToClipboard } from "@docmost/editor-ext";
|
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 = (
|
const parseInternalLink = (
|
||||||
href: string,
|
href: string,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ export interface FullEditorProps {
|
|||||||
content: string;
|
content: string;
|
||||||
spaceSlug: string;
|
spaceSlug: string;
|
||||||
editable: boolean;
|
editable: boolean;
|
||||||
canComment?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FullEditor({
|
export function FullEditor({
|
||||||
@@ -26,7 +25,6 @@ export function FullEditor({
|
|||||||
content,
|
content,
|
||||||
spaceSlug,
|
spaceSlug,
|
||||||
editable,
|
editable,
|
||||||
canComment,
|
|
||||||
}: FullEditorProps) {
|
}: FullEditorProps) {
|
||||||
const [user] = useAtom(userAtom);
|
const [user] = useAtom(userAtom);
|
||||||
const fullPageWidth = user.settings?.preferences?.fullPageWidth;
|
const fullPageWidth = user.settings?.preferences?.fullPageWidth;
|
||||||
@@ -48,7 +46,6 @@ export function FullEditor({
|
|||||||
pageId={pageId}
|
pageId={pageId}
|
||||||
editable={editable}
|
editable={editable}
|
||||||
content={content}
|
content={content}
|
||||||
canComment={canComment}
|
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -37,11 +37,9 @@ import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-
|
|||||||
import {
|
import {
|
||||||
activeCommentIdAtom,
|
activeCommentIdAtom,
|
||||||
showCommentPopupAtom,
|
showCommentPopupAtom,
|
||||||
showReadOnlyCommentPopupAtom,
|
|
||||||
} from "@/features/comment/atoms/comment-atom";
|
} from "@/features/comment/atoms/comment-atom";
|
||||||
import CommentDialog from "@/features/comment/components/comment-dialog";
|
import CommentDialog from "@/features/comment/components/comment-dialog";
|
||||||
import { EditorBubbleMenu } from "@/features/editor/components/bubble-menu/bubble-menu";
|
import { EditorBubbleMenu } from "@/features/editor/components/bubble-menu/bubble-menu";
|
||||||
import { ReadonlyBubbleMenu } from "@/features/editor/components/bubble-menu/readonly-bubble-menu";
|
|
||||||
import TableCellMenu from "@/features/editor/components/table/table-cell-menu.tsx";
|
import TableCellMenu from "@/features/editor/components/table/table-cell-menu.tsx";
|
||||||
import TableMenu from "@/features/editor/components/table/table-menu.tsx";
|
import TableMenu from "@/features/editor/components/table/table-menu.tsx";
|
||||||
import ImageMenu from "@/features/editor/components/image/image-menu.tsx";
|
import ImageMenu from "@/features/editor/components/image/image-menu.tsx";
|
||||||
@@ -68,21 +66,18 @@ import { jwtDecode } from "jwt-decode";
|
|||||||
import { searchSpotlight } from "@/features/search/constants.ts";
|
import { searchSpotlight } from "@/features/search/constants.ts";
|
||||||
import { useEditorScroll } from "./hooks/use-editor-scroll";
|
import { useEditorScroll } from "./hooks/use-editor-scroll";
|
||||||
import { EditorAiMenu } from "@/ee/ai/components/editor/ai-menu/ai-menu";
|
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";
|
import ColumnsMenu from "@/features/editor/components/columns/columns-menu.tsx";
|
||||||
|
|
||||||
interface PageEditorProps {
|
interface PageEditorProps {
|
||||||
pageId: string;
|
pageId: string;
|
||||||
editable: boolean;
|
editable: boolean;
|
||||||
content: any;
|
content: any;
|
||||||
canComment?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PageEditor({
|
export default function PageEditor({
|
||||||
pageId,
|
pageId,
|
||||||
editable,
|
editable,
|
||||||
content,
|
content,
|
||||||
canComment,
|
|
||||||
}: PageEditorProps) {
|
}: PageEditorProps) {
|
||||||
const collaborationURL = useCollaborationUrl();
|
const collaborationURL = useCollaborationUrl();
|
||||||
const isComponentMounted = useRef(false);
|
const isComponentMounted = useRef(false);
|
||||||
@@ -97,7 +92,6 @@ export default function PageEditor({
|
|||||||
const [, setAsideState] = useAtom(asideStateAtom);
|
const [, setAsideState] = useAtom(asideStateAtom);
|
||||||
const [, setActiveCommentId] = useAtom(activeCommentIdAtom);
|
const [, setActiveCommentId] = useAtom(activeCommentIdAtom);
|
||||||
const [showCommentPopup, setShowCommentPopup] = useAtom(showCommentPopupAtom);
|
const [showCommentPopup, setShowCommentPopup] = useAtom(showCommentPopupAtom);
|
||||||
const [showReadOnlyCommentPopup] = useAtom(showReadOnlyCommentPopupAtom);
|
|
||||||
const [isLocalSynced, setIsLocalSynced] = useState(false);
|
const [isLocalSynced, setIsLocalSynced] = useState(false);
|
||||||
const [isRemoteSynced, setIsRemoteSynced] = useState(false);
|
const [isRemoteSynced, setIsRemoteSynced] = useState(false);
|
||||||
const [yjsConnectionStatus, setYjsConnectionStatus] = useAtom(
|
const [yjsConnectionStatus, setYjsConnectionStatus] = useAtom(
|
||||||
@@ -413,7 +407,6 @@ export default function PageEditor({
|
|||||||
{editor && editorIsEditable && (
|
{editor && editorIsEditable && (
|
||||||
<div>
|
<div>
|
||||||
<EditorAiMenu editor={editor} />
|
<EditorAiMenu editor={editor} />
|
||||||
<EditorLinkMenu editor={editor} />
|
|
||||||
<EditorBubbleMenu editor={editor} />
|
<EditorBubbleMenu editor={editor} />
|
||||||
<TableMenu editor={editor} />
|
<TableMenu editor={editor} />
|
||||||
<TableCellMenu editor={editor} appendTo={menuContainerRef} />
|
<TableCellMenu editor={editor} appendTo={menuContainerRef} />
|
||||||
@@ -426,13 +419,7 @@ export default function PageEditor({
|
|||||||
<ColumnsMenu editor={editor} />
|
<ColumnsMenu editor={editor} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{editor && !editorIsEditable && (editable || canComment) && providersRef.current && (
|
|
||||||
<ReadonlyBubbleMenu editor={editor} />
|
|
||||||
)}
|
|
||||||
{showCommentPopup && <CommentDialog editor={editor} pageId={pageId} />}
|
{showCommentPopup && <CommentDialog editor={editor} pageId={pageId} />}
|
||||||
{showReadOnlyCommentPopup && (
|
|
||||||
<CommentDialog editor={editor} pageId={pageId} readOnly />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
onClick={() => editor.commands.focus("end")}
|
onClick={() => editor.commands.focus("end")}
|
||||||
|
|||||||
@@ -110,7 +110,15 @@ export function useUpdatePageMutation() {
|
|||||||
return useMutation<IPage, Error, Partial<IPageInput>>({
|
return useMutation<IPage, Error, Partial<IPageInput>>({
|
||||||
mutationFn: (data) => updatePage(data),
|
mutationFn: (data) => updatePage(data),
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
updatePageData(data);
|
updatePage(data);
|
||||||
|
|
||||||
|
invalidateOnUpdatePage(
|
||||||
|
data.spaceId,
|
||||||
|
data.parentPageId,
|
||||||
|
data.id,
|
||||||
|
data.title,
|
||||||
|
data.icon,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,165 +0,0 @@
|
|||||||
import { useState } from "react";
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Divider,
|
|
||||||
Group,
|
|
||||||
Skeleton,
|
|
||||||
Stack,
|
|
||||||
Table,
|
|
||||||
Text,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconDevices } from "@tabler/icons-react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import {
|
|
||||||
useGetSessionsQuery,
|
|
||||||
useRevokeSessionMutation,
|
|
||||||
useRevokeAllSessionsMutation,
|
|
||||||
} from "@/features/session/queries/session-query";
|
|
||||||
import { formattedDate } from "@/lib/time";
|
|
||||||
|
|
||||||
const PAGE_SIZE = 5;
|
|
||||||
|
|
||||||
export default function SessionList() {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const { data: sessions, isLoading } = useGetSessionsQuery();
|
|
||||||
const revokeSessionMutation = useRevokeSessionMutation();
|
|
||||||
const revokeAllSessionsMutation = useRevokeAllSessionsMutation();
|
|
||||||
const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
|
|
||||||
|
|
||||||
const otherSessions = sessions?.filter((s) => !s?.isCurrentDevice) ?? [];
|
|
||||||
const visibleSessions = sessions?.slice(0, visibleCount) ?? [];
|
|
||||||
const hasMore = sessions && visibleCount < sessions.length;
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return (
|
|
||||||
<Table verticalSpacing="md">
|
|
||||||
<Table.Thead>
|
|
||||||
<Table.Tr>
|
|
||||||
<Table.Th>{t("Device Name")}</Table.Th>
|
|
||||||
<Table.Th>{t("Last Active")}</Table.Th>
|
|
||||||
<Table.Th />
|
|
||||||
</Table.Tr>
|
|
||||||
</Table.Thead>
|
|
||||||
<Table.Tbody>
|
|
||||||
{[1, 2, 3].map((i) => (
|
|
||||||
<Table.Tr key={i}>
|
|
||||||
<Table.Td>
|
|
||||||
<Group gap="xs">
|
|
||||||
<Skeleton height={18} width={18} radius="sm" />
|
|
||||||
<Skeleton height={14} width={140} radius="xs" />
|
|
||||||
</Group>
|
|
||||||
</Table.Td>
|
|
||||||
<Table.Td>
|
|
||||||
<Skeleton height={14} width={120} radius="xs" />
|
|
||||||
</Table.Td>
|
|
||||||
<Table.Td>
|
|
||||||
<Skeleton height={30} width={70} radius="sm" />
|
|
||||||
</Table.Td>
|
|
||||||
</Table.Tr>
|
|
||||||
))}
|
|
||||||
</Table.Tbody>
|
|
||||||
</Table>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack>
|
|
||||||
{otherSessions.length > 0 && (
|
|
||||||
<>
|
|
||||||
<div>
|
|
||||||
<Text fw={500}>{t("Log out of all devices")}</Text>
|
|
||||||
<Group justify="space-between" align="center" mt={4}>
|
|
||||||
<Text size="sm" c="dimmed">
|
|
||||||
{t(
|
|
||||||
"Log out of all sessions except this device",
|
|
||||||
)}
|
|
||||||
</Text>
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
color="red"
|
|
||||||
size="xs"
|
|
||||||
loading={revokeAllSessionsMutation.isPending}
|
|
||||||
onClick={() => revokeAllSessionsMutation.mutate()}
|
|
||||||
>
|
|
||||||
{t("Log out of all devices")}
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
</div>
|
|
||||||
<Divider />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Table verticalSpacing="md">
|
|
||||||
<Table.Thead>
|
|
||||||
<Table.Tr>
|
|
||||||
<Table.Th>{t("Device Name")}</Table.Th>
|
|
||||||
<Table.Th>{t("Last Active")}</Table.Th>
|
|
||||||
{otherSessions.length > 0 && <Table.Th />}
|
|
||||||
</Table.Tr>
|
|
||||||
</Table.Thead>
|
|
||||||
<Table.Tbody>
|
|
||||||
{visibleSessions.map((session) => (
|
|
||||||
<Table.Tr key={session.id}>
|
|
||||||
<Table.Td>
|
|
||||||
<Group gap="xs">
|
|
||||||
<IconDevices size={18} stroke={1.5} />
|
|
||||||
<div>
|
|
||||||
<Text size="sm">
|
|
||||||
{session.deviceName || t("Unknown device")}
|
|
||||||
</Text>
|
|
||||||
{session?.isCurrentDevice && (
|
|
||||||
<Text size="xs" c="blue">
|
|
||||||
{t("This Device")}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</Group>
|
|
||||||
</Table.Td>
|
|
||||||
<Table.Td>
|
|
||||||
<Text size="sm">
|
|
||||||
{session?.isCurrentDevice
|
|
||||||
? t("Now")
|
|
||||||
: formattedDate(new Date(session.lastActiveAt))}
|
|
||||||
</Text>
|
|
||||||
</Table.Td>
|
|
||||||
{otherSessions.length > 0 && (
|
|
||||||
<Table.Td>
|
|
||||||
{!session?.isCurrentDevice && (
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
size="xs"
|
|
||||||
loading={revokeSessionMutation.isPending}
|
|
||||||
onClick={() =>
|
|
||||||
revokeSessionMutation.mutate({
|
|
||||||
sessionId: session.id,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t("Log out")}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</Table.Td>
|
|
||||||
)}
|
|
||||||
</Table.Tr>
|
|
||||||
))}
|
|
||||||
</Table.Tbody>
|
|
||||||
</Table>
|
|
||||||
|
|
||||||
{hasMore && (
|
|
||||||
<Button
|
|
||||||
variant="subtle"
|
|
||||||
size="xs"
|
|
||||||
onClick={() => setVisibleCount((c) => c + PAGE_SIZE)}
|
|
||||||
>
|
|
||||||
{t("Load more")}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{(!sessions || sessions.length === 0) && (
|
|
||||||
<Text size="sm" c="dimmed" ta="center">
|
|
||||||
{t("No active sessions")}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
import {
|
|
||||||
useMutation,
|
|
||||||
useQuery,
|
|
||||||
useQueryClient,
|
|
||||||
UseQueryResult,
|
|
||||||
} from "@tanstack/react-query";
|
|
||||||
import {
|
|
||||||
getSessions,
|
|
||||||
revokeSession,
|
|
||||||
revokeAllSessions,
|
|
||||||
} from "@/features/session/services/session-service";
|
|
||||||
import { ISession } from "@/features/session/types/session.types";
|
|
||||||
import { notifications } from "@mantine/notifications";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
export function useGetSessionsQuery(): UseQueryResult<ISession[], Error> {
|
|
||||||
return useQuery({
|
|
||||||
queryKey: ["session-list"],
|
|
||||||
queryFn: () => getSessions(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useRevokeSessionMutation() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return useMutation<void, Error, { sessionId: string }>({
|
|
||||||
mutationFn: (data) => revokeSession(data),
|
|
||||||
onSuccess: () => {
|
|
||||||
notifications.show({ message: t("Session revoked") });
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["session-list"] });
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
const errorMessage = error["response"]?.data?.message;
|
|
||||||
notifications.show({ message: errorMessage, color: "red" });
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useRevokeAllSessionsMutation() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return useMutation<void, Error, void>({
|
|
||||||
mutationFn: () => revokeAllSessions(),
|
|
||||||
onSuccess: () => {
|
|
||||||
notifications.show({ message: t("All other sessions revoked") });
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["session-list"] });
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
const errorMessage = error["response"]?.data?.message;
|
|
||||||
notifications.show({ message: errorMessage, color: "red" });
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import api from "@/lib/api-client";
|
|
||||||
import { ISession } from "@/features/session/types/session.types";
|
|
||||||
|
|
||||||
export async function getSessions(): Promise<ISession[]> {
|
|
||||||
const req = await api.post<{ sessions: ISession[] }>("/sessions");
|
|
||||||
return req.data.sessions;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function revokeSession(data: {
|
|
||||||
sessionId: string;
|
|
||||||
}): Promise<void> {
|
|
||||||
await api.post("/sessions/revoke", data);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function revokeAllSessions(): Promise<void> {
|
|
||||||
await api.post("/sessions/revoke-all");
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
export type ISession = {
|
|
||||||
id: string;
|
|
||||||
deviceName: string | null;
|
|
||||||
geoLocation: string | null;
|
|
||||||
lastActiveAt: string;
|
|
||||||
createdAt: string;
|
|
||||||
isCurrentDevice?: boolean;
|
|
||||||
};
|
|
||||||
@@ -3,7 +3,6 @@ import SpaceMembersList from "@/features/space/components/space-members.tsx";
|
|||||||
import AddSpaceMembersModal from "@/features/space/components/add-space-members-modal.tsx";
|
import AddSpaceMembersModal from "@/features/space/components/add-space-members-modal.tsx";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import SpaceDetails from "@/features/space/components/space-details.tsx";
|
import SpaceDetails from "@/features/space/components/space-details.tsx";
|
||||||
import SpaceSecuritySettings from "@/features/space/components/space-security-settings.tsx";
|
|
||||||
import { useSpaceQuery } from "@/features/space/queries/space-query.ts";
|
import { useSpaceQuery } from "@/features/space/queries/space-query.ts";
|
||||||
import { useSpaceAbility } from "@/features/space/permissions/use-space-ability.ts";
|
import { useSpaceAbility } from "@/features/space/permissions/use-space-ability.ts";
|
||||||
import {
|
import {
|
||||||
@@ -60,14 +59,6 @@ export default function SpaceSettingsModal({
|
|||||||
<Tabs.Tab fw={500} value="members">
|
<Tabs.Tab fw={500} value="members">
|
||||||
{t("Members")}
|
{t("Members")}
|
||||||
</Tabs.Tab>
|
</Tabs.Tab>
|
||||||
{spaceAbility.can(
|
|
||||||
SpaceCaslAction.Manage,
|
|
||||||
SpaceCaslSubject.Settings,
|
|
||||||
) && (
|
|
||||||
<Tabs.Tab fw={500} value="security">
|
|
||||||
{t("Security")}
|
|
||||||
</Tabs.Tab>
|
|
||||||
)}
|
|
||||||
</Tabs.List>
|
</Tabs.List>
|
||||||
|
|
||||||
<Tabs.Panel value="general">
|
<Tabs.Panel value="general">
|
||||||
@@ -100,20 +91,6 @@ export default function SpaceSettingsModal({
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
|
|
||||||
<Tabs.Panel value="security">
|
|
||||||
<ScrollArea h={580} scrollbarSize={5} pr={8}>
|
|
||||||
<div style={{ paddingBottom: "100px" }}>
|
|
||||||
<SpaceSecuritySettings
|
|
||||||
space={space}
|
|
||||||
readOnly={spaceAbility.cannot(
|
|
||||||
SpaceCaslAction.Manage,
|
|
||||||
SpaceCaslSubject.Settings,
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</ScrollArea>
|
|
||||||
</Tabs.Panel>
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
ResponsiveSettingsControl,
|
ResponsiveSettingsControl,
|
||||||
ResponsiveSettingsRow,
|
ResponsiveSettingsRow,
|
||||||
} from "@/components/ui/responsive-settings-row.tsx";
|
} from "@/components/ui/responsive-settings-row.tsx";
|
||||||
|
import SpacePublicSharingToggle from "@/ee/security/components/space-public-sharing-toggle.tsx";
|
||||||
|
|
||||||
interface SpaceDetailsProps {
|
interface SpaceDetailsProps {
|
||||||
spaceId: string;
|
spaceId: string;
|
||||||
@@ -27,6 +27,7 @@ interface SpaceDetailsProps {
|
|||||||
export default function SpaceDetails({ spaceId, readOnly }: SpaceDetailsProps) {
|
export default function SpaceDetails({ spaceId, readOnly }: SpaceDetailsProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { data: space, isLoading, refetch } = useSpaceQuery(spaceId);
|
const { data: space, isLoading, refetch } = useSpaceQuery(spaceId);
|
||||||
|
const showSharingToggle = !readOnly;
|
||||||
const [exportOpened, { open: openExportModal, close: closeExportModal }] =
|
const [exportOpened, { open: openExportModal, close: closeExportModal }] =
|
||||||
useDisclosure(false);
|
useDisclosure(false);
|
||||||
const [isIconUploading, setIsIconUploading] = useState(false);
|
const [isIconUploading, setIsIconUploading] = useState(false);
|
||||||
@@ -88,6 +89,13 @@ export default function SpaceDetails({ spaceId, readOnly }: SpaceDetailsProps) {
|
|||||||
|
|
||||||
<EditSpaceForm space={space} readOnly={readOnly} />
|
<EditSpaceForm space={space} readOnly={readOnly} />
|
||||||
|
|
||||||
|
{showSharingToggle && (
|
||||||
|
<>
|
||||||
|
<Divider my="lg" />
|
||||||
|
<SpacePublicSharingToggle space={space} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{!readOnly && (
|
{!readOnly && (
|
||||||
<>
|
<>
|
||||||
<Divider my="lg" />
|
<Divider my="lg" />
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
import { Text, Divider } from "@mantine/core";
|
|
||||||
import React from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { ISpace } from "@/features/space/types/space.types.ts";
|
|
||||||
import SpacePublicSharingToggle from "@/ee/security/components/space-public-sharing-toggle.tsx";
|
|
||||||
import SpaceViewerCommentsToggle from "@/ee/security/components/space-viewer-comments-toggle.tsx";
|
|
||||||
|
|
||||||
type SpaceSecuritySettingsProps = {
|
|
||||||
space: ISpace;
|
|
||||||
readOnly?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function SpaceSecuritySettings({
|
|
||||||
space,
|
|
||||||
readOnly,
|
|
||||||
}: SpaceSecuritySettingsProps) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
if (readOnly) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Text my="md" fw={600}>
|
|
||||||
{t("Security")}
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<SpacePublicSharingToggle space={space} />
|
|
||||||
|
|
||||||
<Divider my="lg" />
|
|
||||||
|
|
||||||
<SpaceViewerCommentsToggle space={space} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -9,13 +9,8 @@ export interface ISpaceSharingSettings {
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISpaceCommentsSettings {
|
|
||||||
allowViewerComments?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ISpaceSettings {
|
export interface ISpaceSettings {
|
||||||
sharing?: ISpaceSharingSettings;
|
sharing?: ISpaceSharingSettings;
|
||||||
comments?: ISpaceCommentsSettings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISpace {
|
export interface ISpace {
|
||||||
@@ -34,7 +29,6 @@ export interface ISpace {
|
|||||||
settings?: ISpaceSettings;
|
settings?: ISpaceSettings;
|
||||||
// for updates
|
// for updates
|
||||||
disablePublicSharing?: boolean;
|
disablePublicSharing?: boolean;
|
||||||
allowViewerComments?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IMembership {
|
interface IMembership {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
|
import { focusAtom } from "jotai-optics";
|
||||||
import { z } from "zod/v4";
|
import { z } from "zod/v4";
|
||||||
import { useForm } from "@mantine/form";
|
import { useForm } from "@mantine/form";
|
||||||
import { zod4Resolver } from "mantine-form-zod-resolver";
|
import { zod4Resolver } from "mantine-form-zod-resolver";
|
||||||
import { userAtom } from "@/features/user/atoms/current-user-atom.ts";
|
import { currentUserAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||||
import { updateUser } from "@/features/user/services/user-service.ts";
|
import { updateUser } from "@/features/user/services/user-service.ts";
|
||||||
import { IUser } from "@/features/user/types/user.types.ts";
|
import { IUser } from "@/features/user/types/user.types.ts";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -16,15 +17,18 @@ const formSchema = z.object({
|
|||||||
|
|
||||||
type FormValues = z.infer<typeof formSchema>;
|
type FormValues = z.infer<typeof formSchema>;
|
||||||
|
|
||||||
|
const userAtom = focusAtom(currentUserAtom, (optic) => optic.prop("user"));
|
||||||
|
|
||||||
export default function AccountNameForm() {
|
export default function AccountNameForm() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [user, setUser] = useAtom(userAtom);
|
const [currentUser] = useAtom(currentUserAtom);
|
||||||
|
const [, setUser] = useAtom(userAtom);
|
||||||
|
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
validate: zod4Resolver(formSchema),
|
validate: zod4Resolver(formSchema),
|
||||||
initialValues: {
|
initialValues: {
|
||||||
name: user?.name,
|
name: currentUser?.user.name,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -74,12 +74,8 @@ function redirectToLogin() {
|
|||||||
];
|
];
|
||||||
if (!exemptPaths.some((path) => window.location.pathname.startsWith(path))) {
|
if (!exemptPaths.some((path) => window.location.pathname.startsWith(path))) {
|
||||||
const redirectTo = window.location.pathname;
|
const redirectTo = window.location.pathname;
|
||||||
if (redirectTo === APP_ROUTE.HOME) {
|
const params = new URLSearchParams({ redirect: redirectTo });
|
||||||
window.location.href = APP_ROUTE.AUTH.LOGIN;
|
window.location.href = `${APP_ROUTE.AUTH.LOGIN}?${params.toString()}`;
|
||||||
} else {
|
|
||||||
const params = new URLSearchParams({ redirect: redirectTo });
|
|
||||||
window.location.href = `${APP_ROUTE.AUTH.LOGIN}?${params.toString()}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import bytes from "bytes";
|
import bytes from "bytes";
|
||||||
import { castToBoolean } from "@/lib/utils.tsx";
|
import { castToBoolean } from "@/lib/utils.tsx";
|
||||||
import { AvatarIconType } from "@/features/attachments/types/attachment.types.ts";
|
import { AvatarIconType } from "@/features/attachments/types/attachment.types.ts";
|
||||||
import { sanitizeUrl } from "@docmost/editor-ext";
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
@@ -67,7 +66,7 @@ export function getFileUrl(src: string) {
|
|||||||
if (src.startsWith("/files/")) {
|
if (src.startsWith("/files/")) {
|
||||||
return getBackendUrl() + src;
|
return getBackendUrl() + src;
|
||||||
}
|
}
|
||||||
return sanitizeUrl(src);
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFileUploadSizeLimit() {
|
export function getFileUploadSizeLimit() {
|
||||||
|
|||||||
@@ -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 {
|
export function castToBoolean(value: unknown): boolean {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -53,9 +53,6 @@ function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
|||||||
const { data: space } = useGetSpaceBySlugQuery(page?.space?.slug);
|
const { data: space } = useGetSpaceBySlugQuery(page?.space?.slug);
|
||||||
|
|
||||||
const canEdit = page?.permissions?.canEdit ?? false;
|
const canEdit = page?.permissions?.canEdit ?? false;
|
||||||
const canComment =
|
|
||||||
canEdit ||
|
|
||||||
(space?.settings?.comments?.allowViewerComments === true);
|
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <></>;
|
return <></>;
|
||||||
@@ -107,7 +104,6 @@ function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
|||||||
slugId={page.slugId}
|
slugId={page.slugId}
|
||||||
spaceSlug={page?.space?.slug}
|
spaceSlug={page?.space?.slug}
|
||||||
editable={canEdit}
|
editable={canEdit}
|
||||||
canComment={canComment}
|
|
||||||
/>
|
/>
|
||||||
<MemoizedHistoryModal pageId={page.id} />
|
<MemoizedHistoryModal pageId={page.id} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { getAppName } from "@/lib/config.ts";
|
|||||||
import { Helmet } from "react-helmet-async";
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { AccountMfaSection } from "@/features/user/components/account-mfa-section";
|
import { AccountMfaSection } from "@/features/user/components/account-mfa-section";
|
||||||
import SessionList from "@/features/session/components/session-list";
|
|
||||||
|
|
||||||
export default function AccountSettings() {
|
export default function AccountSettings() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -37,10 +36,6 @@ export default function AccountSettings() {
|
|||||||
<Divider my="lg" />
|
<Divider my="lg" />
|
||||||
|
|
||||||
<AccountMfaSection />
|
<AccountMfaSection />
|
||||||
|
|
||||||
<Divider my="lg" />
|
|
||||||
|
|
||||||
<SessionList />
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { defineConfig, loadEnv } from "vite";
|
|||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
const envPath = path.resolve(process.cwd(), "..", "..");
|
export const envPath = path.resolve(process.cwd(), "..", "..");
|
||||||
|
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
const {
|
const {
|
||||||
@@ -35,20 +35,6 @@ export default defineConfig(({ mode }) => {
|
|||||||
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
||||||
},
|
},
|
||||||
plugins: [react()],
|
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: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"@": "/src",
|
"@": "/src",
|
||||||
|
|||||||
+55
-56
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"version": "0.70.3",
|
"version": "0.70.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "",
|
"author": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -30,124 +30,123 @@
|
|||||||
"test:e2e": "jest --config test/jest-e2e.json"
|
"test:e2e": "jest --config test/jest-e2e.json"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ai-sdk/google": "^3.0.52",
|
"@ai-sdk/google": "^3.0.29",
|
||||||
"@ai-sdk/openai": "^3.0.47",
|
"@ai-sdk/openai": "^3.0.29",
|
||||||
"@ai-sdk/openai-compatible": "^2.0.37",
|
"@ai-sdk/openai-compatible": "^2.0.30",
|
||||||
"@aws-sdk/client-s3": "3.1014.0",
|
"@aws-sdk/client-s3": "3.1000.0",
|
||||||
"@aws-sdk/lib-storage": "3.1014.0",
|
"@aws-sdk/lib-storage": "3.1000.0",
|
||||||
"@aws-sdk/s3-request-presigner": "3.1014.0",
|
"@aws-sdk/s3-request-presigner": "3.1000.0",
|
||||||
"@clickhouse/client": "^1.18.2",
|
"@clickhouse/client": "^1.17.0",
|
||||||
"@fastify/cookie": "^11.0.2",
|
"@fastify/cookie": "^11.0.2",
|
||||||
"@fastify/multipart": "^9.4.0",
|
"@fastify/multipart": "^9.4.0",
|
||||||
"@fastify/static": "^9.0.0",
|
"@fastify/static": "^9.0.0",
|
||||||
"@keyv/redis": "^5.1.6",
|
"@keyv/redis": "^5.1.6",
|
||||||
"@langchain/core": "1.1.34",
|
"@langchain/core": "1.1.29",
|
||||||
"@langchain/textsplitters": "1.0.1",
|
"@langchain/textsplitters": "1.0.1",
|
||||||
"@modelcontextprotocol/sdk": "^1.27.1",
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
||||||
"@nestjs-labs/nestjs-ioredis": "^11.0.4",
|
"@nestjs-labs/nestjs-ioredis": "^11.0.4",
|
||||||
"@nestjs/bullmq": "^11.0.4",
|
"@nestjs/bullmq": "^11.0.4",
|
||||||
"@nestjs/cache-manager": "^3.1.0",
|
"@nestjs/cache-manager": "^3.1.0",
|
||||||
"@nestjs/common": "^11.1.17",
|
"@nestjs/common": "^11.1.14",
|
||||||
"@nestjs/config": "^4.0.3",
|
"@nestjs/config": "^4.0.3",
|
||||||
"@nestjs/core": "^11.1.17",
|
"@nestjs/core": "^11.1.14",
|
||||||
"@nestjs/event-emitter": "^3.0.1",
|
"@nestjs/event-emitter": "^3.0.1",
|
||||||
"@nestjs/jwt": "11.0.2",
|
"@nestjs/jwt": "11.0.0",
|
||||||
"@nestjs/mapped-types": "^2.1.0",
|
"@nestjs/mapped-types": "^2.1.0",
|
||||||
"@nestjs/passport": "^11.0.5",
|
"@nestjs/passport": "^11.0.5",
|
||||||
"@nestjs/platform-fastify": "^11.1.17",
|
"@nestjs/platform-fastify": "^11.1.14",
|
||||||
"@nestjs/platform-socket.io": "^11.1.17",
|
"@nestjs/platform-socket.io": "^11.1.14",
|
||||||
"@nestjs/schedule": "^6.1.1",
|
"@nestjs/schedule": "^6.1.1",
|
||||||
"@nestjs/terminus": "^11.1.1",
|
"@nestjs/terminus": "^11.1.1",
|
||||||
"@nestjs/websockets": "^11.1.17",
|
"@nestjs/websockets": "^11.1.14",
|
||||||
"@node-saml/passport-saml": "^5.1.0",
|
"@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",
|
"@react-email/render": "2.0.4",
|
||||||
"@socket.io/redis-adapter": "^8.3.0",
|
"@socket.io/redis-adapter": "^8.3.0",
|
||||||
"ai": "^6.0.134",
|
"ai": "^6.0.86",
|
||||||
"ai-sdk-ollama": "^3.8.1",
|
"ai-sdk-ollama": "^3.7.0",
|
||||||
"bcrypt": "^6.0.0",
|
"bcrypt": "^6.0.0",
|
||||||
"bowser": "^2.14.1",
|
"bullmq": "^5.70.1",
|
||||||
"bullmq": "^5.71.0",
|
|
||||||
"cache-manager": "^7.2.8",
|
"cache-manager": "^7.2.8",
|
||||||
"cheerio": "^1.2.0",
|
"cheerio": "^1.2.0",
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
"class-validator": "^0.15.1",
|
"class-validator": "^0.15.1",
|
||||||
"cookie": "^1.1.1",
|
"cookie": "^1.1.1",
|
||||||
"fs-extra": "^11.3.4",
|
"fs-extra": "^11.3.3",
|
||||||
"happy-dom": "20.8.4",
|
"happy-dom": "20.1.0",
|
||||||
"ioredis": "^5.10.1",
|
"ioredis": "^5.4.1",
|
||||||
"jsonwebtoken": "^9.0.3",
|
"jsonwebtoken": "^9.0.3",
|
||||||
"kysely": "^0.28.14",
|
"kysely": "^0.28.2",
|
||||||
"kysely-migration-cli": "^0.4.2",
|
"kysely-migration-cli": "^0.4.2",
|
||||||
"kysely-postgres-js": "^3.0.0",
|
"kysely-postgres-js": "^3.0.0",
|
||||||
"ldapts": "^8.1.7",
|
"ldapts": "^7.4.0",
|
||||||
"lib0": "^0.2.117",
|
"lib0": "^0.2.117",
|
||||||
"mammoth": "^1.12.0",
|
"mammoth": "^1.11.0",
|
||||||
"mime-types": "^3.0.2",
|
"mime-types": "^2.1.35",
|
||||||
"msgpackr": "^1.11.9",
|
"msgpackr": "^1.11.8",
|
||||||
"nanoid": "5.1.7",
|
"nanoid": "3.3.11",
|
||||||
"nestjs-cls": "^6.2.0",
|
"nestjs-cls": "^6.2.0",
|
||||||
"nestjs-kysely": "^3.1.2",
|
"nestjs-kysely": "^1.2.0",
|
||||||
"nestjs-pino": "^4.6.1",
|
"nestjs-pino": "^4.5.0",
|
||||||
"nodemailer": "^8.0.3",
|
"nodemailer": "^7.0.12",
|
||||||
"openid-client": "^6.8.2",
|
"openid-client": "^5.7.1",
|
||||||
"otpauth": "^9.5.0",
|
"otpauth": "^9.4.1",
|
||||||
"p-limit": "^7.3.0",
|
"p-limit": "^6.2.0",
|
||||||
"passport-google-oauth20": "^2.0.0",
|
"passport-google-oauth20": "^2.0.0",
|
||||||
"passport-jwt": "^4.0.1",
|
"passport-jwt": "^4.0.1",
|
||||||
"pdfjs-dist": "^5.5.207",
|
"pdfjs-dist": "^5.4.394",
|
||||||
"pg-tsquery": "^8.4.2",
|
"pg-tsquery": "^8.4.2",
|
||||||
"pgvector": "^0.2.1",
|
"pgvector": "^0.2.1",
|
||||||
"pino-http": "^11.0.0",
|
"pino-http": "^11.0.0",
|
||||||
"pino-pretty": "^13.1.3",
|
"pino-pretty": "^13.1.3",
|
||||||
"postgres": "^3.4.8",
|
"postgres": "^3.4.8",
|
||||||
"postmark": "^4.0.7",
|
"postmark": "^4.0.5",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"reflect-metadata": "^0.2.2",
|
"reflect-metadata": "^0.2.2",
|
||||||
"rxjs": "^7.8.2",
|
"rxjs": "^7.8.2",
|
||||||
"sanitize-filename-ts": "1.0.2",
|
"sanitize-filename-ts": "1.0.2",
|
||||||
"socket.io": "^4.8.3",
|
"socket.io": "^4.8.3",
|
||||||
"stripe": "^17.7.0",
|
"stripe": "^17.5.0",
|
||||||
"tlds": "^1.261.0",
|
"tlds": "^1.261.0",
|
||||||
"tmp-promise": "^3.0.3",
|
"tmp-promise": "^3.0.3",
|
||||||
"tseep": "^1.3.1",
|
"tseep": "^1.3.1",
|
||||||
"typesense": "^3.0.3",
|
"typesense": "^2.1.0",
|
||||||
"ws": "^8.19.0",
|
"ws": "^8.19.0",
|
||||||
"yauzl": "^3.2.1",
|
"yauzl": "^3.2.0",
|
||||||
"zod": "^4.3.6"
|
"zod": "^4.3.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.28.0",
|
"@eslint/js": "^9.20.0",
|
||||||
"@nestjs/cli": "^11.0.16",
|
"@nestjs/cli": "^11.0.16",
|
||||||
"@nestjs/schematics": "^11.0.9",
|
"@nestjs/schematics": "^11.0.1",
|
||||||
"@nestjs/testing": "^11.1.17",
|
"@nestjs/testing": "^11.0.10",
|
||||||
"@types/bcrypt": "^6.0.0",
|
"@types/bcrypt": "^5.0.2",
|
||||||
"@types/debounce": "^1.2.4",
|
"@types/debounce": "^1.2.4",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/jest": "^30.0.0",
|
"@types/jest": "^30.0.0",
|
||||||
"@types/mime-types": "^3.0.1",
|
"@types/mime-types": "^2.1.4",
|
||||||
"@types/node": "^25.5.0",
|
"@types/node": "^22.13.4",
|
||||||
"@types/nodemailer": "^7.0.11",
|
"@types/nodemailer": "^6.4.17",
|
||||||
"@types/passport-google-oauth20": "^2.0.17",
|
"@types/passport-google-oauth20": "^2.0.16",
|
||||||
"@types/passport-jwt": "^4.0.1",
|
"@types/passport-jwt": "^4.0.1",
|
||||||
"@types/supertest": "^6.0.3",
|
"@types/supertest": "^6.0.3",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"@types/yauzl": "^2.10.3",
|
"@types/yauzl": "^2.10.3",
|
||||||
"eslint": "^9.28.0",
|
"eslint": "^9.39.2",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.0.1",
|
||||||
"globals": "^17.4.0",
|
"globals": "^15.15.0",
|
||||||
"jest": "^30.3.0",
|
"jest": "^30.2.0",
|
||||||
"kysely-codegen": "^0.20.0",
|
"kysely-codegen": "^0.20.0",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.5.1",
|
||||||
"react-email": "5.2.10",
|
"react-email": "5.2.8",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"supertest": "^7.2.2",
|
"supertest": "^7.2.2",
|
||||||
"ts-jest": "^29.4.6",
|
"ts-jest": "^29.4.6",
|
||||||
"ts-loader": "^9.5.4",
|
"ts-loader": "^9.5.4",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"tsconfig-paths": "^4.2.0",
|
"tsconfig-paths": "^4.2.0",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.7.3",
|
||||||
"typescript-eslint": "^8.57.1"
|
"typescript-eslint": "^8.24.1"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"moduleFileExtensions": [
|
"moduleFileExtensions": [
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ export class CollaborationGateway {
|
|||||||
|
|
||||||
// Forward close events
|
// Forward close events
|
||||||
client.on('close', (code: number, reason: Buffer) => {
|
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
|
// Forward pong events for keepalive
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
prosemirrorNodeToYElement,
|
prosemirrorNodeToYElement,
|
||||||
tiptapExtensions,
|
tiptapExtensions,
|
||||||
} from './collaboration.util';
|
} from './collaboration.util';
|
||||||
import { setYjsMark, updateYjsMarkAttribute, YjsSelection } from './yjs.util';
|
|
||||||
import * as Y from 'yjs';
|
import * as Y from 'yjs';
|
||||||
import { User } from '@docmost/db/types/entity.types';
|
import { User } from '@docmost/db/types/entity.types';
|
||||||
|
|
||||||
@@ -28,53 +27,6 @@ export class CollaborationHandler {
|
|||||||
// const fragment = doc.getXmlFragment('default');
|
// const fragment = doc.getXmlFragment('default');
|
||||||
//});
|
//});
|
||||||
},
|
},
|
||||||
setCommentMark: async (
|
|
||||||
documentName: string,
|
|
||||||
payload: {
|
|
||||||
yjsSelection: YjsSelection;
|
|
||||||
commentId: string;
|
|
||||||
resolved: boolean;
|
|
||||||
user: User;
|
|
||||||
},
|
|
||||||
) => {
|
|
||||||
const { yjsSelection, commentId, resolved, user } = payload;
|
|
||||||
await this.withYdocConnection(
|
|
||||||
hocuspocus,
|
|
||||||
documentName,
|
|
||||||
{ user },
|
|
||||||
(doc) => {
|
|
||||||
const fragment = doc.getXmlFragment('default');
|
|
||||||
setYjsMark(doc, fragment, yjsSelection, 'comment', {
|
|
||||||
commentId,
|
|
||||||
resolved,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
resolveCommentMark: async (
|
|
||||||
documentName: string,
|
|
||||||
payload: {
|
|
||||||
commentId: string;
|
|
||||||
resolved: boolean;
|
|
||||||
user: User;
|
|
||||||
},
|
|
||||||
) => {
|
|
||||||
const { commentId, resolved, user } = payload;
|
|
||||||
await this.withYdocConnection(
|
|
||||||
hocuspocus,
|
|
||||||
documentName,
|
|
||||||
{ user },
|
|
||||||
(doc) => {
|
|
||||||
const fragment = doc.getXmlFragment('default');
|
|
||||||
updateYjsMarkAttribute(
|
|
||||||
fragment,
|
|
||||||
'comment',
|
|
||||||
{ name: 'commentId', value: commentId },
|
|
||||||
{ resolved },
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
updatePageContent: async (
|
updatePageContent: async (
|
||||||
documentName: string,
|
documentName: string,
|
||||||
payload: {
|
payload: {
|
||||||
@@ -106,7 +58,8 @@ export class CollaborationHandler {
|
|||||||
} else {
|
} else {
|
||||||
const newContent = prosemirrorJson.content || [];
|
const newContent = prosemirrorJson.content || [];
|
||||||
const yElements = newContent.map(prosemirrorNodeToYElement);
|
const yElements = newContent.map(prosemirrorNodeToYElement);
|
||||||
const position = operation === 'prepend' ? 0 : fragment.length;
|
const position =
|
||||||
|
operation === 'prepend' ? 0 : fragment.length;
|
||||||
fragment.insert(position, yElements);
|
fragment.insert(position, yElements);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
initProseMirrorDoc,
|
initProseMirrorDoc,
|
||||||
relativePositionToAbsolutePosition,
|
relativePositionToAbsolutePosition,
|
||||||
} from '@tiptap/y-tiptap';
|
} from 'y-prosemirror';
|
||||||
import * as Y from 'yjs';
|
import * as Y from 'yjs';
|
||||||
import { Document } from '@hocuspocus/server';
|
import { Document } from '@hocuspocus/server';
|
||||||
import { getSchema } from '@tiptap/core';
|
import { getSchema } from '@tiptap/core';
|
||||||
|
|||||||
@@ -1,22 +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',
|
|
||||||
VIEWER_COMMENTS: 'comment:viewer',
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export type FeatureKey = (typeof Feature)[keyof typeof Feature];
|
|
||||||
@@ -7,7 +7,6 @@ export interface AuditContext {
|
|||||||
actorId: string | null;
|
actorId: string | null;
|
||||||
actorType: 'user' | 'system' | 'api_key';
|
actorType: 'user' | 'system' | 'api_key';
|
||||||
ipAddress: string | null;
|
ipAddress: string | null;
|
||||||
userAgent: string | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AUDIT_CONTEXT_KEY = 'auditContext';
|
export const AUDIT_CONTEXT_KEY = 'auditContext';
|
||||||
@@ -20,15 +19,11 @@ export class AuditContextMiddleware implements NestMiddleware {
|
|||||||
const workspaceId = (req as any).workspaceId ?? null;
|
const workspaceId = (req as any).workspaceId ?? null;
|
||||||
const ipAddress = this.extractIpAddress(req);
|
const ipAddress = this.extractIpAddress(req);
|
||||||
|
|
||||||
const userAgent =
|
|
||||||
(req.headers['user-agent'] as string) ?? null;
|
|
||||||
|
|
||||||
const auditContext: AuditContext = {
|
const auditContext: AuditContext = {
|
||||||
workspaceId,
|
workspaceId,
|
||||||
actorId: null,
|
actorId: null,
|
||||||
actorType: 'user',
|
actorType: 'user',
|
||||||
ipAddress,
|
ipAddress,
|
||||||
userAgent,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.cls.set(AUDIT_CONTEXT_KEY, auditContext);
|
this.cls.set(AUDIT_CONTEXT_KEY, auditContext);
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ export class AttachmentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
existingAttachment.pageId !== pageId ||
|
existingAttachment.pageId !== pageId &&
|
||||||
existingAttachment.fileExt !== preparedFile.fileExtension ||
|
existingAttachment.fileExt !== preparedFile.fileExtension &&
|
||||||
existingAttachment.workspaceId !== workspaceId
|
existingAttachment.workspaceId !== workspaceId
|
||||||
) {
|
) {
|
||||||
throw new BadRequestException('File attachment does not match');
|
throw new BadRequestException('File attachment does not match');
|
||||||
|
|||||||
@@ -5,14 +5,12 @@ import {
|
|||||||
HttpStatus,
|
HttpStatus,
|
||||||
Inject,
|
Inject,
|
||||||
Post,
|
Post,
|
||||||
Req,
|
|
||||||
Res,
|
Res,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
Logger,
|
Logger,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { LoginDto } from './dto/login.dto';
|
import { LoginDto } from './dto/login.dto';
|
||||||
import { AuthService } from './services/auth.service';
|
import { AuthService } from './services/auth.service';
|
||||||
import { SessionService } from '../session/session.service';
|
|
||||||
import { SetupGuard } from './guards/setup.guard';
|
import { SetupGuard } from './guards/setup.guard';
|
||||||
import { EnvironmentService } from '../../integrations/environment/environment.service';
|
import { EnvironmentService } from '../../integrations/environment/environment.service';
|
||||||
import { CreateAdminUserDto } from './dto/create-admin-user.dto';
|
import { CreateAdminUserDto } from './dto/create-admin-user.dto';
|
||||||
@@ -24,7 +22,7 @@ import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
|||||||
import { ForgotPasswordDto } from './dto/forgot-password.dto';
|
import { ForgotPasswordDto } from './dto/forgot-password.dto';
|
||||||
import { PasswordResetDto } from './dto/password-reset.dto';
|
import { PasswordResetDto } from './dto/password-reset.dto';
|
||||||
import { VerifyUserTokenDto } from './dto/verify-user-token.dto';
|
import { VerifyUserTokenDto } from './dto/verify-user-token.dto';
|
||||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
import { FastifyReply } from 'fastify';
|
||||||
import { validateSsoEnforcement } from './auth.util';
|
import { validateSsoEnforcement } from './auth.util';
|
||||||
import { ModuleRef } from '@nestjs/core';
|
import { ModuleRef } from '@nestjs/core';
|
||||||
import { AuditEvent, AuditResource } from '../../common/events/audit-events';
|
import { AuditEvent, AuditResource } from '../../common/events/audit-events';
|
||||||
@@ -39,7 +37,6 @@ export class AuthController {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private sessionService: SessionService,
|
|
||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
private moduleRef: ModuleRef,
|
private moduleRef: ModuleRef,
|
||||||
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
||||||
@@ -118,15 +115,8 @@ export class AuthController {
|
|||||||
@Body() dto: ChangePasswordDto,
|
@Body() dto: ChangePasswordDto,
|
||||||
@AuthUser() user: User,
|
@AuthUser() user: User,
|
||||||
@AuthWorkspace() workspace: Workspace,
|
@AuthWorkspace() workspace: Workspace,
|
||||||
@Req() req: FastifyRequest,
|
|
||||||
) {
|
) {
|
||||||
const currentSessionId = (req.raw as any).sessionId;
|
return this.authService.changePassword(dto, user.id, workspace.id);
|
||||||
return this.authService.changePassword(
|
|
||||||
dto,
|
|
||||||
user.id,
|
|
||||||
workspace.id,
|
|
||||||
currentSessionId,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@@ -188,18 +178,8 @@ export class AuthController {
|
|||||||
@Post('logout')
|
@Post('logout')
|
||||||
async logout(
|
async logout(
|
||||||
@AuthUser() user: User,
|
@AuthUser() user: User,
|
||||||
@Req() req: FastifyRequest,
|
|
||||||
@Res({ passthrough: true }) res: FastifyReply,
|
@Res({ passthrough: true }) res: FastifyReply,
|
||||||
) {
|
) {
|
||||||
const sessionId = (req.raw as any).sessionId;
|
|
||||||
if (sessionId) {
|
|
||||||
await this.sessionService.revokeSession(
|
|
||||||
sessionId,
|
|
||||||
user.id,
|
|
||||||
user.workspaceId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.clearCookie('authToken');
|
res.clearCookie('authToken');
|
||||||
|
|
||||||
this.auditService.log({
|
this.auditService.log({
|
||||||
@@ -212,7 +192,6 @@ export class AuthController {
|
|||||||
setAuthCookie(res: FastifyReply, token: string) {
|
setAuthCookie(res: FastifyReply, token: string) {
|
||||||
res.setCookie('authToken', token, {
|
res.setCookie('authToken', token, {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
sameSite: 'lax',
|
|
||||||
path: '/',
|
path: '/',
|
||||||
expires: this.environmentService.getCookieExpiresIn(),
|
expires: this.environmentService.getCookieExpiresIn(),
|
||||||
secure: this.environmentService.isHttps(),
|
secure: this.environmentService.isHttps(),
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ export type JwtPayload = {
|
|||||||
email: string;
|
email: string;
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
type: 'access';
|
type: 'access';
|
||||||
sessionId?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type JwtCollabPayload = {
|
export type JwtCollabPayload = {
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import {
|
|||||||
import { LoginDto } from '../dto/login.dto';
|
import { LoginDto } from '../dto/login.dto';
|
||||||
import { CreateUserDto } from '../dto/create-user.dto';
|
import { CreateUserDto } from '../dto/create-user.dto';
|
||||||
import { TokenService } from './token.service';
|
import { TokenService } from './token.service';
|
||||||
import { SessionService } from '../../session/session.service';
|
|
||||||
import { UserSessionRepo } from '@docmost/db/repos/session/user-session.repo';
|
|
||||||
import { SignupService } from './signup.service';
|
import { SignupService } from './signup.service';
|
||||||
import { CreateAdminUserDto } from '../dto/create-admin-user.dto';
|
import { CreateAdminUserDto } from '../dto/create-admin-user.dto';
|
||||||
import { UserRepo } from '@docmost/db/repos/user/user.repo';
|
import { UserRepo } from '@docmost/db/repos/user/user.repo';
|
||||||
@@ -46,8 +44,6 @@ export class AuthService {
|
|||||||
constructor(
|
constructor(
|
||||||
private signupService: SignupService,
|
private signupService: SignupService,
|
||||||
private tokenService: TokenService,
|
private tokenService: TokenService,
|
||||||
private sessionService: SessionService,
|
|
||||||
private userSessionRepo: UserSessionRepo,
|
|
||||||
private userRepo: UserRepo,
|
private userRepo: UserRepo,
|
||||||
private userTokenRepo: UserTokenRepo,
|
private userTokenRepo: UserTokenRepo,
|
||||||
private mailService: MailService,
|
private mailService: MailService,
|
||||||
@@ -94,19 +90,19 @@ export class AuthService {
|
|||||||
metadata: { source: 'password' },
|
metadata: { source: 'password' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.sessionService.createSessionAndToken(user);
|
return this.tokenService.generateAccessToken(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
async register(createUserDto: CreateUserDto, workspaceId: string) {
|
async register(createUserDto: CreateUserDto, workspaceId: string) {
|
||||||
const user = await this.signupService.signup(createUserDto, workspaceId);
|
const user = await this.signupService.signup(createUserDto, workspaceId);
|
||||||
return this.sessionService.createSessionAndToken(user);
|
return this.tokenService.generateAccessToken(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setup(createAdminUserDto: CreateAdminUserDto) {
|
async setup(createAdminUserDto: CreateAdminUserDto) {
|
||||||
const { workspace, user } =
|
const { workspace, user } =
|
||||||
await this.signupService.initialSetup(createAdminUserDto);
|
await this.signupService.initialSetup(createAdminUserDto);
|
||||||
|
|
||||||
const authToken = await this.sessionService.createSessionAndToken(user);
|
const authToken = await this.tokenService.generateAccessToken(user);
|
||||||
return { workspace, authToken };
|
return { workspace, authToken };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +110,6 @@ export class AuthService {
|
|||||||
dto: ChangePasswordDto,
|
dto: ChangePasswordDto,
|
||||||
userId: string,
|
userId: string,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
currentSessionId?: string,
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const user = await this.userRepo.findById(userId, workspaceId, {
|
const user = await this.userRepo.findById(userId, workspaceId, {
|
||||||
includePassword: true,
|
includePassword: true,
|
||||||
@@ -143,16 +138,6 @@ export class AuthService {
|
|||||||
workspaceId,
|
workspaceId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (currentSessionId) {
|
|
||||||
await this.userSessionRepo.deleteAllExceptCurrent(
|
|
||||||
currentSessionId,
|
|
||||||
userId,
|
|
||||||
workspaceId,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await this.userSessionRepo.deleteByUserId(userId, workspaceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.auditService.log({
|
this.auditService.log({
|
||||||
event: AuditEvent.USER_PASSWORD_CHANGED,
|
event: AuditEvent.USER_PASSWORD_CHANGED,
|
||||||
resourceType: AuditResource.USER,
|
resourceType: AuditResource.USER,
|
||||||
@@ -259,8 +244,6 @@ export class AuthService {
|
|||||||
.execute();
|
.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.userSessionRepo.deleteByUserId(user.id, workspace.id);
|
|
||||||
|
|
||||||
this.auditService.setActorId(user.id);
|
this.auditService.setActorId(user.id);
|
||||||
this.auditService.log({
|
this.auditService.log({
|
||||||
event: AuditEvent.USER_PASSWORD_RESET,
|
event: AuditEvent.USER_PASSWORD_RESET,
|
||||||
@@ -293,7 +276,7 @@ export class AuthService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const authToken = await this.sessionService.createSessionAndToken(user);
|
const authToken = await this.tokenService.generateAccessToken(user);
|
||||||
return { authToken };
|
return { authToken };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
UnauthorizedException,
|
UnauthorizedException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import type { StringValue } from 'ms';
|
|
||||||
import { EnvironmentService } from '../../../integrations/environment/environment.service';
|
import { EnvironmentService } from '../../../integrations/environment/environment.service';
|
||||||
import {
|
import {
|
||||||
JwtApiKeyPayload,
|
JwtApiKeyPayload,
|
||||||
@@ -25,7 +24,7 @@ export class TokenService {
|
|||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async generateAccessToken(user: User, sessionId: string): Promise<string> {
|
async generateAccessToken(user: User): Promise<string> {
|
||||||
if (isUserDisabled(user)) {
|
if (isUserDisabled(user)) {
|
||||||
throw new ForbiddenException();
|
throw new ForbiddenException();
|
||||||
}
|
}
|
||||||
@@ -35,7 +34,6 @@ export class TokenService {
|
|||||||
email: user.email,
|
email: user.email,
|
||||||
workspaceId: user.workspaceId,
|
workspaceId: user.workspaceId,
|
||||||
type: JwtType.ACCESS,
|
type: JwtType.ACCESS,
|
||||||
sessionId,
|
|
||||||
};
|
};
|
||||||
return this.jwtService.sign(payload);
|
return this.jwtService.sign(payload);
|
||||||
}
|
}
|
||||||
@@ -98,7 +96,7 @@ export class TokenService {
|
|||||||
apiKeyId: string;
|
apiKeyId: string;
|
||||||
user: User;
|
user: User;
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
expiresIn?: StringValue | number;
|
expiresIn?: string | number;
|
||||||
}): Promise<string> {
|
}): Promise<string> {
|
||||||
const { apiKeyId, user, workspaceId, expiresIn } = opts;
|
const { apiKeyId, user, workspaceId, expiresIn } = opts;
|
||||||
if (isUserDisabled(user)) {
|
if (isUserDisabled(user)) {
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import { EnvironmentService } from '../../../integrations/environment/environmen
|
|||||||
import { JwtApiKeyPayload, JwtPayload, JwtType } from '../dto/jwt-payload';
|
import { JwtApiKeyPayload, JwtPayload, JwtType } from '../dto/jwt-payload';
|
||||||
import { WorkspaceRepo } from '@docmost/db/repos/workspace/workspace.repo';
|
import { WorkspaceRepo } from '@docmost/db/repos/workspace/workspace.repo';
|
||||||
import { UserRepo } from '@docmost/db/repos/user/user.repo';
|
import { UserRepo } from '@docmost/db/repos/user/user.repo';
|
||||||
import { UserSessionRepo } from '@docmost/db/repos/session/user-session.repo';
|
|
||||||
import { SessionActivityService } from '../../session/session-activity.service';
|
|
||||||
import { FastifyRequest } from 'fastify';
|
import { FastifyRequest } from 'fastify';
|
||||||
import { extractBearerTokenFromHeader, isUserDisabled } from '../../../common/helpers';
|
import { extractBearerTokenFromHeader, isUserDisabled } from '../../../common/helpers';
|
||||||
import { ModuleRef } from '@nestjs/core';
|
import { ModuleRef } from '@nestjs/core';
|
||||||
@@ -18,8 +16,6 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
|||||||
constructor(
|
constructor(
|
||||||
private userRepo: UserRepo,
|
private userRepo: UserRepo,
|
||||||
private workspaceRepo: WorkspaceRepo,
|
private workspaceRepo: WorkspaceRepo,
|
||||||
private userSessionRepo: UserSessionRepo,
|
|
||||||
private sessionActivityService: SessionActivityService,
|
|
||||||
private readonly environmentService: EnvironmentService,
|
private readonly environmentService: EnvironmentService,
|
||||||
private moduleRef: ModuleRef,
|
private moduleRef: ModuleRef,
|
||||||
) {
|
) {
|
||||||
@@ -61,16 +57,6 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
|||||||
throw new UnauthorizedException();
|
throw new UnauthorizedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((payload as JwtPayload).sessionId) {
|
|
||||||
const sessionId = (payload as JwtPayload).sessionId;
|
|
||||||
const session = await this.userSessionRepo.findActiveById(sessionId);
|
|
||||||
if (!session || session.userId !== payload.sub || session.workspaceId !== payload.workspaceId) {
|
|
||||||
throw new UnauthorizedException();
|
|
||||||
}
|
|
||||||
req.raw.sessionId = sessionId;
|
|
||||||
this.sessionActivityService.trackActivity(sessionId, payload.sub, payload.workspaceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return { user, workspace };
|
return { user, workspace };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
import type { StringValue } from 'ms';
|
|
||||||
import { EnvironmentService } from '../../integrations/environment/environment.service';
|
import { EnvironmentService } from '../../integrations/environment/environment.service';
|
||||||
import { TokenService } from './services/token.service';
|
import { TokenService } from './services/token.service';
|
||||||
|
|
||||||
@@ -11,7 +10,7 @@ import { TokenService } from './services/token.service';
|
|||||||
return {
|
return {
|
||||||
secret: environmentService.getAppSecret(),
|
secret: environmentService.getAppSecret(),
|
||||||
signOptions: {
|
signOptions: {
|
||||||
expiresIn: environmentService.getJwtTokenExpiresIn() as StringValue,
|
expiresIn: environmentService.getJwtTokenExpiresIn(),
|
||||||
issuer: 'Docmost',
|
issuer: 'Docmost',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -58,13 +58,13 @@ export class CommentController {
|
|||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.pageAccessService.validateCanComment(page, user, workspace.id);
|
await this.pageAccessService.validateCanEdit(page, user);
|
||||||
|
|
||||||
const comment = await this.commentService.create(
|
const comment = await this.commentService.create(
|
||||||
{
|
{
|
||||||
|
userId: user.id,
|
||||||
page,
|
page,
|
||||||
workspaceId: workspace.id,
|
workspaceId: workspace.id,
|
||||||
user,
|
|
||||||
},
|
},
|
||||||
createCommentDto,
|
createCommentDto,
|
||||||
);
|
);
|
||||||
@@ -120,7 +120,7 @@ export class CommentController {
|
|||||||
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Post('update')
|
@Post('update')
|
||||||
async update(@Body() dto: UpdateCommentDto, @AuthUser() user: User, @AuthWorkspace() workspace: Workspace) {
|
async update(@Body() dto: UpdateCommentDto, @AuthUser() user: User) {
|
||||||
const comment = await this.commentRepo.findById(dto.commentId, {
|
const comment = await this.commentRepo.findById(dto.commentId, {
|
||||||
includeCreator: true,
|
includeCreator: true,
|
||||||
includeResolvedBy: true,
|
includeResolvedBy: true,
|
||||||
@@ -134,14 +134,14 @@ export class CommentController {
|
|||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.pageAccessService.validateCanComment(page, user, workspace.id);
|
await this.pageAccessService.validateCanEdit(page, user);
|
||||||
|
|
||||||
return this.commentService.update(comment, dto, user);
|
return this.commentService.update(comment, dto, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Post('delete')
|
@Post('delete')
|
||||||
async delete(@Body() input: CommentIdDto, @AuthUser() user: User, @AuthWorkspace() workspace: Workspace) {
|
async delete(@Body() input: CommentIdDto, @AuthUser() user: User) {
|
||||||
const comment = await this.commentRepo.findById(input.commentId);
|
const comment = await this.commentRepo.findById(input.commentId);
|
||||||
if (!comment) {
|
if (!comment) {
|
||||||
throw new NotFoundException('Comment not found');
|
throw new NotFoundException('Comment not found');
|
||||||
@@ -152,7 +152,8 @@ export class CommentController {
|
|||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.pageAccessService.validateCanComment(page, user, workspace.id);
|
// Check page-level edit permission first
|
||||||
|
await this.pageAccessService.validateCanEdit(page, user);
|
||||||
|
|
||||||
// Check if user is the comment owner
|
// Check if user is the comment owner
|
||||||
const isOwner = comment.creatorId === user.id;
|
const isOwner = comment.creatorId === user.id;
|
||||||
@@ -168,7 +169,7 @@ export class CommentController {
|
|||||||
// Space admin can delete any comment
|
// Space admin can delete any comment
|
||||||
if (ability.cannot(SpaceCaslAction.Manage, SpaceCaslSubject.Settings)) {
|
if (ability.cannot(SpaceCaslAction.Manage, SpaceCaslSubject.Settings)) {
|
||||||
throw new ForbiddenException(
|
throw new ForbiddenException(
|
||||||
'You can only delete your own comments',
|
'You can only delete your own comments or must be a space admin',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await this.commentRepo.deleteComment(comment.id);
|
await this.commentRepo.deleteComment(comment.id);
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { CommentService } from './comment.service';
|
import { CommentService } from './comment.service';
|
||||||
import { CommentController } from './comment.controller';
|
import { CommentController } from './comment.controller';
|
||||||
import { CollaborationModule } from '../../collaboration/collaboration.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [CollaborationModule],
|
|
||||||
controllers: [CommentController],
|
controllers: [CommentController],
|
||||||
providers: [CommentService],
|
providers: [CommentService],
|
||||||
exports: [CommentService],
|
exports: [CommentService],
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import {
|
|||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { InjectQueue } from '@nestjs/bullmq';
|
import { InjectQueue } from '@nestjs/bullmq';
|
||||||
import { Queue } from 'bullmq';
|
import { Queue } from 'bullmq';
|
||||||
import { CreateCommentDto, yjsSelectionSchema } from './dto/create-comment.dto';
|
import { CreateCommentDto } from './dto/create-comment.dto';
|
||||||
import { CollaborationGateway } from '../../collaboration/collaboration.gateway';
|
|
||||||
import { UpdateCommentDto } from './dto/update-comment.dto';
|
import { UpdateCommentDto } from './dto/update-comment.dto';
|
||||||
import { CommentRepo } from '@docmost/db/repos/comment/comment.repo';
|
import { CommentRepo } from '@docmost/db/repos/comment/comment.repo';
|
||||||
import { Comment, Page, User } from '@docmost/db/types/entity.types';
|
import { Comment, Page, User } from '@docmost/db/types/entity.types';
|
||||||
@@ -28,7 +27,6 @@ export class CommentService {
|
|||||||
private commentRepo: CommentRepo,
|
private commentRepo: CommentRepo,
|
||||||
private pageRepo: PageRepo,
|
private pageRepo: PageRepo,
|
||||||
private wsService: WsService,
|
private wsService: WsService,
|
||||||
private collaborationGateway: CollaborationGateway,
|
|
||||||
@InjectQueue(QueueName.GENERAL_QUEUE)
|
@InjectQueue(QueueName.GENERAL_QUEUE)
|
||||||
private generalQueue: Queue,
|
private generalQueue: Queue,
|
||||||
@InjectQueue(QueueName.NOTIFICATION_QUEUE)
|
@InjectQueue(QueueName.NOTIFICATION_QUEUE)
|
||||||
@@ -47,10 +45,10 @@ export class CommentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async create(
|
async create(
|
||||||
opts: { page: Page; workspaceId: string; user: User },
|
opts: { userId: string; page: Page; workspaceId: string },
|
||||||
createCommentDto: CreateCommentDto,
|
createCommentDto: CreateCommentDto,
|
||||||
) {
|
) {
|
||||||
const { page, workspaceId, user } = opts;
|
const { userId, page, workspaceId } = opts;
|
||||||
const commentContent = JSON.parse(createCommentDto.content);
|
const commentContent = JSON.parse(createCommentDto.content);
|
||||||
|
|
||||||
if (createCommentDto.parentCommentId) {
|
if (createCommentDto.parentCommentId) {
|
||||||
@@ -73,39 +71,11 @@ export class CommentService {
|
|||||||
selection: createCommentDto?.selection?.substring(0, 250) ?? null,
|
selection: createCommentDto?.selection?.substring(0, 250) ?? null,
|
||||||
type: createCommentDto.type ?? 'page',
|
type: createCommentDto.type ?? 'page',
|
||||||
parentCommentId: createCommentDto?.parentCommentId,
|
parentCommentId: createCommentDto?.parentCommentId,
|
||||||
creatorId: user.id,
|
creatorId: userId,
|
||||||
workspaceId: workspaceId,
|
workspaceId: workspaceId,
|
||||||
spaceId: page.spaceId,
|
spaceId: page.spaceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (createCommentDto.yjsSelection) {
|
|
||||||
const parsed = yjsSelectionSchema.safeParse(createCommentDto.yjsSelection);
|
|
||||||
if (!parsed.success) {
|
|
||||||
this.logger.warn(
|
|
||||||
`Invalid yjsSelection for comment ${inserted.id}: ${parsed.error.message}`,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
const documentName = `page.${page.id}`;
|
|
||||||
try {
|
|
||||||
await this.collaborationGateway.handleYjsEvent(
|
|
||||||
'setCommentMark',
|
|
||||||
documentName,
|
|
||||||
{
|
|
||||||
yjsSelection: parsed.data,
|
|
||||||
commentId: inserted.id,
|
|
||||||
resolved: false,
|
|
||||||
user,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.warn(
|
|
||||||
`Failed to apply comment mark for comment ${inserted.id}, comment saved without inline highlight`,
|
|
||||||
error,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const comment = await this.commentRepo.findById(inserted.id, {
|
const comment = await this.commentRepo.findById(inserted.id, {
|
||||||
includeCreator: true,
|
includeCreator: true,
|
||||||
includeResolvedBy: true,
|
includeResolvedBy: true,
|
||||||
@@ -113,7 +83,7 @@ export class CommentService {
|
|||||||
|
|
||||||
this.generalQueue
|
this.generalQueue
|
||||||
.add(QueueJob.ADD_PAGE_WATCHERS, {
|
.add(QueueJob.ADD_PAGE_WATCHERS, {
|
||||||
userIds: [user.id],
|
userIds: [userId],
|
||||||
pageId: page.id,
|
pageId: page.id,
|
||||||
spaceId: page.spaceId,
|
spaceId: page.spaceId,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
@@ -131,7 +101,7 @@ export class CommentService {
|
|||||||
page.id,
|
page.id,
|
||||||
page.spaceId,
|
page.spaceId,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
user.id,
|
userId,
|
||||||
!isReply,
|
!isReply,
|
||||||
createCommentDto.parentCommentId,
|
createCommentDto.parentCommentId,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,22 +1,4 @@
|
|||||||
import { IsIn, IsJSON, IsObject, IsOptional, IsString, IsUUID } from 'class-validator';
|
import { IsIn, IsJSON, IsOptional, IsString, IsUUID } from 'class-validator';
|
||||||
import { z } from 'zod';
|
|
||||||
|
|
||||||
const yjsIdSchema = z.object({
|
|
||||||
client: z.number().int().nonnegative(),
|
|
||||||
clock: z.number().int().nonnegative(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const yjsRelativePositionSchema = z.object({
|
|
||||||
type: yjsIdSchema,
|
|
||||||
tname: z.string().nullable(),
|
|
||||||
item: yjsIdSchema.nullable(),
|
|
||||||
assoc: z.number().int(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const yjsSelectionSchema = z.object({
|
|
||||||
anchor: yjsRelativePositionSchema,
|
|
||||||
head: yjsRelativePositionSchema,
|
|
||||||
});
|
|
||||||
|
|
||||||
export class CreateCommentDto {
|
export class CreateCommentDto {
|
||||||
@IsString()
|
@IsString()
|
||||||
@@ -36,11 +18,4 @@ export class CreateCommentDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsUUID()
|
@IsUUID()
|
||||||
parentCommentId: string;
|
parentCommentId: string;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsObject()
|
|
||||||
yjsSelection?: {
|
|
||||||
anchor: any;
|
|
||||||
head: any;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import { AuditContextMiddleware } from '../common/middlewares/audit-context.midd
|
|||||||
import { ShareModule } from './share/share.module';
|
import { ShareModule } from './share/share.module';
|
||||||
import { NotificationModule } from './notification/notification.module';
|
import { NotificationModule } from './notification/notification.module';
|
||||||
import { WatcherModule } from './watcher/watcher.module';
|
import { WatcherModule } from './watcher/watcher.module';
|
||||||
import { SessionModule } from './session/session.module';
|
|
||||||
import { ClsMiddleware } from 'nestjs-cls';
|
import { ClsMiddleware } from 'nestjs-cls';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
@@ -39,7 +38,6 @@ import { ClsMiddleware } from 'nestjs-cls';
|
|||||||
ShareModule,
|
ShareModule,
|
||||||
NotificationModule,
|
NotificationModule,
|
||||||
WatcherModule,
|
WatcherModule,
|
||||||
SessionModule,
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CoreModule implements NestModule {
|
export class CoreModule implements NestModule {
|
||||||
|
|||||||
@@ -6,14 +6,12 @@ import {
|
|||||||
SpaceCaslAction,
|
SpaceCaslAction,
|
||||||
SpaceCaslSubject,
|
SpaceCaslSubject,
|
||||||
} from '../../casl/interfaces/space-ability.type';
|
} from '../../casl/interfaces/space-ability.type';
|
||||||
import { SpaceRepo } from '@docmost/db/repos/space/space.repo';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PageAccessService {
|
export class PageAccessService {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly pagePermissionRepo: PagePermissionRepo,
|
private readonly pagePermissionRepo: PagePermissionRepo,
|
||||||
private readonly spaceAbility: SpaceAbilityFactory,
|
private readonly spaceAbility: SpaceAbilityFactory,
|
||||||
private readonly spaceRepo: SpaceRepo,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,25 +99,4 @@ export class PageAccessService {
|
|||||||
|
|
||||||
return { hasRestriction: hasAnyRestriction };
|
return { hasRestriction: hasAnyRestriction };
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateCanComment(
|
|
||||||
page: Page,
|
|
||||||
user: User,
|
|
||||||
workspaceId: string,
|
|
||||||
): Promise<void> {
|
|
||||||
try {
|
|
||||||
await this.validateCanEdit(page, user);
|
|
||||||
return;
|
|
||||||
} catch {
|
|
||||||
// User cannot edit — check if reader commenting is enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.validateCanView(page, user);
|
|
||||||
|
|
||||||
const space = await this.spaceRepo.findById(page.spaceId, workspaceId);
|
|
||||||
const settings = space?.settings as Record<string, any> | null;
|
|
||||||
if (!settings?.comments?.allowViewerComments) {
|
|
||||||
throw new ForbiddenException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,15 +91,9 @@ export class SearchService {
|
|||||||
return { items: [] };
|
return { items: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
const isRestricted =
|
|
||||||
await this.pagePermissionRepo.hasRestrictedAncestor(share.pageId);
|
|
||||||
if (isRestricted) {
|
|
||||||
return { items: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
const pageIdsToSearch = [];
|
const pageIdsToSearch = [];
|
||||||
if (share.includeSubPages) {
|
if (share.includeSubPages) {
|
||||||
const pageList = await this.pageRepo.getPageAndDescendantsExcludingRestricted(
|
const pageList = await this.pageRepo.getPageAndDescendants(
|
||||||
share.pageId,
|
share.pageId,
|
||||||
{
|
{
|
||||||
includeContent: false,
|
includeContent: false,
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
import { IsNotEmpty, IsUUID } from 'class-validator';
|
|
||||||
|
|
||||||
export class RevokeSessionDto {
|
|
||||||
@IsUUID()
|
|
||||||
@IsNotEmpty()
|
|
||||||
sessionId: string;
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { RedisService } from '@nestjs-labs/nestjs-ioredis';
|
|
||||||
import type { Redis } from 'ioredis';
|
|
||||||
import { UserSessionRepo } from '@docmost/db/repos/session/user-session.repo';
|
|
||||||
import { UserRepo } from '@docmost/db/repos/user/user.repo';
|
|
||||||
|
|
||||||
const THROTTLE_SECONDS = 15 * 60; // 15 minutes
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class SessionActivityService {
|
|
||||||
private readonly redis: Redis;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private readonly redisService: RedisService,
|
|
||||||
private readonly userSessionRepo: UserSessionRepo,
|
|
||||||
private readonly userRepo: UserRepo,
|
|
||||||
) {
|
|
||||||
this.redis = this.redisService.getOrThrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
trackActivity(sessionId: string, userId: string, workspaceId: string): void {
|
|
||||||
const key = `session:activity:${sessionId}`;
|
|
||||||
|
|
||||||
this.redis
|
|
||||||
.set(key, '1', 'EX', THROTTLE_SECONDS, 'NX')
|
|
||||||
.then((result) => {
|
|
||||||
if (result === null) return; // key already exists, throttled
|
|
||||||
|
|
||||||
this.userSessionRepo.updateLastActiveAt(sessionId).catch(() => {});
|
|
||||||
this.userRepo
|
|
||||||
.updateUser({ lastActiveAt: new Date() }, userId, workspaceId)
|
|
||||||
.catch(() => {});
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
import {
|
|
||||||
BadRequestException,
|
|
||||||
Body,
|
|
||||||
Controller,
|
|
||||||
HttpCode,
|
|
||||||
HttpStatus,
|
|
||||||
Post,
|
|
||||||
Req,
|
|
||||||
UseGuards,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { SessionService } from './session.service';
|
|
||||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
|
||||||
import { AuthUser } from '../../common/decorators/auth-user.decorator';
|
|
||||||
import { AuthWorkspace } from '../../common/decorators/auth-workspace.decorator';
|
|
||||||
import { User, Workspace } from '@docmost/db/types/entity.types';
|
|
||||||
import { RevokeSessionDto } from './dto/revoke-session.dto';
|
|
||||||
import { FastifyRequest } from 'fastify';
|
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard)
|
|
||||||
@Controller('sessions')
|
|
||||||
export class SessionController {
|
|
||||||
constructor(private readonly sessionService: SessionService) {}
|
|
||||||
|
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
@Post()
|
|
||||||
async listSessions(
|
|
||||||
@AuthUser() user: User,
|
|
||||||
@AuthWorkspace() workspace: Workspace,
|
|
||||||
@Req() req: FastifyRequest,
|
|
||||||
) {
|
|
||||||
const currentSessionId = (req.raw as any).sessionId ?? null;
|
|
||||||
const sessions = await this.sessionService.getActiveSessions(
|
|
||||||
user.id,
|
|
||||||
workspace.id,
|
|
||||||
currentSessionId,
|
|
||||||
);
|
|
||||||
return { sessions };
|
|
||||||
}
|
|
||||||
|
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
@Post('revoke')
|
|
||||||
async revokeSession(
|
|
||||||
@Body() dto: RevokeSessionDto,
|
|
||||||
@AuthUser() user: User,
|
|
||||||
@AuthWorkspace() workspace: Workspace,
|
|
||||||
@Req() req: FastifyRequest,
|
|
||||||
) {
|
|
||||||
const currentSessionId = (req.raw as any).sessionId;
|
|
||||||
if (dto.sessionId === currentSessionId) {
|
|
||||||
throw new BadRequestException(
|
|
||||||
'Cannot revoke current session. Use logout instead.',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await this.sessionService.revokeSession(
|
|
||||||
dto.sessionId,
|
|
||||||
user.id,
|
|
||||||
workspace.id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
@Post('revoke-all')
|
|
||||||
async revokeAllSessions(
|
|
||||||
@AuthUser() user: User,
|
|
||||||
@AuthWorkspace() workspace: Workspace,
|
|
||||||
@Req() req: FastifyRequest,
|
|
||||||
) {
|
|
||||||
const currentSessionId = (req.raw as any).sessionId;
|
|
||||||
if (!currentSessionId) {
|
|
||||||
throw new BadRequestException(
|
|
||||||
'Current session not found. Please log in again.',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await this.sessionService.revokeAllOtherSessions(
|
|
||||||
currentSessionId,
|
|
||||||
user.id,
|
|
||||||
workspace.id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { Global, Module } from '@nestjs/common';
|
|
||||||
import { SessionService } from './session.service';
|
|
||||||
import { SessionActivityService } from './session-activity.service';
|
|
||||||
import { SessionController } from './session.controller';
|
|
||||||
import { TokenModule } from '../auth/token.module';
|
|
||||||
|
|
||||||
@Global()
|
|
||||||
@Module({
|
|
||||||
imports: [TokenModule],
|
|
||||||
controllers: [SessionController],
|
|
||||||
providers: [SessionService, SessionActivityService],
|
|
||||||
exports: [SessionService, SessionActivityService],
|
|
||||||
})
|
|
||||||
export class SessionModule {}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
|
||||||
import { Interval } from '@nestjs/schedule';
|
|
||||||
import { TokenService } from '../auth/services/token.service';
|
|
||||||
import { UserSessionRepo } from '@docmost/db/repos/session/user-session.repo';
|
|
||||||
import { EnvironmentService } from '../../integrations/environment/environment.service';
|
|
||||||
import { User } from '@docmost/db/types/entity.types';
|
|
||||||
import { ClsService } from 'nestjs-cls';
|
|
||||||
import {
|
|
||||||
AuditContext,
|
|
||||||
AUDIT_CONTEXT_KEY,
|
|
||||||
} from '../../common/middlewares/audit-context.middleware';
|
|
||||||
import * as Bowser from 'bowser';
|
|
||||||
|
|
||||||
const MAX_SESSIONS_PER_USER = 25;
|
|
||||||
const RETENTION_DAYS = 7;
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class SessionService {
|
|
||||||
private readonly logger = new Logger(SessionService.name);
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private readonly tokenService: TokenService,
|
|
||||||
private readonly userSessionRepo: UserSessionRepo,
|
|
||||||
private readonly environmentService: EnvironmentService,
|
|
||||||
private readonly cls: ClsService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
@Interval('session-cleanup', 24 * 60 * 60 * 1000)
|
|
||||||
async cleanupSessions() {
|
|
||||||
try {
|
|
||||||
await this.userSessionRepo.deleteStale(RETENTION_DAYS);
|
|
||||||
await this.userSessionRepo.trimExcessSessions(MAX_SESSIONS_PER_USER);
|
|
||||||
this.logger.debug('Session cleanup completed');
|
|
||||||
} catch (err) {
|
|
||||||
this.logger.error('Session cleanup failed', err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async createSessionAndToken(user: User): Promise<string> {
|
|
||||||
const auditContext = this.cls.get<AuditContext>(AUDIT_CONTEXT_KEY);
|
|
||||||
const ipAddress = auditContext?.ipAddress ?? null;
|
|
||||||
const userAgent = auditContext?.userAgent ?? null;
|
|
||||||
|
|
||||||
const deviceName = this.parseDeviceName(userAgent);
|
|
||||||
const expiresAt = this.environmentService.getCookieExpiresIn();
|
|
||||||
|
|
||||||
const session = await this.userSessionRepo.insertSession({
|
|
||||||
userId: user.id,
|
|
||||||
workspaceId: user.workspaceId,
|
|
||||||
deviceName,
|
|
||||||
ipAddress,
|
|
||||||
expiresAt,
|
|
||||||
});
|
|
||||||
|
|
||||||
return this.tokenService.generateAccessToken(user, session.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
async getActiveSessions(
|
|
||||||
userId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
currentSessionId: string | null,
|
|
||||||
) {
|
|
||||||
const sessions = await this.userSessionRepo.findActiveByUser(
|
|
||||||
userId,
|
|
||||||
workspaceId,
|
|
||||||
);
|
|
||||||
|
|
||||||
const mapped = sessions.map((s) => ({
|
|
||||||
id: s.id,
|
|
||||||
deviceName: s.deviceName,
|
|
||||||
geoLocation: s.geoLocation,
|
|
||||||
lastActiveAt: s.lastActiveAt,
|
|
||||||
createdAt: s.createdAt,
|
|
||||||
isCurrentDevice: s.id === currentSessionId,
|
|
||||||
}));
|
|
||||||
|
|
||||||
return mapped.sort((a, b) => {
|
|
||||||
if (a.isCurrentDevice) return -1;
|
|
||||||
if (b.isCurrentDevice) return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async revokeSession(
|
|
||||||
sessionId: string,
|
|
||||||
userId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
): Promise<void> {
|
|
||||||
await this.userSessionRepo.revokeById(sessionId, userId, workspaceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
async revokeAllOtherSessions(
|
|
||||||
currentSessionId: string,
|
|
||||||
userId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
): Promise<void> {
|
|
||||||
await this.userSessionRepo.revokeAllExceptCurrent(
|
|
||||||
currentSessionId,
|
|
||||||
userId,
|
|
||||||
workspaceId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private parseDeviceName(userAgent: string | null): string | null {
|
|
||||||
if (!userAgent) return null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const parsed = Bowser.parse(userAgent);
|
|
||||||
|
|
||||||
const os = parsed.os?.name;
|
|
||||||
const browser = parsed.browser?.name;
|
|
||||||
const platformType = parsed.platform?.type;
|
|
||||||
|
|
||||||
if (platformType === 'mobile' || platformType === 'tablet') {
|
|
||||||
return parsed.platform?.model || os || 'Mobile Device';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (os) {
|
|
||||||
return browser ? `${browser} on ${os}` : os;
|
|
||||||
}
|
|
||||||
|
|
||||||
return browser || null;
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,8 +11,4 @@ export class UpdateSpaceDto extends PartialType(CreateSpaceDto) {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
disablePublicSharing: boolean;
|
disablePublicSharing: boolean;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
allowViewerComments: boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { Space, User } from '@docmost/db/types/entity.types';
|
|||||||
import { UpdateSpaceDto } from '../dto/update-space.dto';
|
import { UpdateSpaceDto } from '../dto/update-space.dto';
|
||||||
import { executeTx } from '@docmost/db/utils';
|
import { executeTx } from '@docmost/db/utils';
|
||||||
import { InjectKysely } from 'nestjs-kysely';
|
import { InjectKysely } from 'nestjs-kysely';
|
||||||
import { Feature } from '../../../common/features';
|
|
||||||
import { SpaceMemberService } from './space-member.service';
|
import { SpaceMemberService } from './space-member.service';
|
||||||
import { SpaceRole } from '../../../common/helpers/types/permission';
|
import { SpaceRole } from '../../../common/helpers/types/permission';
|
||||||
import { QueueJob, QueueName } from 'src/integrations/queue/constants';
|
import { QueueJob, QueueName } from 'src/integrations/queue/constants';
|
||||||
@@ -134,34 +133,17 @@ export class SpaceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (typeof updateSpaceDto.disablePublicSharing !== 'undefined') {
|
||||||
typeof updateSpaceDto.disablePublicSharing !== 'undefined' ||
|
|
||||||
typeof updateSpaceDto.allowViewerComments !== 'undefined'
|
|
||||||
) {
|
|
||||||
const workspace = await this.workspaceRepo.findById(workspaceId, {
|
const workspace = await this.workspaceRepo.findById(workspaceId, {
|
||||||
withLicenseKey: true,
|
withLicenseKey: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof updateSpaceDto.disablePublicSharing !== 'undefined' &&
|
!this.licenseCheckService.hasFeature(workspace.licenseKey, 'security:settings', workspace.plan)
|
||||||
!this.licenseCheckService.hasFeature(
|
|
||||||
workspace.licenseKey,
|
|
||||||
Feature.SECURITY_SETTINGS,
|
|
||||||
workspace.plan,
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
throw new ForbiddenException('This feature requires a valid license');
|
throw new ForbiddenException(
|
||||||
}
|
'This feature requires a valid license',
|
||||||
|
);
|
||||||
if (
|
|
||||||
typeof updateSpaceDto.allowViewerComments !== 'undefined' &&
|
|
||||||
!this.licenseCheckService.hasFeature(
|
|
||||||
workspace.licenseKey,
|
|
||||||
Feature.VIEWER_COMMENTS,
|
|
||||||
workspace.plan,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new ForbiddenException('This feature requires a valid license');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,22 +179,6 @@ export class SpaceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof updateSpaceDto.allowViewerComments !== 'undefined') {
|
|
||||||
const prev = settingsBefore?.comments?.allowViewerComments ?? false;
|
|
||||||
if (prev !== updateSpaceDto.allowViewerComments) {
|
|
||||||
before.allowViewerComments = prev;
|
|
||||||
after.allowViewerComments = updateSpaceDto.allowViewerComments;
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.spaceRepo.updateCommentSettings(
|
|
||||||
updateSpaceDto.spaceId,
|
|
||||||
workspaceId,
|
|
||||||
'allowViewerComments',
|
|
||||||
updateSpaceDto.allowViewerComments,
|
|
||||||
trx,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
updatedSpace = await this.spaceRepo.updateSpace(
|
updatedSpace = await this.spaceRepo.updateSpace(
|
||||||
{
|
{
|
||||||
name: updateSpaceDto.name,
|
name: updateSpaceDto.name,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { IsEnum, IsNotEmpty, IsUUID } from 'class-validator';
|
import { IsNotEmpty, IsString, IsUUID } from 'class-validator';
|
||||||
import { UserRole } from '../../../common/helpers/types/permission';
|
|
||||||
|
|
||||||
export class UpdateWorkspaceUserRoleDto {
|
export class UpdateWorkspaceUserRoleDto {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@@ -7,6 +6,6 @@ export class UpdateWorkspaceUserRoleDto {
|
|||||||
userId: string;
|
userId: string;
|
||||||
|
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsEnum(UserRole)
|
@IsString()
|
||||||
role: string;
|
role: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import InvitationEmail from '@docmost/transactional/emails/invitation-email';
|
|||||||
import { GroupUserRepo } from '@docmost/db/repos/group/group-user.repo';
|
import { GroupUserRepo } from '@docmost/db/repos/group/group-user.repo';
|
||||||
import InvitationAcceptedEmail from '@docmost/transactional/emails/invitation-accepted-email';
|
import InvitationAcceptedEmail from '@docmost/transactional/emails/invitation-accepted-email';
|
||||||
import { TokenService } from '../../auth/services/token.service';
|
import { TokenService } from '../../auth/services/token.service';
|
||||||
import { SessionService } from '../../session/session.service';
|
|
||||||
import { nanoIdGen } from '../../../common/helpers';
|
import { nanoIdGen } from '../../../common/helpers';
|
||||||
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
||||||
import { executeWithCursorPagination } from '@docmost/db/pagination/cursor-pagination';
|
import { executeWithCursorPagination } from '@docmost/db/pagination/cursor-pagination';
|
||||||
@@ -50,7 +49,6 @@ export class WorkspaceInvitationService {
|
|||||||
private mailService: MailService,
|
private mailService: MailService,
|
||||||
private domainService: DomainService,
|
private domainService: DomainService,
|
||||||
private tokenService: TokenService,
|
private tokenService: TokenService,
|
||||||
private sessionService: SessionService,
|
|
||||||
@InjectKysely() private readonly db: KyselyDB,
|
@InjectKysely() private readonly db: KyselyDB,
|
||||||
@InjectQueue(QueueName.BILLING_QUEUE) private billingQueue: Queue,
|
@InjectQueue(QueueName.BILLING_QUEUE) private billingQueue: Queue,
|
||||||
private readonly environmentService: EnvironmentService,
|
private readonly environmentService: EnvironmentService,
|
||||||
@@ -352,7 +350,7 @@ export class WorkspaceInvitationService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const authToken = await this.sessionService.createSessionAndToken(newUser);
|
const authToken = await this.tokenService.generateAccessToken(newUser);
|
||||||
return { authToken };
|
return { authToken };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
NotFoundException,
|
NotFoundException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { LicenseCheckService } from '../../../integrations/environment/license-check.service';
|
import { LicenseCheckService } from '../../../integrations/environment/license-check.service';
|
||||||
import { UserSessionRepo } from '@docmost/db/repos/session/user-session.repo';
|
|
||||||
import { CreateWorkspaceDto } from '../dto/create-workspace.dto';
|
import { CreateWorkspaceDto } from '../dto/create-workspace.dto';
|
||||||
import { UpdateWorkspaceDto } from '../dto/update-workspace.dto';
|
import { UpdateWorkspaceDto } from '../dto/update-workspace.dto';
|
||||||
import { SpaceService } from '../../space/services/space.service';
|
import { SpaceService } from '../../space/services/space.service';
|
||||||
@@ -18,7 +17,6 @@ import { WorkspaceRepo } from '@docmost/db/repos/workspace/workspace.repo';
|
|||||||
import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types';
|
import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types';
|
||||||
import { executeTx } from '@docmost/db/utils';
|
import { executeTx } from '@docmost/db/utils';
|
||||||
import { InjectKysely } from 'nestjs-kysely';
|
import { InjectKysely } from 'nestjs-kysely';
|
||||||
import { Feature } from '../../../common/features';
|
|
||||||
import { User } from '@docmost/db/types/entity.types';
|
import { User } from '@docmost/db/types/entity.types';
|
||||||
import { GroupUserRepo } from '@docmost/db/repos/group/group-user.repo';
|
import { GroupUserRepo } from '@docmost/db/repos/group/group-user.repo';
|
||||||
import { GroupRepo } from '@docmost/db/repos/group/group.repo';
|
import { GroupRepo } from '@docmost/db/repos/group/group.repo';
|
||||||
@@ -69,7 +67,6 @@ export class WorkspaceService {
|
|||||||
@InjectQueue(QueueName.BILLING_QUEUE) private billingQueue: Queue,
|
@InjectQueue(QueueName.BILLING_QUEUE) private billingQueue: Queue,
|
||||||
@InjectQueue(QueueName.AI_QUEUE) private aiQueue: Queue,
|
@InjectQueue(QueueName.AI_QUEUE) private aiQueue: Queue,
|
||||||
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
||||||
private userSessionRepo: UserSessionRepo,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async findById(workspaceId: string) {
|
async findById(workspaceId: string) {
|
||||||
@@ -353,7 +350,7 @@ export class WorkspaceService {
|
|||||||
typeof updateWorkspaceDto.trashRetentionDays !== 'undefined' ||
|
typeof updateWorkspaceDto.trashRetentionDays !== 'undefined' ||
|
||||||
typeof updateWorkspaceDto.restrictApiToAdmins !== 'undefined'
|
typeof updateWorkspaceDto.restrictApiToAdmins !== 'undefined'
|
||||||
) {
|
) {
|
||||||
if (!this.licenseCheckService.hasFeature(ws.licenseKey, Feature.SECURITY_SETTINGS, ws.plan)) {
|
if (!this.licenseCheckService.hasFeature(ws.licenseKey, 'security:settings', ws.plan)) {
|
||||||
throw new ForbiddenException(
|
throw new ForbiddenException(
|
||||||
'This feature requires a valid license',
|
'This feature requires a valid license',
|
||||||
);
|
);
|
||||||
@@ -670,15 +667,11 @@ export class WorkspaceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await executeTx(this.db, async (trx) => {
|
await this.userRepo.updateUser(
|
||||||
await this.userRepo.updateUser(
|
{ deactivatedAt: new Date() },
|
||||||
{ deactivatedAt: new Date() },
|
userId,
|
||||||
userId,
|
workspaceId,
|
||||||
workspaceId,
|
);
|
||||||
trx,
|
|
||||||
);
|
|
||||||
await this.userSessionRepo.revokeByUserId(userId, workspaceId, trx);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.auditService.log({
|
this.auditService.log({
|
||||||
event: AuditEvent.USER_DEACTIVATED,
|
event: AuditEvent.USER_DEACTIVATED,
|
||||||
@@ -792,8 +785,6 @@ export class WorkspaceService {
|
|||||||
await this.watcherRepo.deleteByUserAndWorkspace(userId, workspaceId, {
|
await this.watcherRepo.deleteByUserAndWorkspace(userId, workspaceId, {
|
||||||
trx,
|
trx,
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.userSessionRepo.revokeByUserId(userId, workspaceId, trx);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.auditService.log({
|
this.auditService.log({
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import { KyselyDB } from '@docmost/db/types/kysely.types';
|
|||||||
import * as process from 'node:process';
|
import * as process from 'node:process';
|
||||||
import { MigrationService } from '@docmost/db/services/migration.service';
|
import { MigrationService } from '@docmost/db/services/migration.service';
|
||||||
import { UserTokenRepo } from './repos/user-token/user-token.repo';
|
import { UserTokenRepo } from './repos/user-token/user-token.repo';
|
||||||
import { UserSessionRepo } from '@docmost/db/repos/session/user-session.repo';
|
|
||||||
import { BacklinkRepo } from '@docmost/db/repos/backlink/backlink.repo';
|
import { BacklinkRepo } from '@docmost/db/repos/backlink/backlink.repo';
|
||||||
import { ShareRepo } from '@docmost/db/repos/share/share.repo';
|
import { ShareRepo } from '@docmost/db/repos/share/share.repo';
|
||||||
import { NotificationRepo } from '@docmost/db/repos/notification/notification.repo';
|
import { NotificationRepo } from '@docmost/db/repos/notification/notification.repo';
|
||||||
@@ -77,7 +76,6 @@ import { normalizePostgresUrl } from '../common/helpers';
|
|||||||
CommentRepo,
|
CommentRepo,
|
||||||
AttachmentRepo,
|
AttachmentRepo,
|
||||||
UserTokenRepo,
|
UserTokenRepo,
|
||||||
UserSessionRepo,
|
|
||||||
BacklinkRepo,
|
BacklinkRepo,
|
||||||
ShareRepo,
|
ShareRepo,
|
||||||
NotificationRepo,
|
NotificationRepo,
|
||||||
@@ -97,7 +95,6 @@ import { normalizePostgresUrl } from '../common/helpers';
|
|||||||
CommentRepo,
|
CommentRepo,
|
||||||
AttachmentRepo,
|
AttachmentRepo,
|
||||||
UserTokenRepo,
|
UserTokenRepo,
|
||||||
UserSessionRepo,
|
|
||||||
BacklinkRepo,
|
BacklinkRepo,
|
||||||
ShareRepo,
|
ShareRepo,
|
||||||
NotificationRepo,
|
NotificationRepo,
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
import { Kysely, sql } from 'kysely';
|
|
||||||
|
|
||||||
export async function up(db: Kysely<any>): Promise<void> {
|
|
||||||
await db.schema
|
|
||||||
.createTable('user_sessions')
|
|
||||||
.addColumn('id', 'uuid', (col) =>
|
|
||||||
col.primaryKey().defaultTo(sql`gen_uuid_v7()`),
|
|
||||||
)
|
|
||||||
.addColumn('user_id', 'uuid', (col) =>
|
|
||||||
col.notNull().references('users.id').onDelete('cascade'),
|
|
||||||
)
|
|
||||||
.addColumn('workspace_id', 'uuid', (col) =>
|
|
||||||
col.notNull().references('workspaces.id').onDelete('cascade'),
|
|
||||||
)
|
|
||||||
.addColumn('device_name', 'varchar')
|
|
||||||
.addColumn('user_agent', 'text')
|
|
||||||
.addColumn('ip_address', sql`inet`)
|
|
||||||
.addColumn('geo_location', 'varchar')
|
|
||||||
.addColumn('last_active_at', 'timestamptz', (col) =>
|
|
||||||
col.notNull().defaultTo(sql`now()`),
|
|
||||||
)
|
|
||||||
.addColumn('expires_at', 'timestamptz', (col) => col.notNull())
|
|
||||||
.addColumn('metadata', 'jsonb')
|
|
||||||
.addColumn('revoked_at', 'timestamptz')
|
|
||||||
.addColumn('created_at', 'timestamptz', (col) =>
|
|
||||||
col.notNull().defaultTo(sql`now()`),
|
|
||||||
)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await sql`
|
|
||||||
CREATE INDEX idx_user_sessions_active
|
|
||||||
ON user_sessions (user_id, workspace_id, last_active_at DESC)
|
|
||||||
WHERE revoked_at IS NULL
|
|
||||||
`.execute(db);
|
|
||||||
|
|
||||||
await sql`
|
|
||||||
CREATE INDEX idx_user_sessions_revoked
|
|
||||||
ON user_sessions (expires_at)
|
|
||||||
WHERE revoked_at IS NOT NULL
|
|
||||||
`.execute(db);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(db: Kysely<any>): Promise<void> {
|
|
||||||
await db.schema.dropTable('user_sessions').execute();
|
|
||||||
}
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
import {
|
|
||||||
InsertableUserSession,
|
|
||||||
UserSession,
|
|
||||||
} from '@docmost/db/types/entity.types';
|
|
||||||
import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types';
|
|
||||||
import { dbOrTx } from '@docmost/db/utils';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { InjectKysely } from 'nestjs-kysely';
|
|
||||||
import { sql } from 'kysely';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class UserSessionRepo {
|
|
||||||
constructor(@InjectKysely() private readonly db: KyselyDB) {}
|
|
||||||
|
|
||||||
async insertSession(
|
|
||||||
session: InsertableUserSession,
|
|
||||||
trx?: KyselyTransaction,
|
|
||||||
): Promise<UserSession> {
|
|
||||||
const db = dbOrTx(this.db, trx);
|
|
||||||
return db
|
|
||||||
.insertInto('userSessions')
|
|
||||||
.values(session)
|
|
||||||
.returningAll()
|
|
||||||
.executeTakeFirstOrThrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
async findActiveById(id: string): Promise<UserSession | undefined> {
|
|
||||||
return this.db
|
|
||||||
.selectFrom('userSessions')
|
|
||||||
.selectAll()
|
|
||||||
.where('id', '=', id)
|
|
||||||
.where('expiresAt', '>', new Date())
|
|
||||||
.where('revokedAt', 'is', null)
|
|
||||||
.executeTakeFirst();
|
|
||||||
}
|
|
||||||
|
|
||||||
async findActiveByUser(
|
|
||||||
userId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
): Promise<UserSession[]> {
|
|
||||||
return this.db
|
|
||||||
.selectFrom('userSessions')
|
|
||||||
.selectAll()
|
|
||||||
.where('userId', '=', userId)
|
|
||||||
.where('workspaceId', '=', workspaceId)
|
|
||||||
.where('expiresAt', '>', new Date())
|
|
||||||
.where('revokedAt', 'is', null)
|
|
||||||
.orderBy('lastActiveAt', 'desc')
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateLastActiveAt(id: string): Promise<void> {
|
|
||||||
await this.db
|
|
||||||
.updateTable('userSessions')
|
|
||||||
.set({ lastActiveAt: new Date() })
|
|
||||||
.where('id', '=', id)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async revokeById(
|
|
||||||
id: string,
|
|
||||||
userId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
): Promise<void> {
|
|
||||||
await this.db
|
|
||||||
.updateTable('userSessions')
|
|
||||||
.set({ revokedAt: new Date() })
|
|
||||||
.where('id', '=', id)
|
|
||||||
.where('userId', '=', userId)
|
|
||||||
.where('workspaceId', '=', workspaceId)
|
|
||||||
.where('revokedAt', 'is', null)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async revokeAllExceptCurrent(
|
|
||||||
currentSessionId: string,
|
|
||||||
userId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
): Promise<void> {
|
|
||||||
await this.db
|
|
||||||
.updateTable('userSessions')
|
|
||||||
.set({ revokedAt: new Date() })
|
|
||||||
.where('userId', '=', userId)
|
|
||||||
.where('workspaceId', '=', workspaceId)
|
|
||||||
.where('id', '!=', currentSessionId)
|
|
||||||
.where('revokedAt', 'is', null)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async revokeByUserId(
|
|
||||||
userId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
trx?: KyselyTransaction,
|
|
||||||
): Promise<void> {
|
|
||||||
const db = dbOrTx(this.db, trx);
|
|
||||||
await db
|
|
||||||
.updateTable('userSessions')
|
|
||||||
.set({ revokedAt: new Date() })
|
|
||||||
.where('userId', '=', userId)
|
|
||||||
.where('workspaceId', '=', workspaceId)
|
|
||||||
.where('revokedAt', 'is', null)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteByUserId(
|
|
||||||
userId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
): Promise<void> {
|
|
||||||
await this.db
|
|
||||||
.deleteFrom('userSessions')
|
|
||||||
.where('userId', '=', userId)
|
|
||||||
.where('workspaceId', '=', workspaceId)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteAllExceptCurrent(
|
|
||||||
currentSessionId: string,
|
|
||||||
userId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
): Promise<void> {
|
|
||||||
await this.db
|
|
||||||
.deleteFrom('userSessions')
|
|
||||||
.where('userId', '=', userId)
|
|
||||||
.where('workspaceId', '=', workspaceId)
|
|
||||||
.where('id', '!=', currentSessionId)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteStale(retentionDays: number): Promise<void> {
|
|
||||||
const cutoff = new Date(Date.now() - retentionDays * 24 * 60 * 60 * 1000);
|
|
||||||
await this.db
|
|
||||||
.deleteFrom('userSessions')
|
|
||||||
.where((eb) =>
|
|
||||||
eb.or([
|
|
||||||
eb('revokedAt', '<', cutoff),
|
|
||||||
eb('expiresAt', '<', cutoff),
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
async trimExcessSessions(maxPerUser: number): Promise<void> {
|
|
||||||
const overflowed = await this.db
|
|
||||||
.selectFrom('userSessions')
|
|
||||||
.select(['userId', 'workspaceId'])
|
|
||||||
.groupBy(['userId', 'workspaceId'])
|
|
||||||
.having(sql`COUNT(*)`, '>', maxPerUser)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
for (const { userId, workspaceId } of overflowed) {
|
|
||||||
await sql`
|
|
||||||
DELETE FROM user_sessions
|
|
||||||
WHERE id IN (
|
|
||||||
SELECT id FROM user_sessions
|
|
||||||
WHERE user_id = ${userId} AND workspace_id = ${workspaceId}
|
|
||||||
ORDER BY last_active_at DESC
|
|
||||||
OFFSET ${maxPerUser}
|
|
||||||
)
|
|
||||||
`.execute(this.db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -111,28 +111,6 @@ export class SpaceRepo {
|
|||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateCommentSettings(
|
|
||||||
spaceId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
prefKey: string,
|
|
||||||
prefValue: string | boolean,
|
|
||||||
trx?: KyselyTransaction,
|
|
||||||
) {
|
|
||||||
const db = dbOrTx(this.db, trx);
|
|
||||||
return db
|
|
||||||
.updateTable('spaces')
|
|
||||||
.set({
|
|
||||||
settings: sql`COALESCE(settings, '{}'::jsonb)
|
|
||||||
|| jsonb_build_object('comments', COALESCE(settings->'comments', '{}'::jsonb)
|
|
||||||
|| jsonb_build_object('${sql.raw(prefKey)}', ${sql.lit(prefValue)}))`,
|
|
||||||
updatedAt: new Date(),
|
|
||||||
})
|
|
||||||
.where('id', '=', spaceId)
|
|
||||||
.where('workspaceId', '=', workspaceId)
|
|
||||||
.returningAll()
|
|
||||||
.executeTakeFirst();
|
|
||||||
}
|
|
||||||
|
|
||||||
async insertSpace(
|
async insertSpace(
|
||||||
insertableSpace: InsertableSpace,
|
insertableSpace: InsertableSpace,
|
||||||
trx?: KyselyTransaction,
|
trx?: KyselyTransaction,
|
||||||
|
|||||||
-16
@@ -429,21 +429,6 @@ export interface PagePermissions {
|
|||||||
updatedAt: Generated<Timestamp>;
|
updatedAt: Generated<Timestamp>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserSessions {
|
|
||||||
id: Generated<string>;
|
|
||||||
userId: string;
|
|
||||||
workspaceId: string;
|
|
||||||
deviceName: string | null;
|
|
||||||
userAgent: string | null;
|
|
||||||
ipAddress: string | null;
|
|
||||||
geoLocation: string | null;
|
|
||||||
metadata: Json | null;
|
|
||||||
lastActiveAt: Generated<Timestamp>;
|
|
||||||
expiresAt: Timestamp;
|
|
||||||
revokedAt: Timestamp | null;
|
|
||||||
createdAt: Generated<Timestamp>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DB {
|
export interface DB {
|
||||||
apiKeys: ApiKeys;
|
apiKeys: ApiKeys;
|
||||||
attachments: Attachments;
|
attachments: Attachments;
|
||||||
@@ -466,7 +451,6 @@ export interface DB {
|
|||||||
spaces: Spaces;
|
spaces: Spaces;
|
||||||
userMfa: UserMfa;
|
userMfa: UserMfa;
|
||||||
users: Users;
|
users: Users;
|
||||||
userSessions: UserSessions;
|
|
||||||
userTokens: UserTokens;
|
userTokens: UserTokens;
|
||||||
watchers: Watchers;
|
watchers: Watchers;
|
||||||
workspaceInvitations: WorkspaceInvitations;
|
workspaceInvitations: WorkspaceInvitations;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import {
|
|||||||
Shares,
|
Shares,
|
||||||
FileTasks,
|
FileTasks,
|
||||||
UserMfa as _UserMFA,
|
UserMfa as _UserMFA,
|
||||||
UserSessions,
|
|
||||||
ApiKeys,
|
ApiKeys,
|
||||||
Watchers,
|
Watchers,
|
||||||
Audit as _Audit,
|
Audit as _Audit,
|
||||||
@@ -158,11 +157,6 @@ export type PagePermission = Selectable<_PagePermissions>;
|
|||||||
export type InsertablePagePermission = Insertable<_PagePermissions>;
|
export type InsertablePagePermission = Insertable<_PagePermissions>;
|
||||||
export type UpdatablePagePermission = Updateable<Omit<_PagePermissions, 'id'>>;
|
export type UpdatablePagePermission = Updateable<Omit<_PagePermissions, 'id'>>;
|
||||||
|
|
||||||
// User Session
|
|
||||||
export type UserSession = Selectable<UserSessions>;
|
|
||||||
export type InsertableUserSession = Insertable<UserSessions>;
|
|
||||||
export type UpdatableUserSession = Updateable<Omit<UserSessions, 'id'>>;
|
|
||||||
|
|
||||||
// Audit
|
// Audit
|
||||||
export type Audit = Selectable<_Audit>;
|
export type Audit = Selectable<_Audit>;
|
||||||
export type InsertableAudit = Insertable<_Audit>;
|
export type InsertableAudit = Insertable<_Audit>;
|
||||||
|
|||||||
+1
-1
Submodule apps/server/src/ee updated: c70a29cb25...8b21c6e32e
@@ -28,7 +28,8 @@ import { PageRepo } from '@docmost/db/repos/page/page.repo';
|
|||||||
import { PagePermissionRepo } from '@docmost/db/repos/page/page-permission.repo';
|
import { PagePermissionRepo } from '@docmost/db/repos/page/page-permission.repo';
|
||||||
import { Node } from '@tiptap/pm/model';
|
import { Node } from '@tiptap/pm/model';
|
||||||
import { EditorState } from '@tiptap/pm/state';
|
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
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
const packageJson = require('../../../package.json');
|
const packageJson = require('../../../package.json');
|
||||||
import { EnvironmentService } from '../environment/environment.service';
|
import { EnvironmentService } from '../environment/environment.service';
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import {
|
|||||||
buildAttachmentCandidates,
|
buildAttachmentCandidates,
|
||||||
collectMarkdownAndHtmlFiles,
|
collectMarkdownAndHtmlFiles,
|
||||||
encodeFilePath,
|
encodeFilePath,
|
||||||
extractNotionPartialId,
|
|
||||||
readDocmostMetadata,
|
readDocmostMetadata,
|
||||||
stripNotionID,
|
stripNotionID,
|
||||||
} from '../utils/import.utils';
|
} from '../utils/import.utils';
|
||||||
@@ -161,7 +160,6 @@ export class FileImportTaskService {
|
|||||||
fileTask: FileTask;
|
fileTask: FileTask;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const { extractDir, fileTask } = opts;
|
const { extractDir, fileTask } = opts;
|
||||||
const isNotion = fileTask.source === FileImportSource.Notion;
|
|
||||||
const allFiles = await collectMarkdownAndHtmlFiles(extractDir);
|
const allFiles = await collectMarkdownAndHtmlFiles(extractDir);
|
||||||
const attachmentCandidates = await buildAttachmentCandidates(extractDir);
|
const attachmentCandidates = await buildAttachmentCandidates(extractDir);
|
||||||
const docmostMetadata = await readDocmostMetadata(extractDir);
|
const docmostMetadata = await readDocmostMetadata(extractDir);
|
||||||
@@ -232,17 +230,7 @@ export class FileImportTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For each folder with content, create a placeholder page if no corresponding .md or .html exists
|
// For each folder with content, create a placeholder page if no corresponding .md or .html exists
|
||||||
// Process folders with partial UUIDs first so they claim their specific files
|
foldersWithContent.forEach((folderPath) => {
|
||||||
// before plain folders (without partial UUIDs) take whatever remains.
|
|
||||||
const sortedFolders = isNotion
|
|
||||||
? [...foldersWithContent].sort((a, b) => {
|
|
||||||
const aHasPartial = extractNotionPartialId(path.basename(a)) ? 0 : 1;
|
|
||||||
const bHasPartial = extractNotionPartialId(path.basename(b)) ? 0 : 1;
|
|
||||||
return aHasPartial - bHasPartial;
|
|
||||||
})
|
|
||||||
: [...foldersWithContent];
|
|
||||||
|
|
||||||
sortedFolders.forEach((folderPath) => {
|
|
||||||
if (
|
if (
|
||||||
skipRootFolder &&
|
skipRootFolder &&
|
||||||
folderPath?.toLowerCase() === skipRootFolder?.toLowerCase()
|
folderPath?.toLowerCase() === skipRootFolder?.toLowerCase()
|
||||||
@@ -255,54 +243,18 @@ export class FileImportTaskService {
|
|||||||
|
|
||||||
if (!pagesMap.has(mdPath) && !pagesMap.has(htmlPath)) {
|
if (!pagesMap.has(mdPath) && !pagesMap.has(htmlPath)) {
|
||||||
const folderName = path.basename(folderPath);
|
const folderName = path.basename(folderPath);
|
||||||
const parentDir = path.dirname(folderPath);
|
const encodedMdPath = encodeFilePath(mdPath);
|
||||||
|
const placeholderMetadata = docmostMetadata?.pages[encodedMdPath];
|
||||||
// Notion no longer adds UUIDs to folder names, but still adds them to files.
|
pagesMap.set(mdPath, {
|
||||||
// For duplicate names, Notion adds a partial UUID "{first4}-{last4}" to the folder.
|
id: v7(),
|
||||||
let matched = false;
|
slugId: generateSlugId(),
|
||||||
if (isNotion) {
|
name: stripNotionID(folderName),
|
||||||
const partialId = extractNotionPartialId(folderName);
|
content: '',
|
||||||
const strippedFolderName = stripNotionID(folderName);
|
parentPageId: null,
|
||||||
const isSameDir = (fileDir: string) =>
|
fileExtension: '.md',
|
||||||
fileDir === parentDir || (parentDir === '.' && !fileDir.includes('/'));
|
filePath: mdPath,
|
||||||
|
icon: placeholderMetadata?.icon ?? null,
|
||||||
for (const [filePath, page] of pagesMap.entries()) {
|
});
|
||||||
if (!isSameDir(path.dirname(filePath))) continue;
|
|
||||||
if (page.name !== strippedFolderName) continue;
|
|
||||||
|
|
||||||
if (partialId) {
|
|
||||||
// Match partial UUID against the full UUID in the filename
|
|
||||||
const fileBase = path.basename(filePath, path.extname(filePath));
|
|
||||||
const fullIdMatch = fileBase.match(/[a-f0-9]{32}$/i);
|
|
||||||
if (!fullIdMatch) continue;
|
|
||||||
const fullId = fullIdMatch[0].toLowerCase();
|
|
||||||
if (!fullId.startsWith(partialId.prefix) || !fullId.endsWith(partialId.suffix)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pagesMap.delete(filePath);
|
|
||||||
page.filePath = mdPath;
|
|
||||||
pagesMap.set(mdPath, page);
|
|
||||||
matched = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!matched) {
|
|
||||||
const encodedMdPath = encodeFilePath(mdPath);
|
|
||||||
const placeholderMetadata = docmostMetadata?.pages[encodedMdPath];
|
|
||||||
pagesMap.set(mdPath, {
|
|
||||||
id: v7(),
|
|
||||||
slugId: generateSlugId(),
|
|
||||||
name: stripNotionID(folderName),
|
|
||||||
content: '',
|
|
||||||
parentPageId: null,
|
|
||||||
fileExtension: '.md',
|
|
||||||
filePath: mdPath,
|
|
||||||
icon: placeholderMetadata?.icon ?? null,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { getEmbedUrlAndProvider } from '@docmost/editor-ext';
|
import { getEmbedUrlAndProvider } from '@docmost/editor-ext';
|
||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { v7 } from 'uuid';
|
|
||||||
import { InsertableBacklink } from '@docmost/db/types/entity.types';
|
import { InsertableBacklink } from '@docmost/db/types/entity.types';
|
||||||
import { Cheerio, CheerioAPI, load } from 'cheerio';
|
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)
|
// Check if text contains Unicode characters (for emojis/icons)
|
||||||
function isUnicodeCharacter(text: string): boolean {
|
function isUnicodeCharacter(text: string): boolean {
|
||||||
@@ -344,35 +344,14 @@ export async function rewriteInternalLinksToMentionHtml(
|
|||||||
const meta = filePathToPageMetaMap.get(resolved);
|
const meta = filePathToPageMetaMap.get(resolved);
|
||||||
if (!meta) return;
|
if (!meta) return;
|
||||||
|
|
||||||
const linkText = $a.text().trim();
|
const titleSlug = slugify(meta.title?.substring(0, 70) || 'untitled');
|
||||||
const titleMatch =
|
const pageSlug = `${titleSlug}-${meta.slugId}`;
|
||||||
linkText === meta.title ||
|
const internalHref = spaceSlug
|
||||||
linkText === meta.title?.trim();
|
? `/s/${spaceSlug}/p/${pageSlug}`
|
||||||
|
: `/p/${pageSlug}`;
|
||||||
|
|
||||||
if (titleMatch) {
|
$a.attr('href', internalHref);
|
||||||
const mentionId = v7();
|
$a.attr('data-internal', 'true');
|
||||||
const $mention = $('<span>')
|
|
||||||
.attr({
|
|
||||||
'data-type': 'mention',
|
|
||||||
'data-id': mentionId,
|
|
||||||
'data-entity-type': 'page',
|
|
||||||
'data-entity-id': meta.id,
|
|
||||||
'data-label': meta.title,
|
|
||||||
'data-slug-id': meta.slugId,
|
|
||||||
'data-creator-id': creatorId,
|
|
||||||
})
|
|
||||||
.text(meta.title);
|
|
||||||
$a.replaceWith($mention);
|
|
||||||
} else {
|
|
||||||
const titleSlug = slugify(meta.title?.substring(0, 70) || 'untitled');
|
|
||||||
const pageSlug = `${titleSlug}-${meta.slugId}`;
|
|
||||||
const internalHref = spaceSlug
|
|
||||||
? `/s/${spaceSlug}/p/${pageSlug}`
|
|
||||||
: `/p/${pageSlug}`;
|
|
||||||
|
|
||||||
$a.attr('href', internalHref);
|
|
||||||
$a.attr('data-internal', 'true');
|
|
||||||
}
|
|
||||||
|
|
||||||
backlinks.push({ sourcePageId, targetPageId: meta.id, workspaceId });
|
backlinks.push({ sourcePageId, targetPageId: meta.id, workspaceId });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -81,25 +81,7 @@ export async function collectMarkdownAndHtmlFiles(
|
|||||||
export function stripNotionID(fileName: string): string {
|
export function stripNotionID(fileName: string): string {
|
||||||
// Handle optional separator (space or dash) + 32 alphanumeric chars at end
|
// Handle optional separator (space or dash) + 32 alphanumeric chars at end
|
||||||
const notionIdPattern = /[ -]?[a-z0-9]{32}$/i;
|
const notionIdPattern = /[ -]?[a-z0-9]{32}$/i;
|
||||||
// Handle partial UUID format used for duplicate names: "Name abcd-ef12"
|
return fileName.replace(notionIdPattern, '').trim();
|
||||||
const partialIdPattern = / [a-f0-9]{4}-[a-f0-9]{4}$/i;
|
|
||||||
return fileName
|
|
||||||
.replace(notionIdPattern, '')
|
|
||||||
.replace(partialIdPattern, '')
|
|
||||||
.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract a partial Notion UUID suffix from a folder name.
|
|
||||||
* Notion adds "{first4}-{last4}" when multiple pages share the same title.
|
|
||||||
* e.g. "Cool 324d-35ab" → { prefix: "324d", suffix: "35ab" }
|
|
||||||
*/
|
|
||||||
export function extractNotionPartialId(
|
|
||||||
folderName: string,
|
|
||||||
): { prefix: string; suffix: string } | null {
|
|
||||||
const match = folderName.match(/ ([a-f0-9]{4})-([a-f0-9]{4})$/i);
|
|
||||||
if (!match) return null;
|
|
||||||
return { prefix: match[1].toLowerCase(), suffix: match[2].toLowerCase() };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function encodeFilePath(filePath: string): string {
|
export function encodeFilePath(filePath: string): string {
|
||||||
|
|||||||
@@ -71,10 +71,7 @@ export class StaticModule implements OnModuleInit {
|
|||||||
|
|
||||||
app.get(RENDER_PATH, (req: any, res: any) => {
|
app.get(RENDER_PATH, (req: any, res: any) => {
|
||||||
const stream = fs.createReadStream(indexFilePath);
|
const stream = fs.createReadStream(indexFilePath);
|
||||||
res
|
res.type('text/html').send(stream);
|
||||||
.header('Cache-Control', 'no-cache, no-store, must-revalidate')
|
|
||||||
.type('text/html')
|
|
||||||
.send(stream);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,10 +65,12 @@ export class WsGateway
|
|||||||
async handleMessage(client: Socket, data: any): Promise<void> {
|
async handleMessage(client: Socket, data: any): Promise<void> {
|
||||||
if (this.wsService.isTreeEvent(data)) {
|
if (this.wsService.isTreeEvent(data)) {
|
||||||
await this.wsService.handleTreeEvent(client, data);
|
await this.wsService.handleTreeEvent(client, data);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.broadcast.emit('message', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@SubscribeMessage('join-room')
|
@SubscribeMessage('join-room')
|
||||||
handleJoinRoom(client: Socket, @MessageBody() roomName: string): void {
|
handleJoinRoom(client: Socket, @MessageBody() roomName: string): void {
|
||||||
// if room is a space, check if user has permissions
|
// if room is a space, check if user has permissions
|
||||||
@@ -79,7 +81,6 @@ export class WsGateway
|
|||||||
handleLeaveRoom(client: Socket, @MessageBody() roomName: string): void {
|
handleLeaveRoom(client: Socket, @MessageBody() roomName: string): void {
|
||||||
client.leave(roomName);
|
client.leave(roomName);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
onModuleDestroy() {
|
onModuleDestroy() {
|
||||||
if (this.server) {
|
if (this.server) {
|
||||||
|
|||||||
@@ -27,15 +27,6 @@ export class WsService {
|
|||||||
async handleTreeEvent(client: Socket, data: any): Promise<void> {
|
async handleTreeEvent(client: Socket, data: any): Promise<void> {
|
||||||
const room = getSpaceRoomName(data.spaceId);
|
const room = getSpaceRoomName(data.spaceId);
|
||||||
|
|
||||||
if (!client.rooms.has(room)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.operation === 'refetchRootTreeNodeEvent') {
|
|
||||||
client.broadcast.to(room).emit('message', data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasRestrictions = await this.spaceHasRestrictions(data.spaceId);
|
const hasRestrictions = await this.spaceHasRestrictions(data.spaceId);
|
||||||
if (!hasRestrictions) {
|
if (!hasRestrictions) {
|
||||||
client.broadcast.to(room).emit('message', data);
|
client.broadcast.to(room).emit('message', data);
|
||||||
|
|||||||
@@ -14,5 +14,4 @@ export const TREE_EVENTS = new Set([
|
|||||||
'addTreeNode',
|
'addTreeNode',
|
||||||
'moveTreeNode',
|
'moveTreeNode',
|
||||||
'deleteTreeNode',
|
'deleteTreeNode',
|
||||||
'refetchRootTreeNodeEvent',
|
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -17,6 +17,5 @@
|
|||||||
},
|
},
|
||||||
"affected": {
|
"affected": {
|
||||||
"defaultBase": "main"
|
"defaultBase": "main"
|
||||||
},
|
}
|
||||||
"analytics": false
|
|
||||||
}
|
}
|
||||||
+64
-67
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "docmost",
|
"name": "docmost",
|
||||||
"homepage": "https://docmost.com",
|
"homepage": "https://docmost.com",
|
||||||
"version": "0.70.3",
|
"version": "0.70.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nx run-many -t build",
|
"build": "nx run-many -t build",
|
||||||
@@ -19,71 +19,73 @@
|
|||||||
"clean": "rm -rf apps/*/dist packages/*/dist apps/client/node_modules/.vite"
|
"clean": "rm -rf apps/*/dist packages/*/dist apps/client/node_modules/.vite"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braintree/sanitize-url": "^7.1.2",
|
"@braintree/sanitize-url": "^7.1.0",
|
||||||
"@casl/ability": "6.8.0",
|
"@casl/ability": "6.8.0",
|
||||||
"@docmost/editor-ext": "workspace:*",
|
"@docmost/editor-ext": "workspace:*",
|
||||||
"@floating-ui/dom": "^1.7.3",
|
"@floating-ui/dom": "^1.7.3",
|
||||||
"@hocuspocus/provider": "3.4.4",
|
"@hocuspocus/provider": "3.4.4",
|
||||||
"@hocuspocus/server": "3.4.4",
|
"@hocuspocus/server": "3.4.4",
|
||||||
"@hocuspocus/transformer": "3.4.4",
|
"@hocuspocus/transformer": "3.4.4",
|
||||||
"@joplin/turndown": "^4.0.82",
|
"@joplin/turndown": "^4.0.74",
|
||||||
"@joplin/turndown-plugin-gfm": "^1.0.64",
|
"@joplin/turndown-plugin-gfm": "^1.0.56",
|
||||||
"@sindresorhus/slugify": "3.0.0",
|
"@sindresorhus/slugify": "1.1.0",
|
||||||
"@tiptap/core": "3.20.4",
|
"@tiptap/core": "3.17.1",
|
||||||
"@tiptap/extension-code-block": "3.20.4",
|
"@tiptap/extension-code-block": "3.17.1",
|
||||||
"@tiptap/extension-collaboration": "3.20.4",
|
"@tiptap/extension-collaboration": "3.17.1",
|
||||||
"@tiptap/extension-collaboration-caret": "3.20.4",
|
"@tiptap/extension-collaboration-caret": "3.17.1",
|
||||||
"@tiptap/extension-color": "3.20.4",
|
"@tiptap/extension-color": "3.17.1",
|
||||||
"@tiptap/extension-document": "3.20.4",
|
"@tiptap/extension-document": "3.17.1",
|
||||||
"@tiptap/extension-heading": "3.20.4",
|
"@tiptap/extension-heading": "3.17.1",
|
||||||
"@tiptap/extension-highlight": "3.20.4",
|
"@tiptap/extension-highlight": "3.17.1",
|
||||||
"@tiptap/extension-history": "3.20.4",
|
"@tiptap/extension-history": "3.17.1",
|
||||||
"@tiptap/extension-image": "3.20.4",
|
"@tiptap/extension-image": "3.17.1",
|
||||||
"@tiptap/extension-link": "3.20.4",
|
"@tiptap/extension-link": "3.17.1",
|
||||||
"@tiptap/extension-list": "3.20.4",
|
"@tiptap/extension-list": "3.17.1",
|
||||||
"@tiptap/extension-placeholder": "3.20.4",
|
"@tiptap/extension-placeholder": "3.17.1",
|
||||||
"@tiptap/extension-subscript": "3.20.4",
|
"@tiptap/extension-subscript": "3.17.1",
|
||||||
"@tiptap/extension-superscript": "3.20.4",
|
"@tiptap/extension-superscript": "3.17.1",
|
||||||
"@tiptap/extension-table": "3.20.4",
|
"@tiptap/extension-table": "3.17.1",
|
||||||
"@tiptap/extension-text": "3.20.4",
|
"@tiptap/extension-text": "3.17.1",
|
||||||
"@tiptap/extension-text-align": "3.20.4",
|
"@tiptap/extension-text-align": "3.17.1",
|
||||||
"@tiptap/extension-text-style": "3.20.4",
|
"@tiptap/extension-text-style": "3.17.1",
|
||||||
"@tiptap/extension-typography": "3.20.4",
|
"@tiptap/extension-typography": "3.17.1",
|
||||||
"@tiptap/extension-unique-id": "3.20.4",
|
"@tiptap/extension-unique-id": "^3.17.1",
|
||||||
"@tiptap/extension-youtube": "3.20.4",
|
"@tiptap/extension-youtube": "3.17.1",
|
||||||
"@tiptap/html": "3.20.4",
|
"@tiptap/html": "3.17.1",
|
||||||
"@tiptap/pm": "3.20.4",
|
"@tiptap/pm": "3.17.1",
|
||||||
"@tiptap/react": "3.20.4",
|
"@tiptap/react": "3.17.1",
|
||||||
"@tiptap/starter-kit": "3.20.4",
|
"@tiptap/starter-kit": "3.17.1",
|
||||||
"@tiptap/suggestion": "3.20.4",
|
"@tiptap/suggestion": "3.17.1",
|
||||||
"@tiptap/y-tiptap": "3.0.2",
|
"@tiptap/y-tiptap": "^3.0.2",
|
||||||
|
"@types/qrcode": "^1.5.5",
|
||||||
"bytes": "^3.1.2",
|
"bytes": "^3.1.2",
|
||||||
"cross-env": "^10.1.0",
|
"cross-env": "^7.0.3",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"diff": "8.0.3",
|
"diff": "8.0.3",
|
||||||
"dompurify": "^3.3.3",
|
"dompurify": "^3.3.1",
|
||||||
"fractional-indexing-jittered": "^1.0.0",
|
"fractional-indexing-jittered": "^1.0.0",
|
||||||
"highlight.js": "^11.11.1",
|
"highlight.js": "^11.11.1",
|
||||||
"image-dimensions": "^2.5.0",
|
"image-dimensions": "^2.5.0",
|
||||||
|
"ioredis": "^5.4.1",
|
||||||
"jszip": "^3.10.1",
|
"jszip": "^3.10.1",
|
||||||
"linkifyjs": "^4.3.2",
|
"linkifyjs": "^4.3.2",
|
||||||
"marked": "17.0.5",
|
"marked": "13.0.3",
|
||||||
"ms": "3.0.0-canary.1",
|
"ms": "3.0.0-canary.1",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"rfc6902": "5.2.0",
|
"rfc6902": "5.1.2",
|
||||||
"uuid": "^13.0.0",
|
"uuid": "^11.1.0",
|
||||||
"y-indexeddb": "^9.0.12",
|
"y-indexeddb": "^9.0.12",
|
||||||
"y-prosemirror": "1.3.7",
|
"y-prosemirror": "1.3.7",
|
||||||
"yjs": "^13.6.30"
|
"yjs": "^13.6.29"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nx/js": "22.6.1",
|
"@nx/js": "22.5.3",
|
||||||
"@types/bytes": "^3.1.5",
|
"@types/bytes": "^3.1.5",
|
||||||
"@types/qrcode": "^1.5.6",
|
|
||||||
"@types/turndown": "^5.0.6",
|
"@types/turndown": "^5.0.6",
|
||||||
"concurrently": "^9.2.1",
|
"@types/uuid": "^10.0.0",
|
||||||
"nx": "22.6.1",
|
"concurrently": "^9.1.2",
|
||||||
"tsx": "^4.21.0"
|
"nx": "22.5.3",
|
||||||
|
"tsx": "^4.19.3"
|
||||||
},
|
},
|
||||||
"workspaces": {
|
"workspaces": {
|
||||||
"packages": [
|
"packages": [
|
||||||
@@ -98,33 +100,28 @@
|
|||||||
"@tiptap/core": "patches/@tiptap__core.patch"
|
"@tiptap/core": "patches/@tiptap__core.patch"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"prosemirror-changeset": "2.4.0",
|
"jsdom": "25.0.1",
|
||||||
|
"jsonwebtoken": "9.0.3",
|
||||||
|
"prosemirror-changeset": "2.3.1",
|
||||||
"y-prosemirror": "1.3.7",
|
"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",
|
"ws": "8.19.0",
|
||||||
"dompurify": "3.3.3",
|
"cross-spawn": "7.0.5",
|
||||||
|
"dompurify": "3.3.1",
|
||||||
"tmp": "0.2.5",
|
"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",
|
"lodash-es": "4.17.23",
|
||||||
"@hono/node-server": "1.19.10",
|
"markdown-it": "14.1.1",
|
||||||
"undici": "7.24.0",
|
"@tiptap/core": "3.17.1",
|
||||||
"ajv@^6": "6.14.0",
|
"@tiptap/pm": "3.17.1",
|
||||||
"ajv@^8": "8.18.0",
|
"@tiptap/starter-kit": "3.17.1",
|
||||||
"underscore": "1.13.8",
|
"@tiptap/extension-blockquote": "3.17.1",
|
||||||
"immutable": "4.3.8",
|
"@tiptap/extension-bold": "3.17.0",
|
||||||
"express-rate-limit": "8.2.2",
|
"@tiptap/extension-bubble-menu": "3.17.1",
|
||||||
"minimatch@^3": "3.1.5",
|
"@tiptap/extension-bullet-list": "3.17.1",
|
||||||
"minimatch@^5": "5.1.8",
|
"@tiptap/extension-list": "3.17.1",
|
||||||
"flatted": "3.4.2",
|
"@tiptap/extension-code": "3.17.1"
|
||||||
"picomatch@<2.3.2": "2.3.2",
|
|
||||||
"picomatch@>=4.0.0 <4.0.4": "4.0.4",
|
|
||||||
"fastify": "5.8.3",
|
|
||||||
"yaml@>=1.0.0 <1.10.3": "1.10.3",
|
|
||||||
"yaml@>=2.0.0 <2.8.3": "2.8.3"
|
|
||||||
},
|
},
|
||||||
"neverBuiltDependencies": []
|
"neverBuiltDependencies": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Node, mergeAttributes } from "@tiptap/core";
|
import { Node, mergeAttributes } from "@tiptap/core";
|
||||||
import { ReactNodeViewRenderer } from "@tiptap/react";
|
import { ReactNodeViewRenderer } from "@tiptap/react";
|
||||||
import { sanitizeUrl } from "../utils";
|
|
||||||
|
|
||||||
export interface AttachmentOptions {
|
export interface AttachmentOptions {
|
||||||
HTMLAttributes: Record<string, any>;
|
HTMLAttributes: Record<string, any>;
|
||||||
@@ -43,12 +42,9 @@ export const Attachment = Node.create<AttachmentOptions>({
|
|||||||
return {
|
return {
|
||||||
url: {
|
url: {
|
||||||
default: "",
|
default: "",
|
||||||
parseHTML: (element) => {
|
parseHTML: (element) => element.getAttribute("data-attachment-url"),
|
||||||
const url = element.getAttribute("data-attachment-url");
|
|
||||||
return sanitizeUrl(url);
|
|
||||||
},
|
|
||||||
renderHTML: (attributes) => ({
|
renderHTML: (attributes) => ({
|
||||||
"data-attachment-url": sanitizeUrl(attributes.url),
|
"data-attachment-url": attributes.url,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
@@ -105,7 +101,7 @@ export const Attachment = Node.create<AttachmentOptions>({
|
|||||||
[
|
[
|
||||||
"a",
|
"a",
|
||||||
{
|
{
|
||||||
href: sanitizeUrl(HTMLAttributes["data-attachment-url"]),
|
href: HTMLAttributes["data-attachment-url"],
|
||||||
class: "attachment",
|
class: "attachment",
|
||||||
target: "blank",
|
target: "blank",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,111 +1,80 @@
|
|||||||
import { findChildren } from '@tiptap/core';
|
import { findChildren } from '@tiptap/core'
|
||||||
import type { Node as ProsemirrorNode } from '@tiptap/pm/model';
|
import type { Node as ProsemirrorNode } from '@tiptap/pm/model'
|
||||||
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
import { Plugin, PluginKey } from '@tiptap/pm/state'
|
||||||
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
import { Decoration, DecorationSet } from '@tiptap/pm/view'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import highlight from 'highlight.js/lib/core';
|
import highlight from 'highlight.js/lib/core'
|
||||||
|
|
||||||
function parseNodes(
|
function parseNodes(nodes: any[], className: string[] = []): { text: string; classes: string[] }[] {
|
||||||
nodes: any[],
|
|
||||||
className: string[] = [],
|
|
||||||
): { text: string; classes: string[] }[] {
|
|
||||||
return nodes
|
return nodes
|
||||||
.map((node) => {
|
.map(node => {
|
||||||
const classes = [
|
const classes = [...className, ...(node.properties ? node.properties.className : [])]
|
||||||
...className,
|
|
||||||
...(node.properties ? node.properties.className : []),
|
|
||||||
];
|
|
||||||
|
|
||||||
if (node.children) {
|
if (node.children) {
|
||||||
return parseNodes(node.children, classes);
|
return parseNodes(node.children, classes)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
text: node.value,
|
text: node.value,
|
||||||
classes,
|
classes,
|
||||||
};
|
}
|
||||||
})
|
})
|
||||||
.flat();
|
.flat()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHighlightNodes(result: any) {
|
function getHighlightNodes(result: any) {
|
||||||
// `.value` for lowlight v1, `.children` for lowlight v2
|
// `.value` for lowlight v1, `.children` for lowlight v2
|
||||||
return result.value || result.children || [];
|
return result.value || result.children || []
|
||||||
}
|
}
|
||||||
|
|
||||||
function registered(aliasOrLanguage: string) {
|
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({
|
function getDecorations({
|
||||||
doc,
|
doc,
|
||||||
name,
|
name,
|
||||||
lowlight,
|
lowlight,
|
||||||
defaultLanguage,
|
defaultLanguage,
|
||||||
}: {
|
}: {
|
||||||
doc: ProsemirrorNode;
|
doc: ProsemirrorNode
|
||||||
name: string;
|
name: string
|
||||||
lowlight: any;
|
lowlight: any
|
||||||
defaultLanguage: string | null | undefined;
|
defaultLanguage: string | null | undefined
|
||||||
}) {
|
}) {
|
||||||
const decorations: Decoration[] = [];
|
const decorations: Decoration[] = []
|
||||||
|
|
||||||
findChildren(doc, (node) => node.type.name === name).forEach((block) => {
|
findChildren(doc, node => node.type.name === name).forEach(block => {
|
||||||
let from = block.pos + 1;
|
let from = block.pos + 1
|
||||||
const language = block.node.attrs.language || defaultLanguage;
|
const language = block.node.attrs.language || defaultLanguage
|
||||||
const languages = lowlight.listLanguages();
|
const languages = lowlight.listLanguages()
|
||||||
const textContent = block.node.textContent;
|
|
||||||
|
|
||||||
let nodes;
|
const nodes =
|
||||||
if (
|
language && (languages.includes(language) || registered(language) || lowlight.registered?.(language))
|
||||||
language &&
|
? getHighlightNodes(lowlight.highlight(language, block.node.textContent))
|
||||||
(languages.includes(language) ||
|
: getHighlightNodes(lowlight.highlightAuto(block.node.textContent))
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parseNodes(nodes).forEach((node) => {
|
parseNodes(nodes).forEach(node => {
|
||||||
const to = from + node.text.length;
|
const to = from + node.text.length
|
||||||
|
|
||||||
if (node.classes.length) {
|
if (node.classes.length) {
|
||||||
const decoration = Decoration.inline(from, to, {
|
const decoration = Decoration.inline(from, to, {
|
||||||
class: node.classes.join(' '),
|
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
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||||
function isFunction(param: any): param is Function {
|
function isFunction(param: any): param is Function {
|
||||||
return typeof param === 'function';
|
return typeof param === 'function'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LowlightPlugin({
|
export function LowlightPlugin({
|
||||||
@@ -113,18 +82,12 @@ export function LowlightPlugin({
|
|||||||
lowlight,
|
lowlight,
|
||||||
defaultLanguage,
|
defaultLanguage,
|
||||||
}: {
|
}: {
|
||||||
name: string;
|
name: string
|
||||||
lowlight: any;
|
lowlight: any
|
||||||
defaultLanguage: string | null | undefined;
|
defaultLanguage: string | null | undefined
|
||||||
}) {
|
}) {
|
||||||
if (
|
if (!['highlight', 'highlightAuto', 'listLanguages'].every(api => isFunction(lowlight[api]))) {
|
||||||
!['highlight', 'highlightAuto', 'listLanguages'].every((api) =>
|
throw Error('You should provide an instance of lowlight to use the code-block-lowlight extension')
|
||||||
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({
|
const lowlightPlugin: Plugin<any> = new Plugin({
|
||||||
@@ -139,16 +102,10 @@ export function LowlightPlugin({
|
|||||||
defaultLanguage,
|
defaultLanguage,
|
||||||
}),
|
}),
|
||||||
apply: (transaction, decorationSet, oldState, newState) => {
|
apply: (transaction, decorationSet, oldState, newState) => {
|
||||||
const oldNodeName = oldState.selection.$head.parent.type.name;
|
const oldNodeName = oldState.selection.$head.parent.type.name
|
||||||
const newNodeName = newState.selection.$head.parent.type.name;
|
const newNodeName = newState.selection.$head.parent.type.name
|
||||||
const oldNodes = findChildren(
|
const oldNodes = findChildren(oldState.doc, node => node.type.name === name)
|
||||||
oldState.doc,
|
const newNodes = findChildren(newState.doc, node => node.type.name === name)
|
||||||
(node) => node.type.name === name,
|
|
||||||
);
|
|
||||||
const newNodes = findChildren(
|
|
||||||
newState.doc,
|
|
||||||
(node) => node.type.name === name,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
transaction.docChanged &&
|
transaction.docChanged &&
|
||||||
@@ -160,23 +117,23 @@ export function LowlightPlugin({
|
|||||||
// OR transaction has changes that completely encapsulte a node
|
// OR transaction has changes that completely encapsulte a node
|
||||||
// (for example, a transaction that affects the entire document).
|
// (for example, a transaction that affects the entire document).
|
||||||
// Such transactions can happen during collab syncing via y-prosemirror, for example.
|
// Such transactions can happen during collab syncing via y-prosemirror, for example.
|
||||||
transaction.steps.some((step) => {
|
transaction.steps.some(step => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return (
|
return (
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
step.from !== undefined &&
|
step.from !== undefined &&
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
step.to !== undefined &&
|
step.to !== undefined &&
|
||||||
oldNodes.some((node) => {
|
oldNodes.some(node => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return (
|
return (
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
node.pos >= step.from &&
|
node.pos >= step.from &&
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
node.pos + node.node.nodeSize <= step.to
|
node.pos + node.node.nodeSize <= step.to
|
||||||
);
|
)
|
||||||
})
|
})
|
||||||
);
|
)
|
||||||
}))
|
}))
|
||||||
) {
|
) {
|
||||||
return getDecorations({
|
return getDecorations({
|
||||||
@@ -184,19 +141,19 @@ export function LowlightPlugin({
|
|||||||
name,
|
name,
|
||||||
lowlight,
|
lowlight,
|
||||||
defaultLanguage,
|
defaultLanguage,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return decorationSet.map(transaction.mapping, transaction.doc);
|
return decorationSet.map(transaction.mapping, transaction.doc)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
decorations(state) {
|
decorations(state) {
|
||||||
return lowlightPlugin.getState(state);
|
return lowlightPlugin.getState(state)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
return lowlightPlugin;
|
return lowlightPlugin
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user