I have a Rails project that's being gradually ported over to React. I need to render a Trix editor in both the old Rails UI and the new React UI. React-trix-rte throws Uncaught NotSupportedError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'trix-toolbar'. A type with that name is already registered. when require('trix') is present in application.js.
I can get around this by adding the check window.customElements.get("trix-editor")|| before r.registerElement("trix-editor") and window.customElements.get("trix-toolbar")|| before r.registerElement("trix-toolbar") in the minified JS but I can't seem to find where to add this check in the non-minified source of either this project or trix itself.
Thoughts on how to get around this issue? Thank you for your time!