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

TextSelection warning from prosemirror-state 1.4.0 #2846

Closed
1 of 2 tasks
andy1li opened this issue Jun 4, 2022 · 6 comments · Fixed by #2934
Closed
1 of 2 tasks

TextSelection warning from prosemirror-state 1.4.0 #2846

andy1li opened this issue Jun 4, 2022 · 6 comments · Fixed by #2934
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@andy1li
Copy link

andy1li commented Jun 4, 2022

What’s the bug you are facing?

Tiptap (or more precisely, prosemirror-state 1.4.0) throws out a warning in my tests, when using tiptap's editor.commands.setContent():

TextSelection endpoint not pointing into a node with inline content (doc)

warning

Which browser was this experienced in? Are any special extensions installed?

It's not in the browser, but in the happy-dom environment of vitest.

How can we reproduce the bug on our side?

I made this minimal repo:

https://github.com/andy1li/text-selection-test-warning

npm run test

Can you provide a CodeSandbox?

https://stackblitz.com/github/andy1li/text-selection-test-warning

What did you expect to happen?

No TextSelection warning should appear. Can we do something in tiptap to make it go away?

Anything to add? (optional)

The warning seems to be from checkTextSelection() in prosemirror-state 1.4.0 (released at the end of May):

https://github.com/ProseMirror/prosemirror-state/blob/f1c2ff98a397aa05b9ccf5ee23642bb7e44f05a7/src/selection.ts#L221

It seems that prosemirror-state 1.3.4 from more than a year ago does not have the new checkTextSelection() function.

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@andy1li andy1li added the Type: Bug The issue or pullrequest is related to a bug label Jun 4, 2022
@andy1li
Copy link
Author

andy1li commented Jun 4, 2022

Temporarily solved the problem, by using the method from NeoDobby.

@andy1li
Copy link
Author

andy1li commented Jun 21, 2022

Just saying: the #2854 PR (chore: migrate to new versions of prosemirror packages) did not fix the problem described above.

@bdbch
Copy link
Member

bdbch commented Jun 21, 2022

I'll investigate this issue when I find some time, thanks for bringing it up

@bdbch
Copy link
Member

bdbch commented Jun 26, 2022

@andy1li

Can you reproduce this issue in the browser? It's not a test but I tried to replicate that warning in this sandbox:
https://1pvl9b.csb.app/

I can't see any comparable warning message - no matter if the editor has initial content or not. As far as I understood this is a warning that was introduced in prosemirror-state 1.4.0.

@andy1li
Copy link
Author

andy1li commented Jun 26, 2022

Sure, @bdbch. Thank you for your time~

I've modified my minimal repo a bit. Now the warning should appear in the browser console.

https://stackblitz.com/github/andy1li/text-selection-test-warning?file=src%2Fmain.ts


Perhaps it's because my use case is not very typical:

On my backend, tiptap is used in a normal fashion to do some custom markups.

On my frontend, tiptap is used (without attaching editor into the dom) to only parse those custom markups into JSON, which is rendered with custom components.

@bdbch
Copy link
Member

bdbch commented Jun 27, 2022

Hey @andy1li I created a PR (see #2934) that should fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants