我在为React搜索HTML,但由于我没有发现任何有用的东西(我只需要格式化文本h1、h2、h3、p、粗体和base64图像)
最后,我决定使用微型Mce,它工作得很好。但只有当第一次打开页面时。如果我再读到那一页。如果没有浏览器放松,则不会初始化tinymce。你知道在这种情况下会发生什么反应事件吗?到目前为止,这是我的小包装:
/** @jsx React.DOM */
var React = require('react');
var TinyMceEditor = React.createClass({
componentDidMount: function() {
var that = this;
tinymce.init({
selector: "textarea.tiny-mce-editor",
setup : function(editor) {
editor.on('change', function(e) {
that.props.onChange(editor.getContent());
});
},
plugins: [
"lists link image charmap print preview anchor",
"searchreplace code fullscreen",
"insertdatetime media table contextmenu paste"
],
toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
tinyMCE.get(that.props.lang + '-editor').setContent(that.props.html);
},
render:function(){
return (
<div>
<textarea ref="text" className="tiny-mce-editor" id={this.props.lang + '-editor'} />
</div>
)
}
});
module.exports = TinyMceEditor;发布于 2015-03-24 12:19:43
要解决这个问题,我必须在卸载时删除TinyMce实例。
componentWillUnmount: function() {
tinymce.remove('#' + this.props.lang + '-editor');
}https://stackoverflow.com/questions/29169158
复制相似问题