Text disappear after creating a new type
Hello!
I am creating a new block that will open a modal during the creation (drag and drop https://github.com/artf/grapesjs/issues/174 really helped me and it works.
But it had a surprising side-effect: When I select and deselect a text component, the text disappear. Here is the code, I think I changed the defaultType property unintentionally:
var defaultType = editor.DomComponents.getType('default');
editor.DomComponents.addType('importType', {
model: defaultType.model.extend({
isComponent: function(el){
if(el.tagName == 'IMPORTTYPE'){
return {type: 'importType'};
}
},
}),
view: defaultType.view.extend({
init() {
this.listenTo(this.model, 'active', this.doStuff); // listen for active event
},
doStuff() {...}
}),
});
Wrong position for isComponent, it should be passed in the second argument object
defaultType.model.extend({
isComponent //<- wrong
}, {
isComponent //<- correct
})
So it's like not declaring it, and as mentioned in Components
As you're putting a new Component type on top of the stack, not declaring isComponent() might probably break stuff, especially if you extend the default one.
It works perfectly, thank you!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.