|
|
@@ -16,7 +16,7 @@ class RichTextEditor extends Component {
|
|
|
);
|
|
|
}
|
|
|
componentDidMount() {
|
|
|
- const { content, onContentChange } = this.props;
|
|
|
+ const { content, onContentChange, readOnly } = this.props;
|
|
|
const elem = this.refs.editorElem;
|
|
|
const editor = new E(elem);
|
|
|
editor.customConfig.onchange = (html) => {
|
|
|
@@ -26,6 +26,9 @@ class RichTextEditor extends Component {
|
|
|
}
|
|
|
}; // 使用 onchange 函数监听内容的变化
|
|
|
editor.customConfig.onfocus = () => {
|
|
|
+ if(readOnly) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.setState({
|
|
|
_html: editor.txt.html()
|
|
|
});
|
|
|
@@ -64,6 +67,8 @@ class RichTextEditor extends Component {
|
|
|
editor.create()
|
|
|
// editor.blur();
|
|
|
editor.txt.html(content);
|
|
|
+
|
|
|
+ editor.$textElem.attr('contenteditable', !readOnly)
|
|
|
}
|
|
|
}
|
|
|
|