matrix-org / matrix-rich-text-editor

Matrix Rich Text Editor
https://matrix-org.github.io/matrix-rich-text-editor/
Apache License 2.0
92 stars 23 forks source link

When selection covers just a mention and the user adds a new line, no new line is added #906

Open jmartinesp opened 9 months ago

jmartinesp commented 9 months ago

Problem

When the composer's selection wraps only a mention and enter() is received, instead of adding a new line, the mention is removed.

Steps to reproduce

// Before:
Test {<a data-mention-type="user" href="https://matrix.to/#/@bob:matrix.org" contenteditable="false">@bob</a>}| more
// After pressing enter:
<p>Test  |more </p><p> </p>

This is obviously not the required behavior. I think it can be avoided by wrapping the contents of the root node inside a paragraph first, but that would also change how pressing enter works in lots of other cases, so it's not a quick fix.

Related issues

https://github.com/matrix-org/matrix-rich-text-editor/issues/903

Proposed solution

Re-work a bit how do_enter() works when the root node for mentions when they're not inside paragraphs.