mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-01-17 13:38:37 +01:00
Fix triple-click contenteditable="false"
error (#5343)
This commit is contained in:
parent
bc07cf8c86
commit
f7f02a8b23
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], {
|
||||
exactMatch,
|
||||
suppressThrow,
|
||||
|
Loading…
x
Reference in New Issue
Block a user