- Implement new tabbed interface in message popover - Add shortcut guide tab alongside messages tab - Update MFV toggle button to use new tooltip format - Enhance scroll handling for open popovers - Adjust search input to display keyboard shortcuts - Update Floating Viewer buttons with new tooltip format - Add keyboard shortcut for toggling MFV (Ctrl/Cmd+V)
31 lines
954 B
JavaScript
31 lines
954 B
JavaScript
export function appendTooltipHint(label, hint) {
|
|
const base = String(label || "").trim();
|
|
const suffix = String(hint || "").trim();
|
|
|
|
if (!suffix) return base;
|
|
if (!base) return suffix;
|
|
if (suffix.length === 1) {
|
|
const escaped = suffix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
if (new RegExp(`\\(${escaped}\\)|\\b${escaped}\\b`, "i").test(base)) {
|
|
return base;
|
|
}
|
|
} else if (base.toLowerCase().includes(suffix.toLowerCase())) {
|
|
return base;
|
|
}
|
|
return `${base} (${suffix})`;
|
|
}
|
|
|
|
export function setTooltipHint(element, label, hint, { setAriaLabel = true, ariaLabel = null } = {}) {
|
|
if (!element) return "";
|
|
|
|
const title = appendTooltipHint(label, hint);
|
|
element.title = title;
|
|
|
|
if (setAriaLabel) {
|
|
const ariaBase = ariaLabel == null ? label : ariaLabel;
|
|
element.setAttribute("aria-label", appendTooltipHint(ariaBase, hint));
|
|
}
|
|
|
|
return title;
|
|
}
|