@draft-js-modules/editor
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@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

/@draft-js-modules/editor/

    Package Sidebar

    Install

    npm i @draft-js-modules/editor

    Weekly Downloads

    1

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    57.3 kB

    Total Files

    10

    Last publish

    Collaborators

    • muniftanjim