1
0
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:
Charley DAVID 2019-01-29 22:10:35 -02:00 committed by Ian Storm Taylor
parent 1ce7c7cc89
commit 1564c3a031
4 changed files with 102 additions and 2 deletions

View File

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

View File

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

View File

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

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