Issue #3569Opened June 26, 2021by sktlmarat0 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.