-
-
Notifications
You must be signed in to change notification settings - Fork 832
Decorate matrix.to anchor tags as mx_UserPill and mx_RoomPill #1227
Conversation
These have since been replaced by decorators that operator whether in MD mode or otherwise. This might not be optimal because LINK entities do not appear in MD mode at all at the moment, but instead you see the ()[] md notation version.
if (node.tagName === "A" && node.getAttribute("href")) { | ||
const href = node.getAttribute("href"); | ||
// HtmlUtils transforms `matrix.to` links to local links, so match against | ||
// user or room app links. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it looks like your code is right, although I'm failing to find where this happens. It probably should not, and leave the href as matrix.to but override the onclick like we do with permalinks and linkified users / rooms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, transformTags
const href = node.getAttribute("href"); | ||
// HtmlUtils transforms `matrix.to` links to local links, so match against | ||
// user or room app links. | ||
const match = /^#\/(user|room)\/(.*)$/.exec(href); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When doing this it's quite nice to expand out the matches into named variables and refer to those, which I think makes the code a bit easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird that I did this with the other PR and not this one..
room = match[2][0] === '#' ? | ||
MatrixClientPeg.get().getRooms().find((r) => { | ||
return r.getCanonicalAlias() === match[2]; | ||
}) : MatrixClientPeg.get().getRoom(match[2]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-canonical aliases should surely work too? This will probably involve a server round-trip to look up the alias though :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a first cut I guess this isn't too bad? The RTE does it this way so I suppose it'd be best to factor this out and then do all the async stuff? Likewise for hitting /profile
for getting user avatars etc.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Requires element-hq/element-web#4597 to look OK