Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/oakfang/draft-js-regex-decorator

A RegEx based DraftJS decorator
https://github.com/oakfang/draft-js-regex-decorator

Last synced: 20 days ago
JSON representation

A RegEx based DraftJS decorator

Awesome Lists containing this project

README

        

# draft-js-regex-decorator

A RegEx based DraftJS decorator

## Usage:

```jsx
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 ;
}
```