pass member and room to editor pills to get avatar url
This commit is contained in:
parent
0c0052d06e
commit
710338c01f
4 changed files with 27 additions and 13 deletions
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
import { MATRIXTO_URL_PATTERN } from '../linkify-matrix';
|
||||
import { PlainPart, UserPillPart, RoomPillPart, NewlinePart } from "./parts";
|
||||
|
||||
function parseHtmlMessage(html) {
|
||||
function parseHtmlMessage(html, room) {
|
||||
const REGEX_MATRIXTO = new RegExp(MATRIXTO_URL_PATTERN);
|
||||
// no nodes from parsing here should be inserted in the document,
|
||||
// as scripts in event handlers, etc would be executed then.
|
||||
|
@ -37,8 +37,8 @@ function parseHtmlMessage(html) {
|
|||
const resourceId = pillMatch[1]; // The room/user ID
|
||||
const prefix = pillMatch[2]; // The first character of prefix
|
||||
switch (prefix) {
|
||||
case "@": return new UserPillPart(resourceId, n.textContent);
|
||||
case "#": return new RoomPillPart(resourceId, n.textContent);
|
||||
case "@": return new UserPillPart(resourceId, n.textContent, room.getMember(resourceId));
|
||||
case "#": return new RoomPillPart(resourceId, n.textContent, room);
|
||||
default: return new PlainPart(n.textContent);
|
||||
}
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ function parseHtmlMessage(html) {
|
|||
return parts;
|
||||
}
|
||||
|
||||
export function parseEvent(event) {
|
||||
export function parseEvent(event, room) {
|
||||
const content = event.getContent();
|
||||
if (content.format === "org.matrix.custom.html") {
|
||||
return parseHtmlMessage(content.formatted_body || "");
|
||||
return parseHtmlMessage(content.formatted_body || "", room);
|
||||
} else {
|
||||
const body = content.body || "";
|
||||
const lines = body.split("\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue