Support EmojiOne for inbound messages
Use their Unicode format, which is available in alt text
This commit is contained in:
parent
fa6d3b5279
commit
4f288b1754
|
@ -22,7 +22,7 @@
|
|||
* [ ] Sticons
|
||||
* [x] Single
|
||||
* [ ] Multiple or mixed with text
|
||||
* [ ] EmojiOne
|
||||
* [x] EmojiOne
|
||||
* [x] Notification for message send failure
|
||||
* [ ] Read receipts
|
||||
* [x] User metadata
|
||||
|
|
|
@ -212,10 +212,27 @@ class MautrixController {
|
|||
}
|
||||
const messageElement = element.querySelector(".mdRGT07Body > .mdRGT07Msg")
|
||||
if (messageElement.classList.contains("mdRGT07Text")) {
|
||||
// TODO Use alt text of emojione imgs
|
||||
messageData.text = messageElement.querySelector(".mdRGT07MsgTextInner")?.innerText
|
||||
// TODO HTML format for emojione imgs & sticons.
|
||||
// Consider using a custom sticker pack (MSC1951)
|
||||
const msgTextInner = messageElement.querySelector(".mdRGT07MsgTextInner")
|
||||
if (msgTextInner) {
|
||||
const imgs = msgTextInner.querySelectorAll("img")
|
||||
if (imgs.length == 0) {
|
||||
messageData.text = msgTextInner.innerText
|
||||
} else {
|
||||
// TODO Consider using a custom sticker pack (MSC1951)
|
||||
//messageData.image_urls = Array.from(imgs).map(img => img.src)
|
||||
//messageData.html = msgTextInner.innerHTML
|
||||
|
||||
let msgTextInnerCopy = msgTextInner.cloneNode(true)
|
||||
// TODO Consider skipping img.CMSticon elements,
|
||||
// whose alt-text is ugly
|
||||
// TODO Confirm that img is the only possible kind
|
||||
// of child element for a text message
|
||||
for (let child of Array.from(msgTextInnerCopy.children)) {
|
||||
child.replaceWith(child.getAttribute("alt"))
|
||||
}
|
||||
messageData.text = msgTextInnerCopy.innerText
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
messageElement.classList.contains("mdRGT07Image") ||
|
||||
messageElement.classList.contains("mdRGT07Sticker")
|
||||
|
|
Loading…
Reference in New Issue