mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-24 17:23:07 +01:00
Fix dirty path normalization on move_node (#2536)
* Add failing tests on undo nested node merge * Fix PathUtils transform on move_node operations
This commit is contained in:
parent
1ce7c7cc89
commit
1564c3a031
@ -351,9 +351,17 @@ function transform(path, operation) {
|
||||
const npAbove = isAbove(np, path)
|
||||
|
||||
if (pAbove) {
|
||||
path = np.concat(path.slice(p.size))
|
||||
if (isAfter(np, p)) {
|
||||
path = decrement(np, 1, min(np, p) - 1).concat(path.slice(p.size))
|
||||
} else {
|
||||
path = np.concat(path.slice(p.size))
|
||||
}
|
||||
} else if (pEqual) {
|
||||
path = np
|
||||
if (isAfter(np, p)) {
|
||||
path = decrement(np, 1, min(np, p) - 1)
|
||||
} else {
|
||||
path = np
|
||||
}
|
||||
} else {
|
||||
if (pYounger) {
|
||||
path = decrement(path, 1, pIndex)
|
||||
|
@ -0,0 +1,30 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../../helpers/h'
|
||||
|
||||
export default function(editor) {
|
||||
editor.deleteBackward()
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>Hello</paragraph>
|
||||
<list>
|
||||
<item>
|
||||
<cursor />world!
|
||||
</item>
|
||||
</list>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
Hello<cursor />world!
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
@ -0,0 +1,33 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../helpers/h'
|
||||
|
||||
export default function(editor) {
|
||||
editor.deleteBackward().undo()
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>Hello</paragraph>
|
||||
<list>
|
||||
<item>
|
||||
<cursor />world!
|
||||
</item>
|
||||
</list>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>Hello</paragraph>
|
||||
<list>
|
||||
<item>
|
||||
<cursor />world!
|
||||
</item>
|
||||
</list>
|
||||
</document>
|
||||
</value>
|
||||
)
|
29
packages/slate/test/history/undo/delete-backward.js
Normal file
29
packages/slate/test/history/undo/delete-backward.js
Normal file
@ -0,0 +1,29 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from '../../helpers/h'
|
||||
|
||||
export default function(editor) {
|
||||
editor.deleteBackward().undo()
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>Hello</paragraph>
|
||||
<paragraph>
|
||||
<cursor />world!
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>Hello</paragraph>
|
||||
<paragraph>
|
||||
<cursor />world!
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user