Files
MajoorWaldi-ComfyUI-Majoor-…/js/utils/tooltipShortcuts.js
T
MajoorWaldi fecfa0eb56 feat(panel): add shortcut guide tab to message popover
- 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)
2026-03-06 19:21:51 +01:00

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;
}