Skip to content

Added TextNode.selectEnd / Renamed TextNode.selectAfter to .selectNext#109

Merged
zurfyx merged 1 commit into
mainfrom
select-end
Feb 19, 2021
Merged

Added TextNode.selectEnd / Renamed TextNode.selectAfter to .selectNext#109
zurfyx merged 1 commit into
mainfrom
select-end

Conversation

@zurfyx

@zurfyx zurfyx commented Feb 19, 2021

Copy link
Copy Markdown
Member

selectAfter works well most of the times. But there's some cases when the next Node is immutable that you either want to move the cursor before or after, not to the immutable node.

For reference:

if (nextSibling === null || !(nextSibling instanceof TextNode) || nextSibling.isImmutable() || nextSibling.isSegmented()) {
  throw new Error('This needs to be fixed');
}

This diff doesn't implement a recursive solution to the immutable nodes to follow, but the introduction of selectEnd should fix the first, move the cursor just at the end of the node you're working with.

That said, this diff is very opinionated so I'm happy to drop it entirely.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 19, 2021
@trueadm

trueadm commented Feb 19, 2021

Copy link
Copy Markdown
Collaborator

So you want it to select the end of the immutable/segmented node? I thought this would break, because these types of nodes are marked as "contenteditable=false", so they should never be part of the selectable editor space.

@zurfyx

zurfyx commented Feb 19, 2021

Copy link
Copy Markdown
Member Author

@trueadm - The end of a mutable node. Place the cursor just at the end of that node

@trueadm

trueadm commented Feb 19, 2021

Copy link
Copy Markdown
Collaborator

This seems to break a bunch of tests, mind looking into it?

@zurfyx

zurfyx commented Feb 19, 2021

Copy link
Copy Markdown
Member Author

@trueadm - Sorry, shouldn't have published a half-baked PR. Added a new test for selectEnd and fixed the broken ones

@zurfyx zurfyx merged commit e15c20f into main Feb 19, 2021
@yangshun yangshun deleted the select-end branch February 22, 2021 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants