mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-15 19:54:02 +02:00
* fix issue #3651 where initial click on a void block can cause the editor to crash * simplify non null cast for editor to element weakmap retrieve * get prettier to shut up * fixed comment
This commit is contained in:
@@ -145,9 +145,20 @@ export const Editable = (props: EditableProps) => {
|
||||
return
|
||||
}
|
||||
|
||||
// If the DOM selection is already correct, we're done.
|
||||
// verify that the dom selection is in the editor
|
||||
const editorElement = EDITOR_TO_ELEMENT.get(editor)!
|
||||
let hasDomSelectionInEditor = false
|
||||
if (
|
||||
editorElement.contains(domSelection.anchorNode) &&
|
||||
editorElement.contains(domSelection.focusNode)
|
||||
) {
|
||||
hasDomSelectionInEditor = true
|
||||
}
|
||||
|
||||
// If the DOM selection is in the editor and the editor selection is already correct, we're done.
|
||||
if (
|
||||
hasDomSelection &&
|
||||
hasDomSelectionInEditor &&
|
||||
selection &&
|
||||
Range.equals(ReactEditor.toSlateRange(editor, domSelection), selection)
|
||||
) {
|
||||
|
Reference in New Issue
Block a user