mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-02 03:32:36 +02: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:
committed by
Ian Storm Taylor
parent
de9a07900e
commit
933c938765
@@ -606,7 +606,9 @@ Changes.setStart = (change, ...args) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Changes.snapshotSelection = change => {
|
Changes.snapshotSelection = change => {
|
||||||
change.select(change.value.selection, { snapshot: true })
|
change.withoutMerging(c =>
|
||||||
|
c.select(change.value.selection, { snapshot: true })
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -47,11 +47,10 @@ class Change {
|
|||||||
* history if needed.
|
* history if needed.
|
||||||
*
|
*
|
||||||
* @param {Operation|Object} operation
|
* @param {Operation|Object} operation
|
||||||
* @param {Object} options
|
|
||||||
* @return {Change}
|
* @return {Change}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
applyOperation(operation, options = {}) {
|
applyOperation(operation) {
|
||||||
const { operations } = this
|
const { operations } = this
|
||||||
let { value } = this
|
let { value } = this
|
||||||
let { history } = value
|
let { history } = value
|
||||||
|
33
packages/slate/test/history/undo/remove-text.js
Normal file
33
packages/slate/test/history/undo/remove-text.js
Normal 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>
|
||||||
|
)
|
Reference in New Issue
Block a user