Skip to content

Commit

Permalink
accomodate rt colorpicker
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartromanek committed Dec 4, 2024
1 parent 818241d commit 2f82d5e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion modules/@apostrophecms/rich-text-widget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,9 @@ module.exports = {
// HSL colors
/^hsl\(\s*\d{1,3}(?:deg)?\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/,
// HSLA colors
/^hsla\(\s*\d{1,3}(?:deg)?\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*,\s*(?:0?\.\d+|1(?:\.0)?)\s*\)$/
/^hsla\(\s*\d{1,3}(?:deg)?\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*,\s*(?:0?\.\d+|1(?:\.0)?)\s*\)$/,
// CSS Variable value
/^var\(--[a-zA-Z0-9-]+\)$/
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,16 @@ export default defineComponent({
};
const update = (value) => {
tinyColorObj.value = new TinyColor(value.hsl);
next.value = tinyColorObj.value.toString(format.value);
props.editor.chain().focus().setColor(next.value).run();
let color;
if (value._cssVariable) {
next.value = value._cssVariable;
color = `var(${next.value})`;
} else {
tinyColorObj.value = new TinyColor(value.hsl);
next.value = tinyColorObj.value.toString(format.value);
color = next.value;
}
props.editor.chain().focus().setColor(color).run();
indicatorColor.value = next.value;
};
Expand Down

0 comments on commit 2f82d5e

Please sign in to comment.