What I would love to achieve is to automatically set the cursor right after the <code> once it’s been created- <p><code>12</code> (cursor here)</p>.
I have tried setSelection in many ways to no avail, such as this:
tr.addMark(markStart, markEnd, markType.create(attrs));
tr.removeStoredMark(markType);
const resolvedPos = tr.doc.resolve(4); // hardcoding position just to see desired effect...
tr.setSelection(new TextSelection(resolvedPos));
return tr;
There are no separate cursor positions before and after the </code>. There’s only one position there, which by default has the code mark active. Disabling the code mark via removeStoredMark should work, at least for immediate subsequent typing. Doesn’t it?
It does. Maybe I can reduce the padding on my grey background color on my </code> so users won’t think to press ‘right’ key to ‘exit’ the inline <code>.
Yeah, padding on inline nodes is problematic like this. But the problem exists not just in ProseMirror, but also in browsers, which for the most part also don’t distinguish between cursor positions inside and outside inline tags when it comes to where to insert text.