1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-17 13:38:37 +01: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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)
if (
'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
focusOffset = anchorNode.textContent?.length || 0