Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createEditor(plugins: TextConfig['plugins']): Editor {
let editor = withEdtr(withReact(createSlateEditor()))
plugins.forEach(withPlugin => {
editor = withPlugin(editor)
})
return editor
function withEdtr(editor: T): T & Editor {
const e = editor as T & Editor
e.controls = []
e.onKeyDown = () => {}
e.renderEditable = ({ children }) => {
return children
}
// eslint-disable-next-line react/display-name
e.renderElement = ({ attributes, children }) => {
return <div>{children}</div>
}
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
const editor = useMemo(() => withReact(createEditor()), [])
return (
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return (
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
const decorate = useCallback(([node, path]) => {
const editor = useMemo(() => withReact(createEditor()), [])
return (
() => withImages(withHistory(withReact(createEditor()))),
[]
() => withHtml(withReact(withHistory(createEditor()))),
[]
() => withLinks(withHistory(withReact(createEditor()))),
[]
() => withMentions(withReact(withHistory(createEditor()))),
[]