1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 20:40:19 +02:00

Fixed triple click workaround breaking void elements selection (#5451)

* Fixed tripple click workaround breaking void selection

* Add changesets

* Fix ts error

* Make code style more consistent
This commit is contained in:
Grzegorz Tłuszcz
2023-06-16 14:01:12 +02:00
committed by GitHub
parent bac37cae81
commit 12ff246e10
2 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': minor
---
Fixed occasional crashes when selecting void elements in Chrome

View File

@@ -869,7 +869,8 @@ export const ReactEditor: ReactEditorInterface = {
// will cause `toSlatePoint` to throw an error. (2023/03/07) // will cause `toSlatePoint` to throw an error. (2023/03/07)
if ( if (
'getAttribute' in focusNode && 'getAttribute' in focusNode &&
(focusNode as HTMLElement).getAttribute('contenteditable') === 'false' (focusNode as HTMLElement).getAttribute('contenteditable') === 'false' &&
(focusNode as HTMLElement).getAttribute('data-slate-void') !== 'true'
) { ) {
focusNode = anchorNode focusNode = anchorNode
focusOffset = anchorNode.textContent?.length || 0 focusOffset = anchorNode.textContent?.length || 0