From 2845d76085c2dff816ee885d9e19e5568ac18913 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Fri, 4 Dec 2026 21:44:32 -0500 Subject: [PATCH] feat: Option to include comments when duplicating a document (#14880) * feat: Option to include comments when duplicating a document * refactor: Share mark walking between removeMarks and comment remapping * fix: Copy thread roots first and notify nobody about duplicated comments --- .../DocumentExplorer/DocumentCopy.tsx | 15 ++ app/models/Document.ts | 3 + app/scenes/Document/components/DataLoader.tsx | 6 +- app/stores/DocumentsStore.ts | 1 + server/commands/documentDuplicator.test.ts | 138 +++++++++++++++++- server/commands/documentDuplicator.ts | 77 +++++++++- .../processors/NotificationsProcessor.test.ts | 55 ++++++- .../processors/NotificationsProcessor.ts | 8 + server/routes/api/documents/documents.test.ts | 18 +++ server/routes/api/documents/documents.ts | 16 +- server/routes/api/documents/schema.ts | 2 + server/types.ts | 4 + shared/i18n/locales/en_US/translation.json | 1 + shared/utils/ProsemirrorHelper.ts | 71 +++++---- 14 files changed, 377 insertions(+), 38 deletions(-) diff --git a/app/components/DocumentExplorer/DocumentCopy.tsx b/app/components/DocumentExplorer/DocumentCopy.tsx index 8df50c05cd..ed2839d148 100644 --- a/app/components/DocumentExplorer/DocumentCopy.tsx +++ b/app/components/DocumentExplorer/DocumentCopy.tsx @@ -9,6 +9,7 @@ import Button from "~/components/Button"; import Switch from "~/components/Switch"; import Text from "~/components/Text"; import useCollectionTrees from "~/hooks/useCollectionTrees"; +import useCurrentTeam from "~/hooks/useCurrentTeam"; import useStores from "~/hooks/useStores"; import { FlexContainer, Footer } from "./Components"; import DocumentExplorer from "./DocumentExplorer"; @@ -22,10 +23,12 @@ type Props = { function DocumentCopy({ document, onSubmit }: Props) { const { t } = useTranslation(); const { policies } = useStores(); + const team = useCurrentTeam(); const collectionTrees = useCollectionTrees(); const [publish, setPublish] = React.useState(!!document.publishedAt); const [copying, setCopying] = React.useState(false); const [recursive, setRecursive] = React.useState(true); + const [comments, setComments] = React.useState(false); const [selectedPath, selectPath] = React.useState( null ); @@ -51,6 +54,7 @@ function DocumentCopy({ document, onSubmit }: Props) { const result = await document.duplicate({ publish, recursive, + comments: team.commentingEnabled && comments, title: document.title, collectionId: path.collectionId, ...(path.type === "document" ? { parentDocumentId: path.id } : {}), @@ -96,6 +100,17 @@ function DocumentCopy({ document, onSubmit }: Props) { /> )} + {team.commentingEnabled && ( + + + + )}