Hey, can I just say first that ProseMirror is amazing – the code, the community, the documentation. On my current project I have gone from Trix to Quill to Slate and finally to ProseMirror and the latter is by far and away the most robust and well-documented. And the number of times a problem I’ve had has been resolved already by a helpful reply posted on this forum is just wonderful (and totally validates using Discourse over Slack, btw).
Anyway, my question is, in the following screenshot you can see the cursor appearing to be inside my custom inline node type (called “wikilink”). In reality the cursor is not actually inside the node, it’s just before it at the end of the preceding text block (there is no space character there either, btw, that is padding on the wikilink node). So is there a way to make the cursor appear before the node where you would expect for that position?
One way is to remove the padding on the node, then it looks right, but I like the padding on these links and want to keep that.
Here’s what it looks like when I type from this position, and you can see how weird it seems – even though it works right:
The wikilink node is atomic in the schema and has contenteditable set to false on the dom element, so it’s impossible to edit the content of the node, despite what the cursor position implies (if you cursor right from this position, the node is highlighted entire, and then further right pressed move you straight past it).
Here’s the relevant section of the schema:
wikilink: {
attrs: { ... },
inline: true,
group: "inline",
atom: true,
draggable: true,
selectable: true,
content: "inline+",
...
And the NodeView for this type sets this.dom
to an a
tag and the contentDOM
to the same tag, and contenteditable
to false as mentioned. It’s interior text node is created in getContent
in the schema with Fragment.from(schema.text(linkTitle))
I’m sure I’m missing something obvious, but I’ve been off and on looking for a solution and trying different NodeSpec options for quite some time now so any help would be appreciated.
thanks – Dan