admin管理员组文章数量:1315221
I was searching for an HTML Editor for React, but since I found nothing that works fine (I just need to format Text h1, h2, h3, p, bold and images [in base64])
At the end I decided to use Tiny Mce, which works fine. But only when the page gets opened for the first time. If I get to that page again. Without a browser relaod, then tinymce is not initialized. Do you know what react event will be triggered in such a situation. Here is my little wrapper so far:
/** @jsx React.DOM */
var React = require('react');
var TinyMceEditor = React.createClass({
ponentDidMount: 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;
I was searching for an HTML Editor for React, but since I found nothing that works fine (I just need to format Text h1, h2, h3, p, bold and images [in base64])
At the end I decided to use Tiny Mce, which works fine. But only when the page gets opened for the first time. If I get to that page again. Without a browser relaod, then tinymce is not initialized. Do you know what react event will be triggered in such a situation. Here is my little wrapper so far:
/** @jsx React.DOM */
var React = require('react');
var TinyMceEditor = React.createClass({
ponentDidMount: 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;
Share
Improve this question
asked Mar 20, 2015 at 14:40
SafariSafari
3,3829 gold badges49 silver badges66 bronze badges
1 Answer
Reset to default 7To fix this I had to delete the TinyMce instance when unmounting.
ponentWillUnmount: function() {
tinymce.remove('#' + this.props.lang + '-editor');
}
本文标签: javascriptReact HTML Editor (TinyMce)Stack Overflow
版权声明:本文标题:javascript - React HTML Editor (TinyMce) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741982223a2408466.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论