How to break a link at the end of a paragraph?

If a link is at the end of a paragraph, and I put my cursor at the end and start typing, whatever I type becomes a part of the link. Is there a way (except for adding a newline and removing it) to turn my text into normal text?

how can we move from:

<p>some text <a href='...'>Link<CURSOR_HERE></a></p>


<p>some text <a href='...'>Link</a><CURSOR_HERE></p>
1 Like

This behavior is controlled by the inclusiveRight MarkType property. You could create a custom LinkMark like this:

const {LinkMark} = require('prosemirror/dist/schema-basic')
class MyLinkMark extends LinkMark {
  get inclusiveRight() { return false }
1 Like

Put cursor at end, disable link style, type. Just like you would for italic or bold. Or change the inclusiveRight property of your link mark, as Kiejo suggested.

1 Like

Thanks man :slight_smile:

Looks like your approach would also make inclusiveLeft to always return false. If my hyperlink text is one character, I can’t use pm.doc.marksAt to get the mark (since both left and right are excluded). Is there a way to make inclusiveRight false but inclusiveLeft true? Do you have better approach? Thanks.

looks like pm.doc.nodeAt(pos).marks can achieve this.