You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-30 02:21:17 +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:
@ -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()));
|
||||
|
@ -63,6 +63,12 @@ describe("editor/serialize", function () {
|
||||
const html = htmlSerializeIfNeeded(model, {});
|
||||
expect(html).toBe('<a href="https://matrix.to/#/@user:server">Displayname]</a>');
|
||||
});
|
||||
it("displaynames containing a newline work", function () {
|
||||
const pc = createPartCreator();
|
||||
const model = new EditorModel([pc.userPill("Display\nname", "@user:server")], pc);
|
||||
const html = htmlSerializeIfNeeded(model, {});
|
||||
expect(html).toBe('<a href="https://matrix.to/#/@user:server">Display<br>name</a>');
|
||||
});
|
||||
it("escaped markdown should not retain backslashes", function () {
|
||||
const pc = createPartCreator();
|
||||
const model = new EditorModel([pc.plain("\\*hello\\* world")], pc);
|
||||
@ -96,7 +102,6 @@ describe("editor/serialize", function () {
|
||||
const html = htmlSerializeIfNeeded(model, { useMarkdown: false });
|
||||
expect(html).toBe("\\*hello\\* world < hey world!");
|
||||
});
|
||||
|
||||
it("plaintext remains plaintext even when forcing html", function () {
|
||||
const pc = createPartCreator();
|
||||
const model = new EditorModel([pc.plain("hello world")], pc);
|
||||
|
Reference in New Issue
Block a user