added "note color"

This commit is contained in:
zadam
2022-09-25 14:19:30 +02:00
parent a9c0daa51a
commit 1d26fd6bf0
6 changed files with 44 additions and 2 deletions

View 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
};