Skip to content

Commit 126d1d6

Browse files
committed
v1.5, sync works no initial content
1 parent 45effc1 commit 126d1d6

File tree

1 file changed

+5
-24
lines changed
  • apps/react/text-editors/libraries/tiptap/tiptap-demo/components/document/TipTapComponent

1 file changed

+5
-24
lines changed

apps/react/text-editors/libraries/tiptap/tiptap-demo/components/document/TipTapComponent/TipTapComponent.tsx

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@ import { useCommentAnnotations, useVeltEventCallback } from '@veltdev/react'
1010
import { TiptapVeltComments, addComment, renderComments } from '@veltdev/tiptap-velt-comments'
1111
import { EditorToolbar } from './ui/EditorToolbar'
1212
import { TipTapComponentProps } from './types'
13-
import { initialContent } from './constants'
1413
import { useCurrentDocument } from '@/app/document/useCurrentDocument'
1514
import { InlineH1, InlineH2, InlineH3 } from './extensions'
1615

1716
export default function TipTapComponent({ scrollContainerRef }: TipTapComponentProps) {
1817
const { documentId } = useCurrentDocument()
1918
const veltUser = useVeltEventCallback('userUpdate')
20-
const [hasInitialized, setHasInitialized] = React.useState(false)
2119

2220
// Initialize CRDT extension without initialContent to avoid encryption errors
23-
// We'll set initial content manually after the editor is ready
2421
const { VeltCrdt, isLoading } = useVeltTiptapCrdtExtension({
2522
editorId: documentId,
2623
onSynced: (doc) => {
@@ -31,7 +28,7 @@ export default function TipTapComponent({ scrollContainerRef }: TipTapComponentP
3128
}
3229
})
3330

34-
// Initialize the editor with empty content
31+
// Initialize the editor - content will be managed by CRDT after sync
3532
const editor = useEditor({
3633
extensions: [
3734
StarterKit.configure({
@@ -48,29 +45,13 @@ export default function TipTapComponent({ scrollContainerRef }: TipTapComponentP
4845
TiptapVeltComments,
4946
...(VeltCrdt ? [VeltCrdt] : []),
5047
],
51-
content: '', // Start with empty content
5248
immediatelyRender: false,
5349
}, [VeltCrdt])
5450

55-
// Set initial content if document is empty after editor initializes
56-
useEffect(() => {
57-
if (editor && !isLoading && !hasInitialized) {
58-
// Small delay to ensure CRDT has fully loaded
59-
const timer = setTimeout(() => {
60-
const currentText = editor.getText()
61-
console.log('Current editor text:', currentText)
62-
63-
// If document is completely empty, set initial content
64-
if (!currentText || currentText.trim().length === 0) {
65-
console.log('Setting initial content...')
66-
editor.commands.setContent(initialContent)
67-
}
68-
setHasInitialized(true)
69-
}, 1000) // Wait 1 second for CRDT to fully sync
70-
71-
return () => clearTimeout(timer)
72-
}
73-
}, [editor, isLoading, hasInitialized])
51+
// Note: Initial content insertion has been disabled due to Velt encryption limitations
52+
// Large HTML content causes "Maximum call stack size exceeded" errors during encryption
53+
// For now, documents start empty. Users can paste content or type manually.
54+
// TODO: Investigate chunking or alternative content loading strategies with Velt team
7455

7556
// Comment annotations
7657
const commentAnnotations = useCommentAnnotations()

0 commit comments

Comments
 (0)