Remove the wrapper when the child component is deleted
Thanks for reporting this, @sktlmarat. Thanks for sharing your report about Remove the wrapper when the child component is deleted. To help the team investigate and prioritize this: Please provide: A minimal reproducible example (CodeSandbox/JSFiddle) Your GrapesJS version number Browser and OS information Any error m...
Read full answer below ↓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 (1)
Thanks for reporting this, @sktlmarat.
Thanks for sharing your report about Remove the wrapper when the child component is deleted. To help the team investigate and prioritize this:
Please provide:
- A minimal reproducible example (CodeSandbox/JSFiddle)
- Your GrapesJS version number
- Browser and OS information
- Any error messages from the browser console
- Steps to reproduce the issue
What helps most:
- Minimal code example (not your full project)
- Screen recording or screenshot showing the issue
- Expected vs actual behavior clearly stated
- GrapesJS configuration you're using
With these details, the maintainers can identify and prioritize a fix much faster. The GrapesJS team is very responsive to well-documented issues.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #4752
Component with pointer-events: 'all' (except wrapper) or editable component are draggable & droppable to itself.
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome 107.0.5304.121 (Official Build) (arm6...
Issue #3512
Child elements not draggable ,droppable highlightable. also the CSS of all child elements not pushed in style section while develop a banner component in as plugin
Hello @artf , I am trying to develop a simple banner plugin which will be include a heading , subheading and link. and every element can be...
Issue #3335
Creating trait with Style Manager property UI
I have a component using the background-url Style Manager property: I would like to reuse this UI that is shown in the Style Manager for a...
Issue #5720
Propagating component defaults can break layers when child comments are introduced
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v122 Reproducible demo link https:/...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Tutorial
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins — TinyMCE Inline Text Editor and Placeholder.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.