Remove the wrapper when the child component is deleted
Question
Hi! I created a DOM component
domc.addType('text', {
model: textModel.extend({
defaults: Object.assign({}, textModel.prototype.defaults, {
'custom-name': 'Text',
selectable: false,
hoverable: false,
draggable: true,
droppable: false,
layerable: true,
editable: false,
badgable: false,
stylable:false,
highlightable: true,
tagName: 'div',
classes: ['text'],
style: {
display: 'flex',
'justify-content': 'center',
'font-family': "'Overpass', sans-serif !important",
'padding': '5px 0'
},
components: {
tagName: 'div',
'custom-name': 'Text',
selectable: true,
hoverable: true,
draggable: false,
layerable: true,
editable: true,
type: 'text',
components: 'The point of using dummy text for your paragraph is that it has a more-or-less normal distribution of letters. making it look like readable English.',
style: {
color: '#666666',
'font-size': '16px',
'text-align': 'center',
'font-family': 'Overpass, sans-serif'
},
}
}),
removed () {
console.log("element was deleted")
},
}, {
isComponent(el) {
if(el && el.classList.contains('text')) {
return {type: 'text'};
}
}
}),
view: textView
});
and I was thinking whether it is possible to delete the div wrapper when I delete the child text component. I tried to do it with the removed hook but couldn't came up with the correct solution. Thanks!
Answers (0)
No answers yet.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1148
Script in component get messed up, any idea?
I created a component like const TWITTERTYPE = 'TWITTER'; domc.addType(TWITTERTYPE, { model: defaultModel.extend({ defaults: { ...defaultMo...
Issue #738
image reverted to original size after resized
hi, i got a strange issue with component: i got 2 types, image and icon the issue is when i first drag and drop the image component, i'm ab...
Issue #1959
[Question] Edit innerHTML in a custom button
Hi All, I am trying to change the text in a button component, but I am not able to edit it. I added this type: I included the editable: tru...
Issue #2405
[QUESTIONS] ckeditor is not initialized when replace trait text
why when i change the ckeditor trait text it is not initialized my trait <pre> domComps.addType('text',{ model: dModel.extend({ defaults: O...
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.