mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-21 22:45:18 +02:00
FIX findPoint offset may be include zero width string (#2982)
* FIX point offset may be include zero width string * fix prettier style * FIX prettier style
This commit is contained in:
@@ -51,7 +51,11 @@ function findPoint(nativeNode, nativeOffset, editor) {
|
||||
// into \r\n. The bug causes a loop when slate-react attempts to reposition
|
||||
// its cursor to match the native position. Use textContent.length instead.
|
||||
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10291116/
|
||||
offset = range.cloneContents().textContent.length
|
||||
const fragment = range.cloneContents()
|
||||
const zeroWidthNodes = fragment.querySelectorAll(
|
||||
`[${DATA_ATTRS.ZERO_WIDTH}]`
|
||||
)
|
||||
offset = fragment.textContent.length - zeroWidthNodes.length
|
||||
} else {
|
||||
// For void nodes, the element with the offset key will be a cousin, not an
|
||||
// ancestor, so find it by going down from the nearest void parent.
|
||||
|
Reference in New Issue
Block a user