Closed softmarshmallow closed 1 day ago
This is by design: passing undefined
makes BlockNote initialize the editor with an empty paragraph block. I think this is a common pattern (use a default value, when passed undefined
). I think using a default value (empty paragraph block) when passing []
would not be very clear for consumers; hence the error.
(I think both approaches can be valid ofc)
Hi. If I may, I have some follow up questions, Not a big expert on neither prosemirror nor tiptap, but as I understand, the docuement
model seems like a tiptap's json wihout a root doc
, is this correct? - It may confuse some people moving from tiptap since the document model does not match (I personally expected the way working with blocknotes' document model would be identical to tiptap.
Not a big problem though!
Hi. If I may, I have some follow up questions, Not a big expert on neither prosemirror nor tiptap, but as I understand, the
docuement
model seems like a tiptap's json wihout a rootdoc
, is this correct? - It may confuse some people moving from tiptap since the document model does not match (I personally expected the way working with blocknotes' document model would be identical to tiptap.Not a big problem though!
Actually, BlockNote's editor.document
is a bit different from TipTap's JSON representation, though admittedly it's mostly a difference in naming. The reason it's different is so that we can have strong typing - TipTap doesn't care what you pass to commands like setContent
whereas BlockNote is strict on what you can pass to e.g. replaceBlocks
.
This is because you can have huge flexibility with the schema in TipTap, but BlockNote is more rigid, and the general structure of blocks can't be changed. But you're right, the way that the document is represented in TipTap using JSON vs how it's represented in BlockNote with Block
objects is pretty close.
Passing a empty array
[]
toinitialContent
will throw an error. This makes sense but also, the editor should be able to use without case handling by users, where for my case I have a postgresql table withbody
default value to[]
- this can be safely ignored by BlockNote. (Plus I don't see a reason why this should be trhown internally as well.)I can do below, but should I?