Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting text in the TextEditor no longer works #5545

Closed
maximlt opened this issue Sep 27, 2023 · 2 comments · Fixed by #5609
Closed

Pasting text in the TextEditor no longer works #5545

maximlt opened this issue Sep 27, 2023 · 2 comments · Fixed by #5609

Comments

@maximlt
Copy link
Member

maximlt commented Sep 27, 2023

Pasting text in the TextEditor no longer works. That's the error logged in the browser console when you try to paste in the widget:

quill.js:3065 Uncaught TypeError: Cannot read properties of null (reading 'offset')
    at quill.js:3065:26
    at Array.map (<anonymous>)
    at Selection.normalizedToRange (quill.js:3059:31)
    at Selection.getRange (quill.js:3042:24)
    at Selection.update (quill.js:3229:28)
    at HTMLDocument.<anonymous> (panel.min.js?v=c47f5b18b8a430e698b9fe15e51f6119984e78334bcf3f45e210d30c37ef2f9e:135:2379)
@maximlt
Copy link
Member Author

maximlt commented Oct 9, 2023

The TextEditor widget is implemented based on QuillJS, which hasn't been updated in a while and doesn't yet support the shadow DOM. A good summary of this can be found in:

After Panel moved to Bokeh 3, the TextEditor widget was patched twice to improve its support in the shadow DOM:

Both patches were inspired from https://stackoverflow.com/questions/67914657/quill-editor-inside-shadow-dom/67944380#67944380, the author of this answer can also be found on Quill's Github slab/quill#2961 (comment).
A somewhat similar patch can be found here slab/quill#2021 (comment), it was suggested a few days after the other one.

The copy/paste issue has also been reported on Quill's issue tracker a few times:

I haven't yet seen a solution that fixes the issue, I haven't tried them all though and I could easily miss it 🙃


I've tried a few things to fix the issue, without luck so far. It seems the issue doesn't occur on Firefox.

@maximlt
Copy link
Member Author

maximlt commented Oct 11, 2023

In my quest for finding a fix for this, I found this interesting PR nuxeo/quill#2 where they are patching Quill directly and replacing the shadow-selection-polyfill with an alternative. This branch slab/quill@develop...nuxeo:quill:2.0.0-NX, apparently built on top of the 2.0dev branch of Quill (that is a few years old) has a few commits to add support to the Shadow DOM. It's been last published two years ago https://www.npmjs.com/package/@nuxeo/quill.

I'm pretty sure we'll get hit back by some of these Shadow DOM issues with Quill, when that happens, trying out @nuxeo/quill might be an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant