1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-24 07:52:50 +02:00

Fix forced layout example (#3294)

This commit is contained in:
Dylan Markow
2019-12-10 22:58:40 -06:00
committed by Ian Storm Taylor
parent 26b67578d4
commit 28c31c2c0c

View File

@@ -1,12 +1,12 @@
import React, { useState, useCallback, useMemo } from 'react'
import { Slate, Editable, withReact } from 'slate-react'
import { Editor, createEditor } from 'slate'
import { Editor, createEditor, Node } from 'slate'
import { withHistory } from 'slate-history'
const withLayout = editor => {
const { normalizeNode } = editor
editor.normalizeNode = path => {
editor.normalizeNode = ([node, path]) => {
if (path.length === 0) {
if (editor.children.length < 1) {
const title = { type: 'title', children: [{ text: 'Untitled' }] }
@@ -27,7 +27,7 @@ const withLayout = editor => {
}
}
return normalizeNode(path)
return normalizeNode([node, path])
}
return editor