mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-29 09:59:48 +02:00
Fixes inability to deleteWordBackward at line start (#2046)
* Adds Unicode LF character to line endings for clipboard plaintext This addresses https://github.com/ianstormtaylor/slate/issues/1932 * Fixes plaintext/unicode pastes not having line breaks * Removes stray spaces for Prettier * Refactors Value creation to save 4 lines * Allows for Ctrl+Backspace on line start Previously Ctrl+Backspace would do nothing instead of continuing on to the above block. * Tests that deleteWordBackwards joins lines properly
This commit is contained in:
committed by
Ian Storm Taylor
parent
1efe55602f
commit
4d97496299
@@ -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)
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,28 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
|
||||
export default function(change) {
|
||||
change.deleteWordBackward()
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>word</paragraph>
|
||||
<paragraph>
|
||||
<cursor />another
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
word<cursor />another
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
Reference in New Issue
Block a user