我正在寻找一个用于 React 的 HTML 编辑器,但是因为我没有发现任何可以正常工作的东西(我只需要格式化文本 h1、h2、h3、p、粗体和图像 [在 base64 中])
最后我决定使用 Tiny Mce,效果很好。但只有在第一次打开页面时。如果我再次进入该页面。如果没有浏览器重新加载,则不会初始化 tinymce。你知道在这种情况下会触发什么react事件吗?到目前为止,这是我的小包装:
/** @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;