mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
29 lines
695 B
JavaScript
29 lines
695 B
JavaScript
const registeredClasses = new Set();
|
|
|
|
function createClassForColor(color) {
|
|
if (!color?.trim()) {
|
|
return "";
|
|
}
|
|
|
|
const normalizedColorName = color.replace(/[^a-z0-9]/gi, "");
|
|
|
|
if (!normalizedColorName.trim()) {
|
|
return "";
|
|
}
|
|
|
|
const className = `color-${normalizedColorName}`;
|
|
|
|
if (!registeredClasses.has(className)) {
|
|
// make the active fancytree selector more specific than the normal color setting
|
|
$("head").append(`<style>.${className}, span.fancytree-active.${className} { color: ${color} !important; }</style>`);
|
|
|
|
registeredClasses.add(className);
|
|
}
|
|
|
|
return className;
|
|
}
|
|
|
|
export default {
|
|
createClassForColor
|
|
};
|