Polish email send and card toggles

This commit is contained in:
pewdiepie-archdaemon
2026-06-01 13:52:07 +09:00
parent 7023468cea
commit 8218421733
3 changed files with 131 additions and 3 deletions

View File

@@ -8,11 +8,41 @@ import themeModule from './theme.js';
let toastEl = null;
let autoScrollEnabled = true;
let hoveredToggleCard = null;
// Smooth scroll state
let _scrollRafId = null;
let _scrollBox = null;
function _isTextEditingTarget(target) {
const el = target && target.nodeType === 1 ? target : target?.parentElement;
return !!(el && el.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]'));
}
function _initHoverCardSpaceToggle() {
if (document._odysseusHoverCardSpaceToggle) return;
document._odysseusHoverCardSpaceToggle = true;
document.addEventListener('pointerover', (e) => {
const card = e.target?.closest?.('#email-lib-modal .doclib-card, #doclib-modal .doclib-card, .email-reader-tab-modal .doclib-card, .email-window-modal .doclib-card');
if (card) hoveredToggleCard = card;
}, true);
document.addEventListener('pointerout', (e) => {
if (!hoveredToggleCard) return;
const next = e.relatedTarget;
if (!next || !hoveredToggleCard.contains(next)) hoveredToggleCard = null;
}, true);
document.addEventListener('keydown', (e) => {
if (e.code !== 'Space' || e.repeat || !hoveredToggleCard || !document.contains(hoveredToggleCard)) return;
if (_isTextEditingTarget(e.target)) return;
const blocked = e.target?.closest?.('button, a, input, textarea, select, [contenteditable="true"], [contenteditable=""], .recipient-chip, .doclib-card-dropdown, .email-card-dropdown');
if (blocked) return;
e.preventDefault();
hoveredToggleCard.click();
}, true);
}
_initHoverCardSpaceToggle();
/**
* Copy text to clipboard
*/
@@ -104,18 +134,25 @@ export function showToast(msg, durationOrOpts) {
toastEl.textContent = '';
toastEl.classList.remove('error');
let duration = 1200, actionLabel = null, onAction = null, actionHint = null, actionIcon = null;
let duration = 1200, actionLabel = null, onAction = null, actionHint = null, actionIcon = null, leadingIcon = null;
if (typeof durationOrOpts === 'object' && durationOrOpts) {
duration = durationOrOpts.duration || 5000;
actionLabel = durationOrOpts.action;
onAction = durationOrOpts.onAction;
actionHint = durationOrOpts.actionHint || null;
actionIcon = durationOrOpts.actionIcon || null;
leadingIcon = durationOrOpts.leadingIcon || null;
} else if (typeof durationOrOpts === 'number') {
duration = durationOrOpts;
}
const textSpan = document.createElement('span');
if (leadingIcon === 'check') {
const icon = document.createElement('span');
icon.className = 'toast-checkmark';
icon.innerHTML = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>';
toastEl.appendChild(icon);
}
textSpan.textContent = msg;
toastEl.appendChild(textSpan);