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: marks at the start of the selection #5725

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

WindRunnerMax
Copy link
Contributor

Description
When the selection is at the end of the previous node, using Editor.marks retrieves the marks of the previous node. In this case, calling Editor.addMark does not override the previous node, thus causing the states to be out of sync.

Issue
Fixes: #5724

Example

Before the fix:

When fixed:

Context

Thanks to the fix in #5580 , we can easily address this issue. By swapping the positions of anchor and focus according to Range.isBackward, we can then proceed with the original correction logic.

Additionally, since Editor.nodes calls Range.edges to recalibrate the order of anchor and focus, it won't affect the original Editor.marks logic.

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

Copy link

changeset-bot bot commented Sep 21, 2024

🦋 Changeset detected

Latest commit: 6e46989

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
slate Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dylans dylans merged commit f31167c into ianstormtaylor:main Sep 26, 2024
11 checks passed
@github-actions github-actions bot mentioned this pull request Sep 26, 2024
This was referenced Oct 16, 2024
z2devil pushed a commit to z2devil/slate that referenced this pull request Dec 6, 2024
* fix: marks at the start of the selection

* chore: modify unit test description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't toggle marks when selection is created with keyboard
2 participants