1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-03-06 22:09:47 +01:00

Fix bug where last char of inline node couldn't be selected with keyboard (#626)

Fix bug where first char of inline node couldn't be selected with keyboard
This commit is contained in:
Per-Kristian Nordnes 2017-02-25 02:19:29 +01:00 committed by Ian Storm Taylor
parent 4f04d48cdc
commit 0cfd106a2d

View File

@ -491,11 +491,12 @@ function Plugin(options = {}) {
const previousBlock = document.getClosestBlock(previous.key)
const previousInline = document.getClosestInline(previous.key)
if (previousBlock == startBlock && previousInline && !previousInline.isVoid) {
if (previousBlock === startBlock && previousInline && !previousInline.isVoid) {
const extendOrMove = data.isShift ? 'extendBackward' : 'moveBackward'
return state
.transform()
.collapseToEndOf(previous)
.moveBackward(1)
[extendOrMove](1)
.apply()
}
@ -562,10 +563,11 @@ function Plugin(options = {}) {
const nextInline = document.getClosestInline(next.key)
if (nextBlock == startBlock && nextInline) {
const extendOrMove = data.isShift ? 'extendForward' : 'moveBackward'
return state
.transform()
.collapseToStartOf(next)
.moveForward(1)
[extendOrMove](1)
.apply()
}