Merge pull request #2792 from LenAnderson/fa-picker-alt-classnames Make alternative class names searchable in FontAwesome icon picker | /pick-icon

b83cfa07c931f0c4ac7b2721ea5a0414df5f708b

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
2 files changed, +9 -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.toLowerCase())));
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 }
public/style.css+1 -0
@@ -5453,6 +5453,7 @@ body:not(.movingUI) .drawer-content.maximized {
54535453 content: 'No icons found';
54545454 color: var(--SmartThemeBodyColor);
54555455 opacity: 0.7;
5456+ width: max-content;
54565457}
54575458
54585459#AdvancedFormatting .autoSetHeight {