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 =>{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: '