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

[Bug]: Can't paste links onto AllSelection when editor is empty #5994

Closed
1 task done
Nantris opened this issue Jan 7, 2025 · 3 comments
Closed
1 task done

[Bug]: Can't paste links onto AllSelection when editor is empty #5994

Nantris opened this issue Jan 7, 2025 · 3 comments
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@Nantris
Copy link
Contributor

Nantris commented Jan 7, 2025

Affected Packages

core

Version(s)

2.11.0

Bug Description

When you use Ctrl+A on an empty editor prior to pasting with the keyboard, nothing happens when you paste links

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

Paste of link occurs

Additional Context (Optional)

Reproducible in: https://templates.tiptap.dev/phF77NHFHR

Dependency Updates

  • Yes, I've updated all my dependencies.
@Nantris Nantris added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Jan 7, 2025
@guanriyue
Copy link
Contributor

I also reproduced this issue. The problem lies in this piece of code.

options.editor.commands.setMark(options.type, {
href: link.href,
})
return true
},

I recorded a video to demonstrate it. Suppose the editor contains two empty paragraph nodes. When using Ctrl+A to select all, the actual selection.from is in the first paragraph, and selection.to is in the second paragraph.
At this point, the clipboard contains a link. When pasting, this.editor.commands.setMark(this.type, { href: link.href }); fails to execute but the event handler still returns true, which prevents the default paste behavior from being triggered.

2025-01-07.11.19.48.mov

Changing the above code to the following can fix this issue:

return this.editor.commands.setMark(this.type, {
  href: link.href,
});

@nperez0111
Copy link

Happy to take this as a PR ^

guanriyue pushed a commit to guanriyue/tiptap that referenced this issue Jan 9, 2025
… the editor content is empty and the editor is in a 'select all' state. See details at [issue#5994](ueberdosis#5994)
@nperez0111
Copy link

Resolved with version 2.11.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

3 participants