Skip to content

Commit ec75a3c

Browse files
Hemomoo邓亮
andauthored
refactor: 移除评论功能相关代码 (#316)
* refactor: 移除评论功能相关代码 移除评论功能的所有相关代码,包括评论面板、评论存储、评论菜单项及相关逻辑 * chore: 启用 engine-strict 以确保 Node 版本匹配 --------- Co-authored-by: 邓亮 <787615673@qq.com>
1 parent cf957ae commit ec75a3c

10 files changed

Lines changed: 2 additions & 1090 deletions

File tree

apps/DocFlow/src/app/docs/[room]/page.tsx

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ import {
1919
} from 'react-resizable-panels';
2020
import 'md-editor-rt/lib/preview.css';
2121

22-
// 动态导入 CommentPanel,禁用 SSR
23-
const CommentPanel = dynamic(
24-
() =>
25-
import('@/app/docs/_components/CommentPanel').then((mod) => ({ default: mod.CommentPanel })),
26-
{
27-
ssr: false,
28-
loading: () => null,
29-
},
30-
);
31-
3222
// 动态导入 ChatPanel,禁用 SSR
3323
const ChatPanel = dynamic(
3424
() => import('@/app/docs/_components/ChatPanel').then((mod) => ({ default: mod.ChatPanel })),
@@ -59,7 +49,6 @@ import { ImageBlockMenu } from '@/components/menus';
5949
import DocumentApi from '@/services/document';
6050
import NoPermission from '@/app/docs/_components/NoPermission';
6151
import { DocumentPermissionData } from '@/services/document/type';
62-
import { useCommentStore } from '@/stores/commentStore';
6352
import { useEditorStore } from '@/stores/editorStore';
6453
import { useEditorHistory } from '@/hooks/useEditorHistory';
6554
import { storage, STORAGE_KEYS } from '@/utils/storage/local-storage';
@@ -101,7 +90,7 @@ export default function DocumentPage() {
10190
const [currentUser, setCurrentUser] = useState<CollaborationUser | null>(null);
10291
const [connectedUsers, setConnectedUsers] = useState<CollaborationUser[]>([]);
10392
const [isIndexedDBReady, setIsIndexedDBReady] = useState(false);
104-
const { openPanel, setActiveCommentId, closePanel, isPanelOpen } = useCommentStore();
93+
10594
const { setEditor, clearEditor } = useEditorStore();
10695
const [isSearchOpen, setIsSearchOpen] = useState(false);
10796

@@ -323,24 +312,6 @@ export default function DocumentPage() {
323312
extensions: [
324313
...ExtensionKit({
325314
provider,
326-
commentCallbacks: {
327-
onCommentActivated: (commentId) => {
328-
// 使用 setTimeout 确保在下一个事件循环中更新状态,避免渲染期间更新
329-
setTimeout(() => {
330-
setActiveCommentId(commentId);
331-
332-
if (commentId) {
333-
openPanel();
334-
}
335-
}, 0);
336-
},
337-
onCommentClick: (commentId) => {
338-
setTimeout(() => {
339-
setActiveCommentId(commentId);
340-
openPanel();
341-
}, 0);
342-
},
343-
},
344315
}),
345316
...(doc && isIndexedDBReady
346317
? [Collaboration.configure({ document: doc, field: 'content' })]
@@ -375,35 +346,6 @@ export default function DocumentPage() {
375346
[doc, provider, currentUser, isReadOnly, isIndexedDBReady, documentId, setEditor, clearEditor],
376347
);
377348

378-
// 点击编辑器内容时关闭评论面板(除非点击评论标记)
379-
useEffect(() => {
380-
if (!editor || !isPanelOpen) return;
381-
382-
const handleEditorClick = (event: MouseEvent) => {
383-
const target = event.target as HTMLElement;
384-
const isCommentMark = target.closest('span[data-comment="true"]');
385-
386-
// 如果点击的不是评论标记,则关闭面板
387-
if (!isCommentMark) {
388-
closePanel();
389-
}
390-
};
391-
392-
const editorElement = editor.view.dom;
393-
394-
// 确保元素仍然存在于DOM中
395-
if (editorElement && document.body.contains(editorElement)) {
396-
editorElement.addEventListener('click', handleEditorClick);
397-
398-
return () => {
399-
// 再次检查元素是否仍然存在于DOM中
400-
if (editorElement && document.body.contains(editorElement)) {
401-
editorElement.removeEventListener('click', handleEditorClick);
402-
}
403-
};
404-
}
405-
}, [editor, isPanelOpen, closePanel]);
406-
407349
// Ctrl+C 复制选中文本为 JSON 格式,并添加文档引用元数据
408350
useEffect(() => {
409351
if (!editor) return;
@@ -634,13 +576,6 @@ export default function DocumentPage() {
634576
</Group>
635577
</div>
636578

637-
{/* 评论面板 */}
638-
{editor && (
639-
<Activity>
640-
<CommentPanel editor={editor} documentId={documentId} currentUserId={currentUser?.id} />
641-
</Activity>
642-
)}
643-
644579
{/* 搜索面板 */}
645580
{editor && editor.view && (
646581
<SearchPanel editor={editor} isOpen={isSearchOpen} onClose={() => setIsSearchOpen(false)} />

apps/DocFlow/src/app/docs/_components/CommentPanel/comment-item.tsx

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)