Skip to content

improvement(caret): caret.setToBlock() offset argument improved #2922

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

Merged
merged 4 commits into from
Apr 30, 2025

Conversation

neSpecc
Copy link
Member

@neSpecc neSpecc commented Mar 29, 2025

This PR improves the behavior of the offset argument of caret.setToBlock() method

Right now it uses internal offset of last/first text node. But it should compute offset across the whole block content.

The problem is in use of $.getDeepestNode() — it just returns first or last deepest node. I implemented getNodeByOffset() method what returns deepest text node by passed offset.

Before

// 1234<b>567</b>
setCaret(block, undefined, 6)
// 1234|<b>567<b>

After

// 1234<b>567</b>
setCaret(block, undefined, 6)
// 1234<b>56|7<b>

@neSpecc neSpecc merged commit 7da61e9 into next Apr 30, 2025
6 checks passed
@neSpecc neSpecc deleted the caret-offset branch April 30, 2025 16:48
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.

1 participant