I have to say, I’m floored with how wonderful the API’s for both projects are. Kudos to the creators!
My use case is a pedestrian one but I’m struggling with how to insert a snippet of text programmatically.
A little bit of context, I’m creating an app that compiles existing assets like text and links that I then allow users to insert into an editor via ProseMirror/TipTap commands. I’m able to insert a paragraph but I can’t seem to make the content editable. I’m assuming it’s to do with the way I’ve configured the NodeSpec.
Nodes that don’t have children are set as uneditable—ProseMirror only concerns itself with editing the part of the DOM that described by the schema. The content of leaf nodes (nodes with no children) falls outside of that.
In this case, you could set the node’s content to be text*, drop the attribute, and have its toDOM return ["p", {class: "snippet"}, 0] to get the effect that I think you’re looking for.
Well, that’s not right at all… Hole has to be the only child element.
My understanding conceptually is that I’d need to insert a paragraph, in my toDOM method which contains my snippet as a child element and the snippet itself also has a paragraph as a child element with the schema you described
["p",{}, 0] to remain editable
toDOM just renders content, it doesn’t create content. If you want editable text inside of a node, put it in there as child nodes, not as an attribute.
Not really, I think. You’re still using an attribute—you don’t need an attribute. The text can be stored as the node content, you don’t need to put it anywhere else.