1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 18:39:51 +02:00

Fix path transform against sibling move operations (#3675)

This commit is contained in:
Jason Tamulonis
2020-05-27 17:19:41 -07:00
committed by GitHub
parent 97a7e8a469
commit 9054d3a381
3 changed files with 36 additions and 0 deletions

View File

@@ -391,6 +391,12 @@ export const Path = {
}
return copy.concat(p.slice(op.length))
} else if (Path.isSibling(op, p) && Path.equals(onp, p)) {
if (Path.endsBefore(op, p)) {
p[op.length - 1] -= 1
} else {
p[op.length - 1] += 1
}
} else if (
Path.endsBefore(onp, p) ||
Path.equals(onp, p) ||

View File

@@ -0,0 +1,15 @@
import { Path } from 'slate'
const path = [0, 1]
const op = {
type: 'move_node',
path: [0, 3],
newPath: [0, 1],
}
export const test = () => {
return Path.transform(path, op)
}
export const output = [0, 2]

View File

@@ -0,0 +1,15 @@
import { Path } from 'slate'
const path = [0, 1]
const op = {
type: 'move_node',
path: [0, 0],
newPath: [0, 1],
}
export const test = () => {
return Path.transform(path, op)
}
export const output = [0, 0]