mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-07-31 20:40:19 +02:00
Fix triple-click contenteditable="false"
error (#5343)
This commit is contained in:
5
.changeset/lucky-falcons-reflect.md
Normal file
5
.changeset/lucky-falcons-reflect.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix error when triple-clicking a word preceding a `contenteditable="false"` DOM node in Chrome
|
@@ -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], {
|
let anchor = ReactEditor.toSlatePoint(editor, [anchorNode, anchorOffset], {
|
||||||
exactMatch,
|
exactMatch,
|
||||||
suppressThrow,
|
suppressThrow,
|
||||||
|
Reference in New Issue
Block a user