Closed dragonman225 closed 1 year ago
Try making openBtn
non-editable (openBtn.contentEditable = "false"
) and see if that helps.
Thank you for the suggestion! Unfortunately the results are the same.
One small difference is that with openBtn.contentEditable = "false"
, when the cursor is at the end of the link text, it doesn't try to go into the button and be set back, instead, it doesn't move to the right at all.
Patch https://github.com/ProseMirror/prosemirror-view/commit/39b5664e2438d841b904dd59269351fc8a6fa766 should help with that.
Thank you for the patch! Cursor movement now works.
But typing after the last character of the link text is a bit tricky.
This ↓ will work (inserts new text after </a>
)
<a href="https://example.com" title="null"> ← dom
<span>content</span> ← contentDOM
<button contenteditable="false" style="user-select: none; display: inline;">↗</button>
</a>
while this ↓ will not work (inserts new text between </a>
and <button...
)
<span> ← dom
<a href="https://example.com" title="null">content</a> ← contentDOM
<button contenteditable="false" style="user-select: none; display: inline;">↗</button>
</span>
I have no particular preference, just point out in case someone encounter the same problem.
I'd like to create a button after each link mark, when the button is clicked, the browser opens the link. And clicking the text of the link does nothing.
I created a MarkView as below:
which would renders
dom
is the outer<span>
, andcontentDom
is<a>
.My
toDOM
function of the link mark is generic,Then, I encountered two problems:
https://github.com/ProseMirror/prosemirror/assets/25148955/53c03ff2-1930-493d-8fba-0b67f1616ac1
contentDOM
nor outsidedom
, but in between. Therefore I can't move the cursor into the new text or delete it, and it's not captured into the ProseMirror doc, either.https://github.com/ProseMirror/prosemirror/assets/25148955/23950d60-e820-4855-805a-5a68ac13e81d
Like this:
I searched for previous issues and it looked like there're some limitations for MarkView. I wonder if what I was trying to do involves with the limitations. Maybe it's not supported to have an addition node between
dom
andcontentDOM
?The ProseMirror libraries I'm using:
And the browser I'm using is Google Chrome 114.0.5735.198 on macOS.