Create a new CSS property for filter #6141
javadsamiee
started this conversation in
General
Replies: 3 comments 2 replies
-
It looks like the editor.StyleManager.addProperty('filters', {
name: 'Opacity',
property: 'filter',
type: 'slider',
units: ['%'],
defaults: '100%',
min: 0,
max: 100,
step: 1,
toStyle(value, unit) {
let currentFilters = this.getStyle()['filter'] || '';
currentFilters = currentFilters.replace(/opacity\(\d+%\)/, '').trim();
return `${currentFilters} opacity(${value}${unit})`.trim();
},
fromStyle(style) {
const match = style.match(/opacity\((\d+)%\)/);
return match ? match[1] : '100';
},
}); |
Beta Was this translation helpful? Give feedback.
2 replies
-
@javadsamiee You can use this lib https://github.com/GrapesJS/style-filter/ |
Beta Was this translation helpful? Give feedback.
0 replies
-
yeah, unfortunately |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to create a new property for
filter: opacity(80%);
https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/opacity
I want to use "toStyle" and "fromStyle" to create it and this is my code that I have used
But the result is
filter: 5%
notfilter: opacity(5%)
, how can I improve it?Beta Was this translation helpful? Give feedback.
All reactions