1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-01 05:16:10 +01:00

Fix delete undo (#2240)

* Fix undo after a selection snapshot

* Add a test to cover the text deletion case

* Fix lint

* Use the new whitoutMerging flag instead

* cleanup + fix function call
This commit is contained in:
inkubux 2018-10-09 15:13:03 -04:00 committed by Ian Storm Taylor
parent de9a07900e
commit 933c938765
3 changed files with 37 additions and 3 deletions

View File

@ -606,7 +606,9 @@ Changes.setStart = (change, ...args) => {
}
Changes.snapshotSelection = change => {
change.select(change.value.selection, { snapshot: true })
change.withoutMerging(c =>
c.select(change.value.selection, { snapshot: true })
)
}
/**

View File

@ -47,11 +47,10 @@ class Change {
* history if needed.
*
* @param {Operation|Object} operation
* @param {Object} options
* @return {Change}
*/
applyOperation(operation, options = {}) {
applyOperation(operation) {
const { operations } = this
let { value } = this
let { history } = value

View File

@ -0,0 +1,33 @@
/** @jsx h */
import h from '../../helpers/h'
export default function(value) {
return value
.change()
.moveAnchorForward(4)
.moveFocusForward(7)
.delete()
.value.change()
.undo().value
}
export const input = (
<value>
<document>
<paragraph>
<cursor />one two
</paragraph>
</document>
</value>
)
export const output = (
<value>
<document>
<paragraph>
one <anchor />two<focus />
</paragraph>
</document>
</value>
)