1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-29 18:09:49 +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:
Slapbox
2018-08-07 19:21:30 -04:00
committed by Ian Storm Taylor
parent 1efe55602f
commit 4d97496299
2 changed files with 29 additions and 1 deletions

View File

@@ -322,7 +322,7 @@ Changes.deleteWordBackwardAtRange = (change, range, options) => {
const offset = startBlock.getOffset(start.key) const offset = startBlock.getOffset(start.key)
const o = offset + start.offset const o = offset + start.offset
const { text } = startBlock const { text } = startBlock
const n = TextUtils.getWordOffsetBackward(text, o) const n = o === 0 ? 1 : TextUtils.getWordOffsetBackward(text, o)
change.deleteBackwardAtRange(range, n, options) change.deleteBackwardAtRange(range, n, options)
} }

View File

@@ -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>
)