import isHotkey from 'is-hotkey' import React, { useCallback, useMemo, useState } from 'react' import { createPortal } from 'react-dom' import { Editor, createEditor } from 'slate' import { withHistory } from 'slate-history' import { Editable, ReactEditor, Slate, useSlate, withReact } from 'slate-react' import { Button, Icon, Toolbar } from './components' const HOTKEYS = { 'mod+b': 'bold', 'mod+i': 'italic', 'mod+u': 'underline', 'mod+`': 'code', } const IFrameExample = () => { const renderElement = useCallback( ({ attributes, children }) =>

{children}

, [] ) const renderLeaf = useCallback(props => , []) const editor = useMemo(() => withHistory(withReact(createEditor())), []) const handleBlur = useCallback(() => ReactEditor.deselect(editor), [editor]) return ( ) } const toggleMark = (editor, format) => { const isActive = isMarkActive(editor, format) if (isActive) { Editor.removeMark(editor, format) } else { Editor.addMark(editor, format, true) } } const isMarkActive = (editor, format) => { const marks = Editor.marks(editor) return marks ? marks[format] === true : false } const Leaf = ({ attributes, children, leaf }) => { if (leaf.bold) { children = {children} } if (leaf.code) { children = {children} } if (leaf.italic) { children = {children} } if (leaf.underline) { children = {children} } return {children} } const MarkButton = ({ format, icon }) => { const editor = useSlate() return ( ) } const IFrame = ({ children, ...props }) => { const [iframeBody, setIframeBody] = useState(null) const handleLoad = e => { const iframe = e.target if (!iframe.contentDocument) return setIframeBody(iframe.contentDocument.body) } return ( ) } const initialValue = [ { type: 'paragraph', children: [ { text: 'In this example, the document gets rendered into a controlled ', }, { text: '