Skip to content

Commit 9688e44

Browse files
committedMar 23, 2025
refactor(dependencies): remove '@tiptap-pro/extension-table-of-contents' from project
- Removed the '@tiptap-pro/extension-table-of-contents' dependency from package.json files in both the web and ai-workspace-common packages. - Updated the collab-editor and readonly-editor components to eliminate references to the TableOfContents, ensuring compliance with code style rules. - Ensured proper cleanup of related state management in the document store.
1 parent 6171b69 commit 9688e44

File tree

6 files changed

+1
-41
lines changed

6 files changed

+1
-41
lines changed
 

‎apps/web/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"@tailwindcss/forms": "^0.5.3",
3131
"@tailwindcss/typography": "^0.5.10",
3232
"@tanstack/react-query": "^5.61.3",
33-
"@tiptap-pro/extension-table-of-contents": "~2.11.2",
3433
"@tiptap-pro/extension-unique-id": "~2.11.2",
3534
"@types/aos": "^3.0.7",
3635
"@types/is-hotkey": "~0.1.7",

‎packages/ai-workspace-common/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@tailwindcss/forms": "^0.5.3",
3636
"@tanstack/react-query": "^5.61.3",
3737
"@tippyjs/react": "^4.2.6",
38-
"@tiptap-pro/extension-table-of-contents": "~2.11.2",
3938
"@tiptap/core": "2.7.4",
4039
"@tiptap/extension-character-count": "2.7.4",
4140
"@tiptap/extension-code-block-lowlight": "2.7.4",

‎packages/ai-workspace-common/src/components/document/collab-editor.tsx

-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
handleImageDrop,
3030
handleImagePaste,
3131
} from '@refly-packages/ai-workspace-common/components/editor/core/plugins';
32-
import { getHierarchicalIndexes, TableOfContents } from '@tiptap-pro/extension-table-of-contents';
3332
import {
3433
useDocumentStore,
3534
useDocumentStoreShallow,
@@ -102,7 +101,6 @@ export const CollaborativeEditor = memo(
102101
const documentActions = useDocumentStoreShallow((state) => ({
103102
setHasEditorSelection: state.setHasEditorSelection,
104103
updateDocumentCharsCount: state.updateDocumentCharsCount,
105-
updateTocItems: state.updateTocItems,
106104
updateLastCursorPosRef: state.updateLastCursorPosRef,
107105
setActiveDocumentId: state.setActiveDocumentId,
108106
}));
@@ -233,12 +231,6 @@ export const CollaborativeEditor = memo(
233231
Collaboration.configure({
234232
document: ydoc,
235233
}),
236-
TableOfContents.configure({
237-
getIndex: getHierarchicalIndexes,
238-
onUpdate(content) {
239-
documentActions.updateTocItems(docId, content);
240-
},
241-
}),
242234
];
243235
}, [ydoc, docId, documentActions, createPlaceholderExtension]);
244236

‎packages/ai-workspace-common/src/components/document/readonly-editor.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99

1010
import { handleCommandNavigation } from '@refly-packages/ai-workspace-common/components/editor/core/extensions';
1111
import { defaultExtensions } from '@refly-packages/ai-workspace-common/components/editor/components/extensions';
12-
import { getHierarchicalIndexes, TableOfContents } from '@tiptap-pro/extension-table-of-contents';
1312
import { useDocumentStoreShallow } from '@refly-packages/ai-workspace-common/stores/document';
1413
import { ImagePreview } from '@refly-packages/ai-workspace-common/components/common/image-preview';
1514
import UpdatedImage from '@refly-packages/ai-workspace-common/components/editor/core/extensions/updated-image';
@@ -82,12 +81,7 @@ export const ReadonlyEditor = memo(
8281

8382
const filteredExtensions = defaultExtensions.filter((ext) => ext.name !== 'image');
8483

85-
return [
86-
...filteredExtensions,
87-
centeredImage,
88-
Markdown,
89-
TableOfContents.configure({ getIndex: getHierarchicalIndexes }),
90-
];
84+
return [...filteredExtensions, centeredImage, Markdown];
9185
}, [docId]);
9286

9387
useEffect(() => {

‎packages/ai-workspace-common/src/stores/document.ts

-7
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ interface DocumentBaseState {
4242
updateDocument: (docId: string, document: Document) => void;
4343
updateDocumentCharsCount: (docId: string, count: number) => void;
4444
updateLastCursorPosRef: (docId: string, pos: number) => void;
45-
updateTocItems: (docId: string, items: TableOfContentsItem[]) => void;
4645
setActiveDocumentId: (docId: string) => void;
4746

4847
setDocumentReadOnly: (docId: string, readOnly: boolean) => void;
@@ -90,12 +89,6 @@ export const useDocumentStore = create<DocumentBaseState>()(
9089
state.data[docId].lastCursorPosRef = pos;
9190
}),
9291

93-
updateTocItems: (docId: string, items: TableOfContentsItem[]) =>
94-
set((state) => {
95-
state.data[docId] ??= {};
96-
state.data[docId].tocItems = items;
97-
}),
98-
9992
setActiveDocumentId: (docId: string) =>
10093
set((state) => {
10194
state.activeDocumentId = docId;

‎pnpm-lock.yaml

-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.