mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-28 17:39:57 +02:00
add select
option to insertNodes
This commit is contained in:
@@ -23,14 +23,14 @@ export const NodeTransforms = {
|
||||
at?: Location
|
||||
match?: NodeMatch
|
||||
hanging?: boolean
|
||||
select?: boolean
|
||||
voids?: boolean
|
||||
} = {}
|
||||
) {
|
||||
Editor.withoutNormalizing(editor, () => {
|
||||
const { selection } = editor
|
||||
const { hanging = false, voids = false } = options
|
||||
let { at, match } = options
|
||||
let select = false
|
||||
let { at, match, select } = options
|
||||
|
||||
if (Node.isNode(nodes)) {
|
||||
nodes = [nodes]
|
||||
@@ -57,6 +57,10 @@ export const NodeTransforms = {
|
||||
select = true
|
||||
}
|
||||
|
||||
if (select == null) {
|
||||
select = false
|
||||
}
|
||||
|
||||
if (Range.isRange(at)) {
|
||||
if (!hanging) {
|
||||
at = Editor.unhangRange(editor, at)
|
||||
|
@@ -0,0 +1,34 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>
|
||||
<cursor />
|
||||
one
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const run = editor => {
|
||||
Editor.insertNodes(
|
||||
editor,
|
||||
<block>
|
||||
<text />
|
||||
</block>,
|
||||
{ at: [0], select: true }
|
||||
)
|
||||
}
|
||||
|
||||
export const output = (
|
||||
<editor>
|
||||
<block>
|
||||
<cursor />
|
||||
</block>
|
||||
<block>
|
||||
one
|
||||
</block>
|
||||
</editor>
|
||||
)
|
Reference in New Issue
Block a user