draft-js-regex-decorator
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

draft-js-regex-decorator

A RegEx based DraftJS decorator

Usage:

import { Editor, EditorState, CompositeDecorator } from 'draft-js';
import createRegExDecorator from 'draft-js-regex-decorator';

function TextEditor() {
  const [editorState, setEditorState] = useState(EditorState.createEmpty());
  const onChange = editorState => {
    setEditorState(
      EditorState.set(editorState, {
        decorator: new CompositeDecorator(createRegExDecorator(/hello/gi)),
      })
    );
  };

  return <Editor {...{ editorState, onChange }} />;
}

Readme

Keywords

none

Package Sidebar

Install

npm i draft-js-regex-decorator

Weekly Downloads

2

Version

0.3.0

License

MIT

Unpacked Size

17.1 kB

Total Files

13

Last publish

Collaborators

  • oakfang