diff --git a/packages/slate/src/changes/at-range.js b/packages/slate/src/changes/at-range.js index f47796240..2f9420f5d 100644 --- a/packages/slate/src/changes/at-range.js +++ b/packages/slate/src/changes/at-range.js @@ -322,7 +322,7 @@ Changes.deleteWordBackwardAtRange = (change, range, options) => { const offset = startBlock.getOffset(start.key) const o = offset + start.offset const { text } = startBlock - const n = TextUtils.getWordOffsetBackward(text, o) + const n = o === 0 ? 1 : TextUtils.getWordOffsetBackward(text, o) change.deleteBackwardAtRange(range, n, options) } diff --git a/packages/slate/test/changes/at-current-range/delete-word-backward/join-blocks.js b/packages/slate/test/changes/at-current-range/delete-word-backward/join-blocks.js new file mode 100644 index 000000000..88075c003 --- /dev/null +++ b/packages/slate/test/changes/at-current-range/delete-word-backward/join-blocks.js @@ -0,0 +1,28 @@ +/** @jsx h */ + +import h from '../../../helpers/h' + +export default function(change) { + change.deleteWordBackward() +} + +export const input = ( + + + word + + another + + + +) + +export const output = ( + + + + wordanother + + + +)