Pause mutationObserver to allow styling?

Currently it’s very difficult to experiment with styles in development because adding an inline style, a class, and ID; any of that will instantly be erased.

Adding the code to properly implement dynamic styles can be quite difficult and not being able to test them beforehand is a big problem.

Is there something I’m overlooking here?

The issue seems to be caused by this code in prosemirror-view:

this.observer = window.MutationObserver &&
            new window.MutationObserver(mutations => {
                for (let i = 0; i < mutations.length; i++)
                    this.queue.push(mutations[i]);
            });

I sometimes use the trick of assigning someElement.innerHTML = someElement.innerHTML to get a non-scripted version of the content of a DOM element.

2 Likes

Thank you so much for sharing that tip; it works great!

@marijn is there some trick to this I’m overlooking? I keep trying to set it on an H1 which has an associated widget or on the entire editor but the mutation observer reigns supreme still.

I know I had it working with some other elements and I’m not sure what the difference may be here.