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

fix(extension-table): update selection position when inserting a new … #5151

Conversation

wilson-everlaw
Copy link
Contributor

@wilson-everlaw wilson-everlaw commented May 14, 2024

…table

Typically when inserting a new table we want to select within the first cell of the newly inserted table. This change should ensure that occurs even if the original selection's head precedes the anchor.

fix #5143

Changes Overview

Using the selection's from instead of anchor is a better approach since the user may be making a selection where the head precedes the anchor

Implementation Approach

Changed the selection offset from tr.selection.anchor + 1 to tr.selection.from + 1

Testing Done

Made a selection from the end of the doc to the beginning, inserted a table and see that there is no error and that the selection is set to within the first cell.

Verification Steps

  • Start with an empty editor
  • Add content to the editor ensuring that it exceeds 44 characters
  • Select the entire content starting from the end of the editor to the beginning of the editor to ensure that the selection's head precedes the anchor
  • Insert a 3x3 table
  • See that there is no error and that the selection is within the first cell

Additional Notes

Checklist

  • I have renamed my PR according to the naming conventions. (e.g. feat: Implement new feature or chore(deps): Update dependencies)
  • My changes do not break the library.
  • I have added tests where applicable.
  • I have followed the project guidelines.
  • I have fixed any lint issues.

Related Issues

#5143

…table

Typically when inserting a new table we want to select within the first cell of the newly inserted
table. This change should ensure that occurs even if original selection's head precedes the anchor.

fix ueberdosis#5143
Copy link

netlify bot commented May 14, 2024

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 0105e9e
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/6643e041a0dd0b0008570760
😎 Deploy Preview https://deploy-preview-5151--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nperez0111 nperez0111 merged commit b45fb70 into ueberdosis:main Jun 7, 2024
14 checks passed
@nperez0111
Copy link
Contributor

Thank you for your contribution @wilson-everlaw it will go into the next release, and I'll make a beta with it soon

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

Successfully merging this pull request may close these issues.

[Bug]: Insert Table Command Uncaught Range Error
2 participants