import React, { useMemo } from 'react' import { Editor, createEditor } from 'slate' import { Slate, Editable, withReact, useEditor, useFocused, useSelected, } from 'slate-react' const EmbedsExample = () => { const editor = useMemo(() => withEmbeds(withReact(createEditor())), []) return ( } placeholder="Enter some text..." /> ) } const withEmbeds = editor => { const { isVoid } = editor editor.isVoid = element => (element.type === 'video' ? true : isVoid(element)) return editor } const Element = props => { const { attributes, children, element } = props switch (element.type) { case 'video': return default: return

{children}

} } const VideoElement = ({ attributes, children, element }) => { const editor = useEditor() const selected = useSelected() const focused = useFocused() const { url } = element return (