Rework message pilling to ignore event permalinks
This removes pills from event permalinks since they hide the text associated with the link, which can cause nonsensical messages since words have been removed. In addition, this moves away from fragile regexs to more straightforward code to parse links and adds a test for this case. Regressed by https://github.com/matrix-org/matrix-react-sdk/pull/5188 Fixes https://github.com/vector-im/element-web/issues/15159
This commit is contained in:
parent
71921ad705
commit
fa3ace8473
6 changed files with 72 additions and 26 deletions
|
@ -213,6 +213,35 @@ describe("<TextualBody />", () => {
|
|||
'style="width: 16px; height: 16px;" title="@member:domain.bla" alt="" aria-hidden="true">Member</a>' +
|
||||
'</span></span>');
|
||||
});
|
||||
|
||||
it("pills do not appear for event permalinks", () => {
|
||||
const ev = mkEvent({
|
||||
type: "m.room.message",
|
||||
room: "room_id",
|
||||
user: "sender",
|
||||
content: {
|
||||
body:
|
||||
"An [event link](https://matrix.to/#/!ZxbRYPQXDXKGmDnJNg:example.com/" +
|
||||
"$16085560162aNpaH:example.com?via=example.com) with text",
|
||||
msgtype: "m.text",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body:
|
||||
"An <a href=\"https://matrix.to/#/!ZxbRYPQXDXKGmDnJNg:example.com/" +
|
||||
"$16085560162aNpaH:example.com?via=example.com\">event link</a> with text",
|
||||
},
|
||||
event: true,
|
||||
});
|
||||
|
||||
const wrapper = mount(<TextualBody mxEvent={ev} />);
|
||||
expect(wrapper.text()).toBe("An event link with text");
|
||||
const content = wrapper.find(".mx_EventTile_body");
|
||||
expect(content.html()).toBe(
|
||||
'<span class="mx_EventTile_body markdown-body" dir="auto">' +
|
||||
'An <a href="#/room/!ZxbRYPQXDXKGmDnJNg:example.com/' +
|
||||
'$16085560162aNpaH:example.com?via=example.com" ' +
|
||||
'rel="noreferrer noopener">event link</a> with text</span>',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("renders url previews correctly", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue