-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
Needs TriageA new issue or pullrequest that requires triage (added by default)A new issue or pullrequest that requires triage (added by default)Open SourceThe issue or pull reuqest is related to the open source packages of Tiptap.The issue or pull reuqest is related to the open source packages of Tiptap.
Description
Affected Packages
core
Version(s)
3.0.1 or later
Bug Description
In Node environment
When I create a Tiptap Editor instance in SSR mode
const editor = new Editor({
element: null,
extensions: [StarterKit],
})
It throws an error:
Error: [tiptap error]: there is no window object available, so this function cannot be used
❯ elementFromString node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@tiptap/core/src/utilities/elementFromString.ts:19:11
❯ createNodeFromContent node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@tiptap/core/src/helpers/createNodeFromContent.ts:115:25
❯ createDocument node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@tiptap/core/src/helpers/createDocument.ts:19:10
❯ Editor.createDoc node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@tiptap/core/src/Editor.ts:439:13
❯ new Editor node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@tiptap/core/src/Editor.ts:132:29
❯ index.ts:24:20
22|
23|
24| const editor = new Editor({
| ^
25| element: null,
26| // content: {
When I set the content to a Tiptap JSON object, the error disappears:
const editor = new Editor({
element: null,
content: {
type: 'doc',
content: [],
},
extensions: [StarterKit, AiToolkit],
})
I think it's because the editor, by default, creates the document by parsing an empty string (Even when SSR mode is on).
Would it be possible that the default value of the editor is an empty node of type 'doc'
? (Or whatever the top-level node of the schema might be) . Instead of an empty string.
If this is not possible, the documentation should be updated to explain this, so that developers don't meet this error.
Browser Used
Other
Code Example URL
No response
Expected Behavior
The Editor is initialized without error in SSR mode when the content
parameter is not provided.
Additional Context (Optional)
No response
Dependency Updates
- Yes, I've updated all my dependencies.
Metadata
Metadata
Assignees
Labels
Needs TriageA new issue or pullrequest that requires triage (added by default)A new issue or pullrequest that requires triage (added by default)Open SourceThe issue or pull reuqest is related to the open source packages of Tiptap.The issue or pull reuqest is related to the open source packages of Tiptap.
Type
Projects
Status
Needs Triage