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 -5Ignore whitespace
public/scripts/utils.js+8 -5
@@ -2039,7 +2039,10 @@ export async function fetchFaFile(name) {
2039 document.head.append(style);2039 document.head.append(style);
2040 const sheet = style.sheet;2040 const sheet = style.sheet;
2041 style.remove();2041 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 ;
2043}2046}
2044export async function fetchFa() {2047export async function fetchFa() {
2045 return [...new Set((await Promise.all([2048 return [...new Set((await Promise.all([
@@ -2065,7 +2068,7 @@ export async function showFontAwesomePicker(customList = null) {
2065 qry.placeholder = 'Filter icons';2068 qry.placeholder = 'Filter icons';
2066 qry.autofocus = true;2069 qry.autofocus = true;
2067 const qryDebounced = debounce(() => {2070 const qryDebounced = debounce(() => {
2068 const result = faList.filter(it => it.includes(qry.value));2071 const result = faList.filter(fa => fa.find(className=>className.includes(qry.value.toLowerCase())));
2069 for (const fa of faList) {2072 for (const fa of faList) {
2070 if (!result.includes(fa)) {2073 if (!result.includes(fa)) {
2071 fas[fa].classList.add('hidden');2074 fas[fa].classList.add('hidden');
@@ -2086,10 +2089,10 @@ export async function showFontAwesomePicker(customList = null) {
2086 fas[fa] = opt;2089 fas[fa] = opt;
2087 opt.classList.add('menu_button');2090 opt.classList.add('menu_button');
2088 opt.classList.add('fa-solid');2091 opt.classList.add('fa-solid');
2089 opt.classList.add(fa);2092 opt.classList.add(fa[0]);
2090 opt.title = fa.slice(3);2093 opt.title = fa.map(it=>it.slice(3)).join(', ');
2091 opt.dataset.result = POPUP_RESULT.AFFIRMATIVE.toString();2094 opt.dataset.result = POPUP_RESULT.AFFIRMATIVE.toString();
2092 opt.addEventListener('click', () => value = fa);2095 opt.addEventListener('click', () => value = fa[0]);
2093 grid.append(opt);2096 grid.append(opt);
2094 }2097 }
2095 }2098 }
public/style.css+1 -0
@@ -5453,6 +5453,7 @@ body:not(.movingUI) .drawer-content.maximized {
5453 content: 'No icons found';5453 content: 'No icons found';
5454 color: var(--SmartThemeBodyColor);5454 color: var(--SmartThemeBodyColor);
5455 opacity: 0.7;5455 opacity: 0.7;
5456 width: max-content;
5456}5457}
54575458
5458#AdvancedFormatting .autoSetHeight {5459#AdvancedFormatting .autoSetHeight {