mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-17 04:34:00 +02:00
fix inserting nodes in empty documents
This commit is contained in:
@@ -46,7 +46,14 @@ export const NodeTransforms = {
|
||||
// no selection, insert at the end of the document since that is such a
|
||||
// common use case when inserting from a non-selected state.
|
||||
if (!at) {
|
||||
at = selection || Editor.end(editor, []) || [editor.children.length]
|
||||
if (editor.selection) {
|
||||
at = editor.selection
|
||||
} else if (editor.children.length > 0) {
|
||||
at = Editor.end(editor, [])
|
||||
} else {
|
||||
at = [0]
|
||||
}
|
||||
|
||||
select = true
|
||||
}
|
||||
|
||||
|
@@ -17,5 +17,3 @@ export const output = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const skip = true
|
||||
|
Reference in New Issue
Block a user