@draft-js-modules/editor
v0.1.0
Published
Editor component for Draft.js Modules
Downloads
3
Maintainers
Readme
@draft-js-modules/editor
Installation
# using npm:
npm install --save @draft-js-modules/editor
# using yarn:
yarn add @draft-js-modules/editor
Usage
import { Editor } from '@draft-js-modules/editor'
import { EditorState } from 'draft-js'
import 'draft-js/dist/Draft.css'
import React, { useCallback, useRef, useState } from 'react'
const modules = []
function DraftEditor() {
const store = useRef(null)
const [editorState, setEditorState] = useState(EditorState.createEmpty())
const onClick = useCallback(() => {
store.current.getEditor().focus()
}, [])
const onChange = useCallback(editorState => {
setEditorState(editorState)
}, [])
return (
<div onClick={onClick}>
<Editor
editorState={editorState}
onChange={onChange}
placeholder="Editor for Draft.js Modules"
modules={modules}
store={store}
/>
</div>
)
}
export default DraftEditor