我已经使用 RichUtils 实现了高亮显示,但它没有高亮显示。我已经尝试了很多方法并使用 react-draft-wysiwyg。你能帮我解决一下吗?
编辑器.js
//Imports I used
import { EditorState, RichUtils } from "draft-js";
import { Editor } from "react-draft-wysiwyg";
//StyleMap object
const styleMap = {
HIGHLIGHT: {
backgroundColor: "#fdaed27",
},
};
//Highlight Function
_onHighlightClick() {
this.onChange(
RichUtils.toggleInlineStyle(this.state.editorState, "HIGHLIGHT")
);
}
return(
<div
onClick={this._onHighlightClick.bind(this)}
className="editor-options-txt-hghlgt"
>
<img
src="https://img.icons8.com/ios-filled/50/000000/h.png"
alt="Highlight"
width="20px"
height="20px"
/>
</div>
<Editor
customStyleMap={styleMap}
editorState={this.state.editorState}
onEditorStateChange={this.onChange}
/>
)