mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
add jsDoc and allow custom icon lists
This commit is contained in:
@ -1899,18 +1899,26 @@ export function getFreeName(name, list, numberFormatter = (n) => ` #${n}`) {
|
|||||||
return `${name}${numberFormatter(counter)}`;
|
return `${name}${numberFormatter(counter)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function showFontAwesomePicker() {
|
export async function fetchFaFile(name) {
|
||||||
const fetchFa = async(name)=>{
|
const style = document.createElement('style');
|
||||||
const style = document.createElement('style');
|
style.innerHTML = await (await fetch(`/css/${name}`)).text();
|
||||||
style.innerHTML = await (await fetch(`/css/${name}`)).text();
|
document.head.append(style);
|
||||||
document.head.append(style);
|
const sheet = style.sheet;
|
||||||
const sheet = style.sheet;
|
style.remove();
|
||||||
style.remove();
|
return [...sheet.cssRules].filter(it=>it.style?.content).map(it=>it.selectorText.split('::').shift().slice(1));
|
||||||
return [...sheet.cssRules].filter(it=>it.style?.content).map(it=>it.selectorText.split('::').shift().slice(1));
|
}
|
||||||
};
|
export async function fetchFa() {
|
||||||
const faList = [...new Set((await Promise.all([
|
return [...new Set((await Promise.all([
|
||||||
fetchFa('fontawesome.min.css'),
|
fetchFaFile('fontawesome.min.css'),
|
||||||
])).flat())];
|
])).flat())];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Opens a popup with all the available Font Awesome icons and returns the selected icon's name.
|
||||||
|
* @prop {string[]} customList A custom list of Font Awesome icons to use instead of all available icons.
|
||||||
|
* @returns {Promise<string>} The icon name (fa-pencil) or null if cancelled.
|
||||||
|
*/
|
||||||
|
export async function showFontAwesomePicker(customList = null) {
|
||||||
|
const faList = customList ?? await fetchFa();
|
||||||
const fas = {};
|
const fas = {};
|
||||||
const dom = document.createElement('div'); {
|
const dom = document.createElement('div'); {
|
||||||
const search = document.createElement('div'); {
|
const search = document.createElement('div'); {
|
||||||
|
Reference in New Issue
Block a user