mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-16 12:14:14 +02:00
Fix selection, if click event fired after (#3650)
This commit is contained in:
committed by
GitHub
parent
c1760127f1
commit
31709160a3
@@ -7,6 +7,7 @@ import {
|
|||||||
Range,
|
Range,
|
||||||
Text,
|
Text,
|
||||||
Transforms,
|
Transforms,
|
||||||
|
Path,
|
||||||
} from 'slate'
|
} from 'slate'
|
||||||
import throttle from 'lodash/throttle'
|
import throttle from 'lodash/throttle'
|
||||||
import scrollIntoView from 'scroll-into-view-if-needed'
|
import scrollIntoView from 'scroll-into-view-if-needed'
|
||||||
@@ -554,8 +555,16 @@ export const Editable = (props: EditableProps) => {
|
|||||||
const node = ReactEditor.toSlateNode(editor, event.target)
|
const node = ReactEditor.toSlateNode(editor, event.target)
|
||||||
const path = ReactEditor.findPath(editor, node)
|
const path = ReactEditor.findPath(editor, node)
|
||||||
const start = Editor.start(editor, path)
|
const start = Editor.start(editor, path)
|
||||||
|
const end = Editor.end(editor, path)
|
||||||
|
|
||||||
if (Editor.void(editor, { at: start })) {
|
const startVoid = Editor.void(editor, { at: start })
|
||||||
|
const endVoid = Editor.void(editor, { at: end })
|
||||||
|
|
||||||
|
if (
|
||||||
|
startVoid &&
|
||||||
|
endVoid &&
|
||||||
|
Path.equals(startVoid[1], endVoid[1])
|
||||||
|
) {
|
||||||
const range = Editor.range(editor, start)
|
const range = Editor.range(editor, start)
|
||||||
Transforms.select(editor, range)
|
Transforms.select(editor, range)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user