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

Cannot read position pos of undefined in autolink.ts #3250

Closed
1 of 2 tasks
ScopeyNZ opened this issue Sep 28, 2022 · 2 comments · Fixed by #3251
Closed
1 of 2 tasks

Cannot read position pos of undefined in autolink.ts #3250

ScopeyNZ opened this issue Sep 28, 2022 · 2 comments · Fixed by #3251
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@ScopeyNZ
Copy link
Contributor

What’s the bug you are facing?

Right now, if you are using both the image extension, and the link extension, you can cause the editor to crash with an error by dragging an image into the editor.

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

Browser: Chrome latest.
Relevant extensions: image and link

How can we reproduce the bug on our side?

Have a look at the CodeSandbox. It appears as though the steps are:

  • Use ProseMirror with both the link and image extensions,
  • Drag an image into the editor

Can you provide a CodeSandbox?

Here's a codesandbox https://codesandbox.io/s/small-thunder-k9wl2m?file=/src/App.vue

What did you expect to happen?

No error, but nothing in the editor should happen.

Anything to add? (optional)

Happy to raise a PR. My fix would be to add a check on the nodesInChangedRange array in the condition below to check that the array is not empty:

https://github.com/ueberdosis/tiptap/blob/main/packages/extension-link/src/helpers/autolink.ts#L76-L79

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. 💖
@ScopeyNZ ScopeyNZ added the Type: Bug The issue or pullrequest is related to a bug label Sep 28, 2022
ScopeyNZ added a commit to ScopeyNZ/tiptap that referenced this issue Sep 28, 2022
@ScopeyNZ
Copy link
Contributor Author

I raised a PR anyway for consideration.

@ScopeyNZ
Copy link
Contributor Author

ScopeyNZ commented Sep 28, 2022

I've actually just discovered that even providing a button to add an image (as demo'd in the docs) will also break it. I've updated the code sandbox with a button. This makes me feel like I've done something wrong.

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.

1 participant