Merge pull request #2792 from LenAnderson/fa-picker-alt-classnames

Make alternative class names searchable in FontAwesome icon picker | /pick-icon
This commit is contained in:
Cohee 2024-09-06 17:29:40 +03:00 committed by GitHub
commit b83cfa07c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -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.toLowerCase())));
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);
}
}

View File

@ -5453,6 +5453,7 @@ body:not(.movingUI) .drawer-content.maximized {
content: 'No icons found';
color: var(--SmartThemeBodyColor);
opacity: 0.7;
width: max-content;
}
#AdvancedFormatting .autoSetHeight {