mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-11 09:43:58 +02:00
Collapse expanded selection before move word (#4211)
This commit is contained in:
@@ -915,12 +915,22 @@ export const Editable = (props: EditableProps) => {
|
||||
|
||||
if (Hotkeys.isMoveWordBackward(nativeEvent)) {
|
||||
event.preventDefault()
|
||||
|
||||
if (selection && Range.isExpanded(selection)) {
|
||||
Transforms.collapse(editor, { edge: 'focus' })
|
||||
}
|
||||
|
||||
Transforms.move(editor, { unit: 'word', reverse: !isRTL })
|
||||
return
|
||||
}
|
||||
|
||||
if (Hotkeys.isMoveWordForward(nativeEvent)) {
|
||||
event.preventDefault()
|
||||
|
||||
if (selection && Range.isExpanded(selection)) {
|
||||
Transforms.collapse(editor, { edge: 'focus' })
|
||||
}
|
||||
|
||||
Transforms.move(editor, { unit: 'word', reverse: isRTL })
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user