Use prosemirror schema instead of node extension API? #2077
-
Hi Subject says it - is there any way to pass in a regular ProseMirror schema when creating a tiptap editor, as opposed to using Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
TLDR: Not really. You can use the import { Editor } from '@tiptap/core'
const editor = new Editor({
onBeforeCreate() {
this.editor.schema = new Schema({
// ...
})
},
}) But I think this will throw a ProseMirror error because tiptap creates the schema right before You can use a minimal setup to create a valid schema. After that you can overwrite it. import { Editor } from '@tiptap/core'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
const editor = new Editor({
extensions: [
Document,
Paragraph,
Text,
],
onBeforeCreate() {
this.editor.schema = new Schema({
// ...
})
},
}) But that just doesn’t feel right. I already thought about an option to pass a custom schema but you’ll miss some features that tiptap provides. Such as
To summarize: it’s probably not a good idea if you want to use tiptap. Just out of interest: why do you want to put pass a schema? |
Beta Was this translation helpful? Give feedback.
TLDR: Not really.
You can use the
onBeforeCreate
event to overwrite the schema. At this time the view is not created.But I think this will throw a ProseMirror error because tiptap creates the schema right before
onBeforeCreate
. Without atopNode
and atext
extension, ProseMirror throws an error.You can use a minimal setup to create a valid schema. After that you can overwrite it.