mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-24 01:02:31 +01:00
Change concat into insertChildrenAfter and insertChildrenBefore (#232)
* Change concat into insertChildrenAfter and insertChildrenBefore * Update input and out yaml of insert block at range block-end * Update input and out yaml of insert block at range block-start
This commit is contained in:
parent
a10f0a7935
commit
10cfb6e48b
@ -261,14 +261,12 @@ const Transforms = {
|
||||
|
||||
// If the range is at the start of the block, insert before.
|
||||
else if (range.isAtStartOf(startBlock)) {
|
||||
nodes = nodes.concat(parent.nodes)
|
||||
parent = parent.merge({ nodes })
|
||||
parent = parent.insertChildrenBefore(startBlock, nodes)
|
||||
}
|
||||
|
||||
// If the range is at the end of the block, insert after.
|
||||
else if (range.isAtEndOf(startBlock)) {
|
||||
nodes = parent.nodes.concat(nodes)
|
||||
parent = parent.merge({ nodes })
|
||||
parent = parent.insertChildrenAfter(startBlock, nodes)
|
||||
}
|
||||
|
||||
// Otherwise, split the block and insert between.
|
||||
|
@ -5,3 +5,14 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
|
@ -10,3 +10,19 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: block
|
||||
type: image
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
|
@ -2,7 +2,7 @@
|
||||
export default function (state) {
|
||||
const { document, selection } = state
|
||||
const texts = document.getTexts()
|
||||
const first = texts.first()
|
||||
const first = texts.last()
|
||||
const range = selection.merge({
|
||||
anchorKey: first.key,
|
||||
anchorOffset: 0,
|
||||
|
@ -5,3 +5,14 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
|
@ -10,3 +10,19 @@ nodes:
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
- kind: block
|
||||
type: image
|
||||
nodes:
|
||||
- kind: text
|
||||
text: ""
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: word
|
||||
|
Loading…
x
Reference in New Issue
Block a user