1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-07 21:23:00 +03:00

Handle newlines in user pills (#11166)

* Handle newlines in user pills

Fixes: vector-im/element-web#10994

* Fix typo in comment

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Refactor link generation for better readability

* Use `<br>` instead of `<br/>`

* Fix copy/paste error

---------

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
Johannes Marbach
2023-07-06 00:00:27 +02:00
committed by GitHub
parent 3f20675b93
commit d7677c7e21
4 changed files with 29 additions and 16 deletions

View File

@@ -183,6 +183,14 @@ describe("editor/deserialize", function () {
expect(parts[1]).toStrictEqual({ type: "user-pill", text: "Alice]", resourceId: "@alice:hs.tld" });
expect(parts[2]).toStrictEqual({ type: "plain", text: "!" });
});
it("user pill with displayname containing linebreak", function () {
const html = 'Hi <a href="https://matrix.to/#/@alice:hs.tld">Alice<br>123</a>!';
const parts = normalize(parseEvent(htmlMessage(html), createPartCreator()));
expect(parts.length).toBe(3);
expect(parts[0]).toStrictEqual({ type: "plain", text: "Hi " });
expect(parts[1]).toStrictEqual({ type: "user-pill", text: "Alice123", resourceId: "@alice:hs.tld" });
expect(parts[2]).toStrictEqual({ type: "plain", text: "!" });
});
it("room pill", function () {
const html = 'Try <a href="https://matrix.to/#/#room:hs.tld">#room:hs.tld</a>?';
const parts = normalize(parseEvent(htmlMessage(html), createPartCreator()));