mirror of https://github.com/artf/grapesjs.git
nocodeframeworkdrag-and-dropsite-buildersite-generatortemplate-builderui-builderweb-builderweb-builder-frameworkwebsite-builderno-codepage-builder
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
728 B
28 lines
728 B
import { isArray } from 'underscore';
|
|
|
|
export default {
|
|
run(ed, sender, opts = {}) {
|
|
const { target } = opts;
|
|
const dc = ed.DomComponents;
|
|
const type = target.get('type');
|
|
const len = dc.getWrapper().find(`[data-gjs-type="${type}"]`).length;
|
|
const toRemove = [];
|
|
|
|
if (!len) {
|
|
const rules = ed.CssComposer.getAll();
|
|
let toClear = target.get('style-signature');
|
|
toClear = isArray(toClear) ? toClear : [toClear];
|
|
|
|
rules.forEach(rule => {
|
|
const selector = rule.selectorsToString();
|
|
toClear.forEach(part => {
|
|
part && selector.indexOf(part) >= 0 && toRemove.push(rule);
|
|
});
|
|
});
|
|
|
|
rules.remove(toRemove);
|
|
}
|
|
|
|
return toRemove;
|
|
}
|
|
};
|
|
|