From 49df21e4655fda48841d02d6c3bc6dd4f541db62 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 6 Jul 2021 16:48:31 -0700 Subject: [PATCH] Display lists. --- src/platform/web/dom/deserialize.js | 2 +- .../web/ui/session/room/timeline/TextMessageView.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/platform/web/dom/deserialize.js b/src/platform/web/dom/deserialize.js index c036a059..5b9d1645 100644 --- a/src/platform/web/dom/deserialize.js +++ b/src/platform/web/dom/deserialize.js @@ -36,7 +36,7 @@ function parseLink(result, node, children) { function parseList(result, node) { let start = null; - if (result.getNodeElementName(node) == "OL") { + if (result.getNodeElementName(node) === "OL") { // Will return 1 for, say, '1A', which may not be intended? start = parseInt(result.getAttributeValue(node, "start")) || 1; } diff --git a/src/platform/web/ui/session/room/timeline/TextMessageView.js b/src/platform/web/ui/session/room/timeline/TextMessageView.js index 1f59af9c..f87e79dd 100644 --- a/src/platform/web/ui/session/room/timeline/TextMessageView.js +++ b/src/platform/web/ui/session/room/timeline/TextMessageView.js @@ -32,6 +32,15 @@ export class TextMessageView extends BaseMessageView { } } +function renderList(listBlock) { + const items = listBlock.items.map(item => tag.li({}, renderParts(item))); + const start = listBlock.startOffset; + if (start) { + return tag.ol({ start }, items); + } else { + return tag.ul({}, items); + } +} /** * Map from part to function that outputs DOM for the part */ @@ -43,6 +52,7 @@ const formatFunction = { text: textPart => text(textPart.text), link: linkPart => tag.a({ href: linkPart.url, target: "_blank", rel: "noopener" }, renderParts(linkPart.inlines)), format: formatPart => tag[formatPart.format]({}, renderParts(formatPart.children)), + list: renderList, newline: () => tag.br() };