From 0388d3eb6c7e05228359ee06fab4c71b6d029bfa Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Fri, 6 Sep 2024 10:07:50 -0400 Subject: [PATCH] make alternative class names searchable in FontAwesome icon picker --- public/scripts/utils.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/public/scripts/utils.js b/public/scripts/utils.js index fc83b4a50..8fb591c95 100644 --- a/public/scripts/utils.js +++ b/public/scripts/utils.js @@ -2039,7 +2039,10 @@ export async function fetchFaFile(name) { document.head.append(style); const sheet = style.sheet; style.remove(); - return [...sheet.cssRules].filter(it => it.style?.content).map(it => it.selectorText.split('::').shift().slice(1)); + return [...sheet.cssRules] + .filter(rule => rule.style?.content) + .map(rule => rule.selectorText.split(/,\s*/).map(selector=>selector.split('::').shift().slice(1))) + ; } export async function fetchFa() { return [...new Set((await Promise.all([ @@ -2065,7 +2068,7 @@ export async function showFontAwesomePicker(customList = null) { qry.placeholder = 'Filter icons'; qry.autofocus = true; const qryDebounced = debounce(() => { - const result = faList.filter(it => it.includes(qry.value)); + const result = faList.filter(fa => fa.find(className=>className.includes(qry.value))); for (const fa of faList) { if (!result.includes(fa)) { fas[fa].classList.add('hidden'); @@ -2086,10 +2089,10 @@ export async function showFontAwesomePicker(customList = null) { fas[fa] = opt; opt.classList.add('menu_button'); opt.classList.add('fa-solid'); - opt.classList.add(fa); - opt.title = fa.slice(3); + opt.classList.add(fa[0]); + opt.title = fa.map(it=>it.slice(3)).join(', '); opt.dataset.result = POPUP_RESULT.AFFIRMATIVE.toString(); - opt.addEventListener('click', () => value = fa); + opt.addEventListener('click', () => value = fa[0]); grid.append(opt); } }