1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-16 04:04:06 +02:00

fix wrapNodes for uneven blocks

This commit is contained in:
Ian Storm Taylor
2019-12-13 16:57:26 -05:00
parent f05cefa7a8
commit 7057bb2c4c
2 changed files with 49 additions and 1 deletions

View File

@@ -800,7 +800,7 @@ export const NodeTransforms = {
const range = Editor.range(editor, firstPath, lastPath)
const [commonNode] = Editor.node(editor, commonPath)
const depth = commonPath.length + 1
const wrapperPath = Path.next(lastPath).slice(0, depth)
const wrapperPath = Path.next(lastPath.slice(0, depth))
const wrapper = { ...element, children: [] }
Editor.insertNodes(editor, wrapper, { at: wrapperPath, voids })

View File

@@ -0,0 +1,48 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Editor.wrapNodes(editor, <block a />)
}
export const input = (
<editor>
<block>
<block>
wo
<anchor />
rd
</block>
<block>
<block>
an
<focus />
other
</block>
</block>
</block>
</editor>
)
export const output = (
<editor>
<block>
<block a>
<block>
wo
<anchor />
rd
</block>
<block>
<block>
an
<focus />
other
</block>
</block>
</block>
</block>
</editor>
)