GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.36k stars 4.05k forks source link

BUG: textnode is not removed from canvas #2918

Closed neon12345 closed 4 years ago

neon12345 commented 4 years ago

Text imported directly to the wrapper is not removed from the canvas with the component.

To verify one can import simple texts multiple times to the demo and watch how they combine instead of replacing the previous one.

Adding this seems to help:

    editor.DomComponents.addType('textnode', {
        model: {
            removed() {
                var el = this.getEl();
                el.parentNode.removeChild(el);
            }
        }
    });

Tested with the demo v0.16.18.

artf commented 4 years ago

I don't follow your example, can you illustrate exact steps to reproduce, please?

neon12345 commented 4 years ago

Go to the newsletter demo at https://grapesjs.com/demo-newsletter-editor.html and use the "Import template" function with simple text like "hello" but no html (or combine it with html and text on the root level). Repeat this and the text on the root level will not be removed but add up on each import.

artf commented 4 years ago

Thanks @neon12345, I was able to find the issue and it should be fixed in the next release