Move blockquote switcher to HTML parser #902

This commit is contained in:
the-djmaze 2023-02-03 11:17:16 +01:00
parent 39bb3719c2
commit c6db5f1def
2 changed files with 26 additions and 28 deletions

View file

@ -25,14 +25,6 @@ import { LanguageStore } from 'Stores/Language';
import Remote from 'Remote/User/Fetch';
const
hcont = Element.fromHTML('<div area="hidden" style="position:absolute;left:-200vw;width:max(50vw,400px)"></div>'),
getRealHeight = el => {
hcont.innerHTML = el.outerHTML;
const result = hcont.clientHeight;
hcont.innerHTML = '';
return result;
},
toggleTag = (message, keyword) => {
const lower = keyword.toLowerCase(),
flags = message.flags,
@ -60,8 +52,6 @@ const
unic[email.email] || localEmails.has(email.email) || localEmails.set(email.email, email)
);
doc.body.append(hcont);
export class MessageModel extends AbstractModel {
constructor() {
super();
@ -307,7 +297,6 @@ export class MessageModel extends AbstractModel {
}
this.isHtml(true);
this.initView();
return true;
}
}
@ -327,25 +316,10 @@ export class MessageModel extends AbstractModel {
);
this.isHtml(false);
this.hasImages(false);
this.initView();
return true;
}
}
initView() {
// init BlockquoteSwitcher
this.body.querySelectorAll('blockquote').forEach(node => {
if (node.textContent.trim()) {
let h = node.clientHeight || getRealHeight(node);
if (0 === h || 100 < h) {
const el = Element.fromHTML('<details class="sm-bq-switcher"><summary>•••</summary></details>');
node.replaceWith(el);
el.append(node);
}
}
});
}
viewPopupMessage(print) {
const timeStampInUTC = this.dateTimeStampInUTC() || 0,
ccLine = this.cc.toString(),