mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 21:36:05 +01:00
added "note color"
This commit is contained in:
27
src/public/app/services/css_class_manager.js
Normal file
27
src/public/app/services/css_class_manager.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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)) {
|
||||
$("head").append(`<style>.${className} { color: ${color} !important; }</style>`);
|
||||
|
||||
registeredClasses.add(className);
|
||||
}
|
||||
|
||||
return className;
|
||||
}
|
||||
|
||||
export default {
|
||||
createClassForColor
|
||||
};
|
||||
Reference in New Issue
Block a user