diff --git a/site/examples/forced-layout.tsx b/site/examples/forced-layout.tsx index 2ec9bb135..116b358ae 100644 --- a/site/examples/forced-layout.tsx +++ b/site/examples/forced-layout.tsx @@ -6,6 +6,7 @@ import { Node, Element as SlateElement, Descendant, + Editor, } from 'slate' import { withHistory } from 'slate-history' import { ParagraphElement, TitleElement } from './custom-types' @@ -15,12 +16,15 @@ const withLayout = editor => { editor.normalizeNode = ([node, path]) => { if (path.length === 0) { - if (editor.children.length < 1) { + if (editor.children.length <= 1 && Editor.string(editor, [0, 0]) === '') { const title: TitleElement = { type: 'title', children: [{ text: 'Untitled' }], } - Transforms.insertNodes(editor, title, { at: path.concat(0) }) + Transforms.insertNodes(editor, title, { + at: path.concat(0), + select: true, + }) } if (editor.children.length < 2) {