Q: Why does WebViewer crash with the following error when I add a sticky note comment? I am using Google Tag Manager.
A: Google Tag Manager may swap out Text
nodes in the DOM to use the class from the parent window instead of the iframe that WebViewer is running in. This causes an instance check to fail in Quill (iframe) and trigger a different case.
To workaround this, you can force the iframe to use the top-level window’s Text
class. This can be done by setting the following code when WebViewer mounts:
const scrollView = instance.Core.documentViewer.getScrollViewElement();
const iframeWindow = scrollView.ownerDocument.defaultView;
iframeWindow.Text = iframeWindow.top.Text;
However, Quill may revert back to the old class after the comment closes in the notes panel.
The best solution is to share the same Text
class throughout and to accomplish that, WebComponent
should help.
Otherwise, you may have to change the open source UI to perform the swapping when necessary.