Hey - me again
One of the things that I’m experimenting with is to see whether it would be possible to create a metadata-driven editor. I’m using tiptap v2, (currently) a fixed json document - that has both PM content and metadata that should drive the editor instance and ES6 dynamic import functionality. I’m facing a problem with this which I’m trying to track down. Now I know that this is a) maybe, probably not a PM issue (or tiptap) for that matter and b) maybe somewhat of a ‘different’ way to do things - but I’m reaching out to this forum to see whether the problematic behavior I will describe rings any bells.
The situation is relatively straightforward. I use standard Document, Paragraph, Text, Bold and Italic extensions and use them (in a dev setup) using dynamic imports. Additionally I have a custom extension (node) called Introduction which I add into the mix.
The content expression for the document is:
introduction? paragraph*
The content expression for the introduction is:
paragraph+
So effectively I describe the document as optionally starting with an Introduction (which itself could hold one or more paragraphs), then followed by zero or more paragraphs.
I start out this document with content like this:
{
"type": "doc",
"content": [
{
"type": "introduction",
"content": [
{
"type": "paragraph",
"content": [{ "type": "text", "text": "Some introductory words..." }]
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "It's a "
},
{
"type": "text",
"marks": [
{
"type": "bold"
}
],
"text": "dynamic"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"marks": [
{
"type": "italic"
}
],
"text": "world"
},
{
"type": "text",
"text": "!"
}
]
}
]
}
This loads fine and the prosemirror-dev-toolkit shows the following content:
Whenever I position the cursor in the introduction and hit [enter], just as I expect a new paragraph is added and is reflected by the toolkit:
However when I move the cursor to the very end of the document (at the end of the paragraph, not within the introduction) and when I hit [enter] to start a new paragraph, the following error is displayed on the console:
After which the Introduction has vanished from the document content, also seen in the toolkit:
The below screen recording shows the behavior as it happens.
My question/ask is: has anyone seen a similar kind of behavior before?
Could this (somehow) be related to using dynamic imports?