mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-04-21 13:51:59 +02:00
make create methods more helpful
This commit is contained in:
parent
06d4216146
commit
b3b16227bc
@ -695,13 +695,11 @@ const Node = {
|
||||
// character if one exists.
|
||||
const prev = characters.get(startOffset - 1)
|
||||
const marks = prev ? prev.marks : null
|
||||
const newChars = Character.createList(
|
||||
text.split('').map((char) => {
|
||||
const obj = { text: char }
|
||||
if (marks) obj.marks = marks
|
||||
return Character.create(obj)
|
||||
})
|
||||
)
|
||||
const newChars = Character.createList(text.split('').map((char) => {
|
||||
const obj = { text: char }
|
||||
if (marks) obj.marks = marks
|
||||
return obj
|
||||
}))
|
||||
|
||||
// Splice in the new characters.
|
||||
characters = characters.slice(0, startOffset)
|
||||
@ -939,7 +937,7 @@ const Node = {
|
||||
const secondBlock = Block.create({
|
||||
type: firstBlock.type,
|
||||
data: firstBlock.data,
|
||||
nodes: Block.createMap([secondChild])
|
||||
nodes: [secondChild]
|
||||
})
|
||||
|
||||
// Replace the block in the parent with the two new blocks.
|
||||
@ -981,12 +979,9 @@ const Node = {
|
||||
|
||||
// While the parent is an inline parent, split the inline nodes.
|
||||
while (parent = node.getClosestInline(firstChild)) {
|
||||
debugger
|
||||
const firstNodes = Inline.createMap([firstChild])
|
||||
const secondNodes = Inline.createMap([secondChild])
|
||||
firstChild = parent.merge({ nodes: firstNodes })
|
||||
firstChild = parent.merge({ nodes: [firstChild] })
|
||||
secondChild = Inline.create({
|
||||
nodes: secondNodes,
|
||||
nodes: [secondChild],
|
||||
type: parent.type,
|
||||
data: parent.data
|
||||
})
|
||||
@ -1294,10 +1289,8 @@ const Node = {
|
||||
|
||||
// Iterate each of the child nodes, wrapping them.
|
||||
children.forEach((child) => {
|
||||
const wrappedNodes = Inline.createMap([child])
|
||||
|
||||
const obj = {}
|
||||
obj.nodes = wrappedNodes
|
||||
obj.nodes = [child]
|
||||
obj.type = type
|
||||
if (data) obj.data = data
|
||||
const wrapper = Inline.create(obj)
|
||||
|
Loading…
x
Reference in New Issue
Block a user