mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-12 10:14:02 +02:00
Fix triple-click contenteditable="false"
error (#5343)
This commit is contained in:
@@ -754,6 +754,17 @@ export const ReactEditor = {
|
||||
)
|
||||
}
|
||||
|
||||
// COMPAT: Triple-clicking a word in chrome will sometimes place the focus
|
||||
// inside a `contenteditable="false"` DOM node following the word, which
|
||||
// will cause `toSlatePoint` to throw an error. (2023/03/07)
|
||||
if (
|
||||
'getAttribute' in focusNode &&
|
||||
(focusNode as HTMLElement).getAttribute('contenteditable') === 'false'
|
||||
) {
|
||||
focusNode = anchorNode
|
||||
focusOffset = anchorNode.textContent?.length || 0
|
||||
}
|
||||
|
||||
let anchor = ReactEditor.toSlatePoint(editor, [anchorNode, anchorOffset], {
|
||||
exactMatch,
|
||||
suppressThrow,
|
||||
|
Reference in New Issue
Block a user