The discussion revolves around the NotFoundError: Node.removeChild: The node to be removed is not a child of this node error when using a theme component to remove elements in the composer preview.
magjac created a theme component that replaces BBCode with SVG, but encountered the error when typing a character after removing elements. magjac was able to reproduce the issue with a simple theme component.
david suggested that the composer preview’s Ember rendering engine is confused by the DOM changes and recommended hiding nodes instead of removing them. david confirmed that this is a quirk of the implementation and not a bug, with no plans to change it.
@riking shared their experience with a similar issue and provided a solution by creating a sacrificial div node for the widget to consume, leaving the original div intact.
The composer preview uses ember to render the cooked content. It looks like that error is coming from the ember rendering engine, which is probably confused by the DOM being changed by something else.
To avoid the issue, I suggest that you don’t remove() any nodes, and instead hide them using display:none; or something similar.
The composer preview is an unusual combination of ember rendering and custom ‘decorateCooked’ functions. It looks like this is a quirk of that implementation. We don’t have any plans to change the way it works at the moment, especially since the workaround is nice and simple.
@j.jaffeux I notice you have this cleanUp function passed to api.cleanupStream when you used WidgetGlue.
I’m getting the error in the OP when I try to write in the composer after my widget attaches. Notably, the original div data-wrap is completely gone after I target it with WidgetGlue.appendTo()…
EDIT: Solved. I create a sacrificial <div> node for the Widget to consume, so that I can leave the [wrap=dice] div alive.