Skip to content

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