BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

RangeError: Unknown node type: tableParagraph

Open barbudour opened this issue 2 years ago • 1 comments

Describe the bug I'm trying to set up BlockNote Collaboration using Hocuspocus and the Database extension. When saving the data to the database everything works fine, but when retrieving the data and converting it to a Y.Doc (I'm using TiptapTransformer.toYdoc from @hocuspocus/transformer) I get a format error RangeError: Unknown node type: tableParagraph. As I understand - when parsing data, the handler encounters an unfamiliar data format. Perhaps someone has encountered this problem, how to pass to TiptapTransformer.toYdoc the data types that BlockNote works with so that it processes the data correctly?

The code of my handler is inside Database extension:

import {TiptapTransformer} from "@hocuspocus/transformer"
import {StarterKit} from "@tiptap/starter-kit";

const emptyDoc = new Y.Doc({
    guid: data?.id
})
if (data && data.document) {
    try {
        const doc = TiptapTransformer.toYdoc(data.document, 'default', [StarterKit])
        resolve(Y.encodeStateAsUpdate(doc))
    } catch (e) {
        // console.log(data.document)
        console.log(e)
        resolve(Y.encodeStateAsUpdate(emptyDoc))
    }
} else {
    resolve(Y.encodeStateAsUpdate(emptyDoc))
}

Terminal output:

[2024-01-16T18:49:33.411Z] Loaded document "5d3b0499-4644-4513-b60d-73c31561ba82".
RangeError: Unknown node type: tableParagraph
    at Schema.nodeType (/Users/barbudour/AI/socket/node_modules/prosemirror-model/dist/index.cjs:1950:25)
    at Function.fromJSON (/Users/barbudour/AI/socket/node_modules/prosemirror-model/dist/index.cjs:1172:21)
    at Schema.nodeFromJSON (/Users/barbudour/AI/socket/node_modules/prosemirror-model/dist/index.cjs:1939:19)
    at Array.map (<anonymous>)
    at Function.fromJSON (/Users/barbudour/AI/socket/node_modules/prosemirror-model/dist/index.cjs:288:33)
    at Function.fromJSON (/Users/barbudour/AI/socket/node_modules/prosemirror-model/dist/index.cjs:1171:30)
    at Schema.nodeFromJSON (/Users/barbudour/AI/socket/node_modules/prosemirror-model/dist/index.cjs:1939:19)
    at Array.map (<anonymous>)
    at Function.fromJSON (/Users/barbudour/AI/socket/node_modules/prosemirror-model/dist/index.cjs:288:33)
    at Function.fromJSON (/Users/barbudour/AI/socket/node_modules/prosemirror-model/dist/index.cjs:1171:30)

barbudour avatar Jan 16 '24 18:01 barbudour

@barbudour the TipTapTransformer would need to know about the BlockNote node types that are added to prosemirror. We'd like to improve BlockNote's support for server-side handling. There is some related work going on here: https://github.com/TypeCellOS/BlockNote/pull/451 which you might be interested in.

Curious what you're building btw!

YousefED avatar Jan 17 '24 10:01 YousefED