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]: insertContentAt should either document that it changes selection or it should not change selection #4213

Closed
1 of 2 tasks
Nantris opened this issue Jul 13, 2023 · 2 comments
Assignees
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Triage: Open A new issue or pullrequest that requires triage (added by default) Type: Bug The issue or pullrequest is related to a bug

Comments

@Nantris
Copy link
Contributor

Nantris commented Jul 13, 2023

Which packages did you experience the bug in?

core

What Tiptap version are you using?

2.1.0-rc.11

What’s the bug you are facing?

I find it frustrating that insertContentAt changes the selection. This severely limits its usefulness and this behavior is undocumented. There's no suggestion it will affect selection but it does.

What browser are you using?

Chrome

Code example

No response

What did you expect to happen?

insertContentAt inserts content only, without changing selection.

Anything to add? (optional)

If it's necessary to change the selection then it should come with an option to revert the selection after.

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. 💖
@Nantris Nantris added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Triage: Open A new issue or pullrequest that requires triage (added by default) Type: Bug The issue or pullrequest is related to a bug labels Jul 13, 2023
@svenadlung
Copy link
Contributor

Hi @slapbox, changing the selection after inserting content is the default behavior. Have you tried this?

editor.commands.insertContentAt(12, '<p>Hello world</p>', { updateSelection: false })

editor.commands.insertContentAt(12, '<p>Hello world</p>', {

@Nantris
Copy link
Contributor Author

Nantris commented Jul 14, 2023

Wow I just totally missed that option in the docs. Thanks for the tip!

The various options for commands might benefit from being bolded in the docs like:

updateSelection: controls if the selection should be moved to the newly inserted content.

Or alternatively, I'd suggest that yellow background not be used for inline code. It guides the eye a little too much.

@Nantris Nantris closed this as completed Jul 14, 2023
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. Triage: Open A new issue or pullrequest that requires triage (added by default) Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

3 participants