mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
Use HTML details/summary elements for blockquote switcher
This commit is contained in:
parent
c6652ba9b4
commit
9f8fdb2dfb
3 changed files with 8 additions and 19 deletions
|
|
@ -496,16 +496,13 @@ export class MessageModel extends AbstractModel {
|
||||||
|
|
||||||
initView() {
|
initView() {
|
||||||
// init BlockquoteSwitcher
|
// init BlockquoteSwitcher
|
||||||
this.body.querySelectorAll('blockquote:not(.rl-bq-switcher)').forEach(node => {
|
this.body.querySelectorAll('blockquote').forEach(node => {
|
||||||
if (node.textContent.trim()) {
|
if (node.textContent.trim()) {
|
||||||
// if (node.textContent.trim() && !node.parentNode.closest('blockquote')) {
|
|
||||||
node.removeAttribute('style')
|
|
||||||
let h = node.clientHeight || getRealHeight(node);
|
let h = node.clientHeight || getRealHeight(node);
|
||||||
if (0 === h || 100 < h) {
|
if (0 === h || 100 < h) {
|
||||||
const el = Element.fromHTML('<span class="rlBlockquoteSwitcher">•••</span>');
|
const el = Element.fromHTML('<details class="sm-bq-switcher"><summary>•••</summary></details>');
|
||||||
node.classList.add('rl-bq-switcher','hidden-bq');
|
node.replaceWith(el);
|
||||||
node.before(el);
|
el.append(node);
|
||||||
el.addEventListener('click', () => node.classList.toggle('hidden-bq'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -613,7 +610,6 @@ export class MessageModel extends AbstractModel {
|
||||||
let attr = 'data-x-src',
|
let attr = 'data-x-src',
|
||||||
src, useProxy = !!SettingsGet('UseLocalProxyForExternalImages');
|
src, useProxy = !!SettingsGet('UseLocalProxyForExternalImages');
|
||||||
body.querySelectorAll('img[' + attr + ']').forEach(node => {
|
body.querySelectorAll('img[' + attr + ']').forEach(node => {
|
||||||
node.loading = 'lazy';
|
|
||||||
src = node.getAttribute(attr);
|
src = node.getAttribute(attr);
|
||||||
node.src = useProxy ? proxy(src) : src;
|
node.src = useProxy ? proxy(src) : src;
|
||||||
});
|
});
|
||||||
|
|
@ -632,11 +628,8 @@ export class MessageModel extends AbstractModel {
|
||||||
bodyAsHTML() {
|
bodyAsHTML() {
|
||||||
if (this.body) {
|
if (this.body) {
|
||||||
let clone = this.body.cloneNode(true);
|
let clone = this.body.cloneNode(true);
|
||||||
clone.querySelectorAll('blockquote.rl-bq-switcher').forEach(
|
clone.querySelectorAll('.sm-bq-switcher').forEach(
|
||||||
node => node.classList.remove('rl-bq-switcher','hidden-bq')
|
node => node.replaceWith(node.lastElementChild)
|
||||||
);
|
|
||||||
clone.querySelectorAll('.rlBlockquoteSwitcher').forEach(
|
|
||||||
node => node.remove()
|
|
||||||
);
|
);
|
||||||
return clone.innerHTML;
|
return clone.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ html.rl-no-preview-pane {
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rlBlockquoteSwitcher {
|
.sm-bq-switcher > summary {
|
||||||
border: 1px solid #999;
|
border: 1px solid #999;
|
||||||
display: block;
|
display: block;
|
||||||
width: 3em;
|
width: 3em;
|
||||||
|
|
@ -369,10 +369,6 @@ html.rl-no-preview-pane {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rl-bq-switcher.hidden-bq {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.html {
|
&.html {
|
||||||
|
|
||||||
img {
|
img {
|
||||||
|
|
|
||||||
|
|
@ -394,7 +394,7 @@ export class MailMessageView extends AbstractViewRight {
|
||||||
registerShortcut('b', '', [Scope.MessageList, Scope.MessageView], () => {
|
registerShortcut('b', '', [Scope.MessageList, Scope.MessageView], () => {
|
||||||
const message = currentMessage();
|
const message = currentMessage();
|
||||||
if (message?.body) {
|
if (message?.body) {
|
||||||
message.body.querySelectorAll('.rlBlockquoteSwitcher').forEach(node => node.click());
|
message.body.querySelectorAll('.sm-bq-switcher > summary').forEach(node => node.click());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue