mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-27 00:54:22 +02:00
Fixes deleteWordForward at line ending (#2290)
#### Is this adding or improving a _feature_ or fixing a _bug_? Bug fix - Very minor change #### What's the new behavior? `deleteWordBackward` at line ending behaves the same as `deleteCharForward` #### How does this change work? If `TextUtils.getWordOffsetForward(text, o)` returns 0, instead we substitute in `1` to delete the line break and join the blocks. The relevant test for this change (`join-blocks`) is also added. #### Have you checked that...? <!-- Please run through this checklist for your pull request: --> * [x] The new code matches the existing patterns and styles. * [x] The tests pass with `yarn test`. * [x] The linter passes with `yarn lint`. (Fix errors with `yarn prettier`.) * [x] The relevant examples still work. (Run examples with `yarn watch`.) #### Does this fix any issues or need any specific reviewers? Fixes: #2258 Reviewers: @ianstormtaylor
This commit is contained in:
committed by
Ian Storm Taylor
parent
bcc61a0bb2
commit
611fa85b80
@@ -455,7 +455,8 @@ Commands.deleteWordForwardAtRange = (change, range) => {
|
||||
const offset = startBlock.getOffset(start.key)
|
||||
const o = offset + start.offset
|
||||
const { text } = startBlock
|
||||
const n = TextUtils.getWordOffsetForward(text, o)
|
||||
const wordOffset = TextUtils.getWordOffsetForward(text, o)
|
||||
const n = wordOffset === 0 ? 1 : wordOffset
|
||||
change.deleteForwardAtRange(range, n)
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,28 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
|
||||
export default function(change) {
|
||||
change.deleteWordForward()
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
word<cursor />
|
||||
</paragraph>
|
||||
<paragraph>another</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
word<cursor />another
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
Reference in New Issue
Block a user