1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-17 12:41:44 +02:00

Revert "in examples, move withReact in front of withHistory (#4604)" (#4607)

This reverts commit 9cf2f4eea2.
This commit is contained in:
Dylan Schiemann
2021-10-17 14:31:33 +01:00
committed by GitHub
parent 9cf2f4eea2
commit f1607da4ad
19 changed files with 20 additions and 20 deletions

View File

@@ -69,7 +69,7 @@ const CheckListsExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const renderElement = useCallback(props => <Element {...props} />, []) const renderElement = useCallback(props => <Element {...props} />, [])
const editor = useMemo( const editor = useMemo(
() => withReact(withChecklists(withHistory(createEditor()))), () => withChecklists(withHistory(withReact(createEditor()))),
[] []
) )

View File

@@ -13,7 +13,7 @@ const CodeHighlightingExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const [language, setLanguage] = useState('html') const [language, setLanguage] = useState('html')
const renderLeaf = useCallback(props => <Leaf {...props} />, []) const renderLeaf = useCallback(props => <Leaf {...props} />, [])
const editor = useMemo(() => withReact(withHistory(createEditor())), []) const editor = useMemo(() => withHistory(withReact(createEditor())), [])
// decorate function depends on the language selected // decorate function depends on the language selected
const decorate = useCallback( const decorate = useCallback(

View File

@@ -5,7 +5,7 @@ import { withHistory } from 'slate-history'
const PlainTextExample = () => { const PlainTextExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const editor = useMemo(() => withReact(withHistory(createEditor())), []) const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return ( return (
<Slate editor={editor} value={value} onChange={value => setValue(value)}> <Slate editor={editor} value={value} onChange={value => setValue(value)}>
<Editable <Editable

View File

@@ -11,7 +11,7 @@ import { EditableVoidElement } from './custom-types'
const EditableVoidsExample = () => { const EditableVoidsExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const editor = useMemo( const editor = useMemo(
() => withReact(withEditableVoids(withHistory(createEditor()))), () => withEditableVoids(withHistory(withReact(createEditor()))),
[] []
) )

View File

@@ -15,7 +15,7 @@ import {
const EmbedsExample = () => { const EmbedsExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const editor = useMemo(() => withReact(withEmbeds(createEditor())), []) const editor = useMemo(() => withEmbeds(withReact(createEditor())), [])
return ( return (
<Slate editor={editor} value={value} onChange={value => setValue(value)}> <Slate editor={editor} value={value} onChange={value => setValue(value)}>
<Editable <Editable

View File

@@ -65,7 +65,7 @@ const ForcedLayoutExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const renderElement = useCallback(props => <Element {...props} />, []) const renderElement = useCallback(props => <Element {...props} />, [])
const editor = useMemo( const editor = useMemo(
() => withReact(withLayout(withHistory(createEditor()))), () => withLayout(withHistory(withReact(createEditor()))),
[] []
) )
return ( return (

View File

@@ -16,7 +16,7 @@ import { Button, Icon, Menu, Portal } from '../components'
const HoveringMenuExample = () => { const HoveringMenuExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const editor = useMemo(() => withReact(withHistory(createEditor())), []) const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return ( return (
<Slate editor={editor} value={value} onChange={value => setValue(value)}> <Slate editor={editor} value={value} onChange={value => setValue(value)}>

View File

@@ -21,7 +21,7 @@ const IFrameExample = () => {
[] []
) )
const renderLeaf = useCallback(props => <Leaf {...props} />, []) const renderLeaf = useCallback(props => <Leaf {...props} />, [])
const editor = useMemo(() => withReact(withHistory(createEditor())), []) const editor = useMemo(() => withHistory(withReact(createEditor())), [])
const handleBlur = useCallback(() => ReactEditor.deselect(editor), [editor]) const handleBlur = useCallback(() => ReactEditor.deselect(editor), [editor])

View File

@@ -19,7 +19,7 @@ import { ImageElement } from './custom-types'
const ImagesExample = () => { const ImagesExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const editor = useMemo( const editor = useMemo(
() => withImages(withReact(withHistory(createEditor()))), () => withImages(withHistory(withReact(createEditor()))),
[] []
) )

View File

@@ -17,7 +17,7 @@ import { Button, Icon, Toolbar } from '../components'
const LinkExample = () => { const LinkExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const editor = useMemo( const editor = useMemo(
() => withLinks(withReact(withHistory(createEditor()))), () => withLinks(withHistory(withReact(createEditor()))),
[] []
) )

View File

@@ -11,7 +11,7 @@ import { css } from 'emotion'
const MarkdownPreviewExample = () => { const MarkdownPreviewExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const renderLeaf = useCallback(props => <Leaf {...props} />, []) const renderLeaf = useCallback(props => <Leaf {...props} />, [])
const editor = useMemo(() => withReact(withHistory(createEditor())), []) const editor = useMemo(() => withHistory(withReact(createEditor())), [])
const decorate = useCallback(([node, path]) => { const decorate = useCallback(([node, path]) => {
const ranges = [] const ranges = []

View File

@@ -29,7 +29,7 @@ const MarkdownShortcutsExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const renderElement = useCallback(props => <Element {...props} />, []) const renderElement = useCallback(props => <Element {...props} />, [])
const editor = useMemo( const editor = useMemo(
() => withReact(withShortcuts(withHistory(createEditor()))), () => withShortcuts(withReact(withHistory(createEditor()))),
[] []
) )
return ( return (

View File

@@ -21,7 +21,7 @@ const MentionExample = () => {
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const renderElement = useCallback(props => <Element {...props} />, []) const renderElement = useCallback(props => <Element {...props} />, [])
const editor = useMemo( const editor = useMemo(
() => withReact(withMentions(withHistory(createEditor()))), () => withMentions(withReact(withHistory(createEditor()))),
[] []
) )

View File

@@ -5,7 +5,7 @@ import { withHistory } from 'slate-history'
const PlainTextExample = () => { const PlainTextExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const editor = useMemo(() => withReact(withHistory(createEditor())), []) const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return ( return (
<Slate editor={editor} value={value} onChange={value => setValue(value)}> <Slate editor={editor} value={value} onChange={value => setValue(value)}>
<Editable placeholder="Enter some plain text..." /> <Editable placeholder="Enter some plain text..." />

View File

@@ -25,7 +25,7 @@ const RichTextExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const renderElement = useCallback(props => <Element {...props} />, []) const renderElement = useCallback(props => <Element {...props} />, [])
const renderLeaf = useCallback(props => <Leaf {...props} />, []) const renderLeaf = useCallback(props => <Leaf {...props} />, [])
const editor = useMemo(() => withReact(withHistory(createEditor())), []) const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return ( return (
<Slate editor={editor} value={value} onChange={value => setValue(value)}> <Slate editor={editor} value={value} onChange={value => setValue(value)}>

View File

@@ -50,7 +50,7 @@ const ScrollIntoViewExample = () => {
const PlainTextEditor = () => { const PlainTextEditor = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const editor = useMemo(() => withReact(withHistory(createEditor())), []) const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return ( return (
<Slate editor={editor} value={value} onChange={value => setValue(value)}> <Slate editor={editor} value={value} onChange={value => setValue(value)}>
<Editable placeholder="Enter some plain text..." /> <Editable placeholder="Enter some plain text..." />

View File

@@ -9,7 +9,7 @@ import { Icon, Toolbar } from '../components'
const SearchHighlightingExample = () => { const SearchHighlightingExample = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const [search, setSearch] = useState<string | undefined>() const [search, setSearch] = useState<string | undefined>()
const editor = useMemo(() => withReact(withHistory(createEditor())), []) const editor = useMemo(() => withHistory(withReact(createEditor())), [])
const decorate = useCallback( const decorate = useCallback(
([node, path]) => { ([node, path]) => {
const ranges = [] const ranges = []

View File

@@ -29,7 +29,7 @@ const ShadowDOM = () => {
const ShadowEditor = () => { const ShadowEditor = () => {
const [value, setValue] = useState<Descendant[]>(initialValue) const [value, setValue] = useState<Descendant[]>(initialValue)
const editor = useMemo(() => withReact(withHistory(createEditor())), []) const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return ( return (
<Slate editor={editor} value={value} onChange={value => setValue(value)}> <Slate editor={editor} value={value} onChange={value => setValue(value)}>

View File

@@ -15,7 +15,7 @@ const TablesExample = () => {
const renderElement = useCallback(props => <Element {...props} />, []) const renderElement = useCallback(props => <Element {...props} />, [])
const renderLeaf = useCallback(props => <Leaf {...props} />, []) const renderLeaf = useCallback(props => <Leaf {...props} />, [])
const editor = useMemo( const editor = useMemo(
() => withReact(withTables(withHistory(createEditor()))), () => withTables(withHistory(withReact(createEditor()))),
[] []
) )
return ( return (