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:
@@ -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) ||
|
||||
|
@@ -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]
|
@@ -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]
|
Reference in New Issue
Block a user