Eric Mauldin
Aug 16 · 1 min read

Hi Siobhan,

I am getting the same error as Shin. This is the code I have…

highlightPlugin.js

import { RichUtils } from “draft-js”;export default () => {return {customStyleMap: {HIGHLIGHT: {background: “#fffe0d”}},keyBindingFn: e => {if (e.metaKey && e.key === “h”) {return “highlight”;}},handleKeyCommand: (command, editorState, { setEditorState }) => {if (command === “highlight”) {setEditorState(RichUtils.toggleInlineStyle(editorState, “HIGHLIGHT”));return true;}}};};

TextEditor.js

import React, { Component } from 'react'import { EditorState, RichUtils } from 'draft-js'import Editor from 'draft-js-plugins-editor'import createHighlightPlugin from './plugins/highlightPlugin'const highlightPlugin = createHighlightPlugin();class TextEditor extends Component {state = {editorState: EditorState.createEmpty(),}plugins = [highlightPlugin,]onChange = (editorState) => {this.setState({editorState})}handleKeyCommand = (command) => {const newState = RichUtils.handleKeyCommand(this.state.editorState, command)if (newState) {this.onChange(newState)return 'handled'}return 'not-handled'}onUnderlineClick = () => {this.onChange(RichUtils.toggleInlineStyle(this.state.editorState, 'UNDERLINE'))}onBoldClick = () => {this.onChange(RichUtils.toggleInlineStyle(this.state.editorState, 'BOLD'))}onItalicClick = () => {this.onChange(RichUtils.toggleInlineStyle(this.state.editorState, 'ITALIC'))}onHighlightClick = () => {this.onChange(RichUtils.toggleInlineStyle(this.state.editorState, 'HIGHLIGHT'))}render() {return (<div><button onClick={this.onUnderlineClick}><u>U</u></button><button onClick={this.onBoldClick}><b>B</b></button><button onClick={this.onItalicClick}><em>I</em></button><button className="highlight" onClick={this.onHighlightClick}><span style={{background: 'yellow'}}>H</span></button><div className="editors"><EditoreditorState={this.state.editorState}handleKeyCommand={this.handleKeyCommand}onChange={this.onChange}plugins={this.plugins}/></div></div>)}}export default TextEditor

Any thoughts? Thank you in advance!

    Eric Mauldin

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade