@zbanx/lexical-rich-text-editor
v0.0.1-alpha.5
Published
A simple rich text editor based on lexical.
Downloads
19
Keywords
Readme
README
import '@zbanx/lexical-rich-text-editor/styles.css'
import React, { useCallback, useMemo, useState } from 'react'
import { LoadHtmlPlugin, TextEditor } from '@zbanx/lexical-rich-text-editor'
import type { TextEditorState } from '@zbanx/lexical-rich-text-editor'
export default function App() {
const [state, setState] = useState<TextEditorState>({})
const style = useMemo<React.CSSProperties>(
() => ({
minHeight: 100,
maxHeight: 200,
overflow: 'auto'
}),
[]
)
const upload = useCallback(async (file: File) => {
await new Promise((resolve) => setTimeout(resolve, 500))
return { url: URL.createObjectURL(file) }
}, [])
return (
<TextEditor
state={state}
setState={setState}
style={style}
upload={upload}
>
<LoadHtmlPlugin html={`<p><span style="font-size:18px; font-weight:bold;">Hello world!</span></p>`} />
</TextEditor>
)
}