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
|
* [ ] Sticons
|
||||||
* [x] Single
|
* [x] Single
|
||||||
* [ ] Multiple or mixed with text
|
* [ ] Multiple or mixed with text
|
||||||
* [ ] EmojiOne
|
* [x] EmojiOne
|
||||||
* [x] Notification for message send failure
|
* [x] Notification for message send failure
|
||||||
* [ ] Read receipts
|
* [ ] Read receipts
|
||||||
* [x] User metadata
|
* [x] User metadata
|
||||||
|
|
|
@ -212,10 +212,27 @@ class MautrixController {
|
||||||
}
|
}
|
||||||
const messageElement = element.querySelector(".mdRGT07Body > .mdRGT07Msg")
|
const messageElement = element.querySelector(".mdRGT07Body > .mdRGT07Msg")
|
||||||
if (messageElement.classList.contains("mdRGT07Text")) {
|
if (messageElement.classList.contains("mdRGT07Text")) {
|
||||||
// TODO Use alt text of emojione imgs
|
const msgTextInner = messageElement.querySelector(".mdRGT07MsgTextInner")
|
||||||
messageData.text = messageElement.querySelector(".mdRGT07MsgTextInner")?.innerText
|
if (msgTextInner) {
|
||||||
// TODO HTML format for emojione imgs & sticons.
|
const imgs = msgTextInner.querySelectorAll("img")
|
||||||
// Consider using a custom sticker pack (MSC1951)
|
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 (
|
} else if (
|
||||||
messageElement.classList.contains("mdRGT07Image") ||
|
messageElement.classList.contains("mdRGT07Image") ||
|
||||||
messageElement.classList.contains("mdRGT07Sticker")
|
messageElement.classList.contains("mdRGT07Sticker")
|
||||||
|
|
Loading…
Reference in New Issue