| export type ToolboxTabCard = { | |
| title: string; | |
| desc: string; | |
| key: string; | |
| }; | |
| function normalize(input: string): string { | |
| return String(input || "").trim().toLowerCase(); | |
| } | |
| export function isEditableElement(target: EventTarget | null): boolean { | |
| if (!(target instanceof HTMLElement)) return false; | |
| const tag = target.tagName.toLowerCase(); | |
| const contentEditableAttr = String(target.getAttribute("contenteditable") || "").toLowerCase(); | |
| const contentEditable = target.isContentEditable || contentEditableAttr === "true" || contentEditableAttr === "plaintext-only"; | |
| return contentEditable || tag === "input" || tag === "textarea" || tag === "select"; | |
| } | |
| export function filterToolboxTabs<T extends ToolboxTabCard>(tabs: T[], query: string): T[] { | |
| const q = normalize(query); | |
| if (!q) return tabs; | |
| return tabs.filter((tab) => { | |
| const hay = normalize(`${tab.title} ${tab.desc} ${tab.key}`); | |
| return hay.includes(q); | |
| }); | |
| } | |
| export function shortcutLabel(index: number): string { | |
| if (index < 0 || index > 8) return ""; | |
| return `Alt+${index + 1}`; | |
| } | |