首页
学习
活动
专区
圈层
工具
发布

(TinyMce)
EN

Stack Overflow用户
提问于 2015-03-20 14:40:11
回答 1查看 6K关注 0票数 7

我在为React搜索HTML,但由于我没有发现任何有用的东西(我只需要格式化文本h1、h2、h3、p、粗体和base64图像)

最后,我决定使用微型Mce,它工作得很好。但只有当第一次打开页面时。如果我再读到那一页。如果没有浏览器放松,则不会初始化tinymce。你知道在这种情况下会发生什么反应事件吗?到目前为止,这是我的小包装:

代码语言:javascript
复制
/** @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;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-24 12:19:43

要解决这个问题,我必须在卸载时删除TinyMce实例。

代码语言:javascript
复制
componentWillUnmount: function() {
    tinymce.remove('#' + this.props.lang + '-editor');
}
票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29169158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档