make alternative class names searchable in FontAwesome icon picker

0388d3eb6c7e05228359ee06fab4c71b6d029bfa

LenAnderson <Anderson.Len@outlook.com>

1 files changed, +8 -5Showing whitespace changes
public/scripts/utils.js+8 -5
@@ -2039,7 +2039,10 @@ export async function fetchFaFile(name) {
20392039 document.head.append(style);
20402040 const sheet = style.sheet;
20412041 style.remove();
2042- return [...sheet.cssRules].filter(it => it.style?.content).map(it => it.selectorText.split('::').shift().slice(1));
2042+ return [...sheet.cssRules]
2043+ .filter(rule => rule.style?.content)
2044+ .map(rule => rule.selectorText.split(/,\s*/).map(selector=>selector.split('::').shift().slice(1)))
2045+ ;
20432046}
20442047export async function fetchFa() {
20452048 return [...new Set((await Promise.all([
@@ -2065,7 +2068,7 @@ export async function showFontAwesomePicker(customList = null) {
20652068 qry.placeholder = 'Filter icons';
20662069 qry.autofocus = true;
20672070 const qryDebounced = debounce(() => {
20682071 const result = faList.filter(itfa => itfa.find(className=>className.includes(qry.value)));
20692072 for (const fa of faList) {
20702073 if (!result.includes(fa)) {
20712074 fas[fa].classList.add('hidden');
@@ -2086,10 +2089,10 @@ export async function showFontAwesomePicker(customList = null) {
20862089 fas[fa] = opt;
20872090 opt.classList.add('menu_button');
20882091 opt.classList.add('fa-solid');
20892092 opt.classList.add(fa[0]);
20902093 opt.title = fa.map(it=>it.slice(3)).join(', ');
20912094 opt.dataset.result = POPUP_RESULT.AFFIRMATIVE.toString();
20922095 opt.addEventListener('click', () => value = fa[0]);
20932096 grid.append(opt);
20942097 }
20952098 }