mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-16 20:24:01 +02:00
fix wrapNodes for uneven blocks
This commit is contained in:
@@ -800,7 +800,7 @@ export const NodeTransforms = {
|
|||||||
const range = Editor.range(editor, firstPath, lastPath)
|
const range = Editor.range(editor, firstPath, lastPath)
|
||||||
const [commonNode] = Editor.node(editor, commonPath)
|
const [commonNode] = Editor.node(editor, commonPath)
|
||||||
const depth = commonPath.length + 1
|
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: [] }
|
const wrapper = { ...element, children: [] }
|
||||||
Editor.insertNodes(editor, wrapper, { at: wrapperPath, voids })
|
Editor.insertNodes(editor, wrapper, { at: wrapperPath, voids })
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
)
|
Reference in New Issue
Block a user