1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-03 12:12:39 +02:00

change schema plugin to be returned from function (#3252)

* change schema plugin to be returned from function

* fix forced-layout example
This commit is contained in:
Ian Storm Taylor
2019-12-05 15:29:02 -05:00
committed by GitHub
parent be1ce2e099
commit 90d40fd764
5 changed files with 158 additions and 159 deletions

View File

@@ -2,9 +2,9 @@ import React, { useState, useCallback, useMemo } from 'react'
import { Slate, Editable, withReact } from 'slate-react'
import { Editor, createEditor } from 'slate'
import { withHistory } from 'slate-history'
import { withSchema } from 'slate-schema'
import { defineSchema } from 'slate-schema'
const schema = [
const withSchema = defineSchema([
{
for: 'node',
match: 'editor',
@@ -36,14 +36,14 @@ const schema = [
}
},
},
]
])
const ForcedLayoutExample = () => {
const [value, setValue] = useState(initialValue)
const [selection, setSelection] = useState(null)
const renderElement = useCallback(props => <Element {...props} />, [])
const editor = useMemo(
() => withSchema(withHistory(withReact(createEditor())), schema),
() => withSchema(withHistory(withReact(createEditor()))),
[]
)
return (