Text disappear after creating a new type
Question
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() {...}
}),
});
Answers (3)
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.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #518
change only component body not whole page body.
Hello @artf As we discussed in issue #374. setComponents will set the body and replace all the contents that are present on the page with a...
Issue #1106
traits setting not work after reload
Hello @artf previous issue Yes, you're right traits are there but you didn't read the my issues those I'm facing. 1. when you drag and drop...
Issue #1109
[QUESTION] Column blocks not droppable in canvas
Morning @artf :) I'm experiencing an similar problem to this issue. I can't drop any block (text, image, etc.) inside the column block from...
Issue #980
[BUG] Related with task https://github.com/artf/grapesjs/issues/873
Hello, After restoring editor from db still have some part of bug present. It seems inside of script: function () traits will have old valu...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.