整合TinyMCE WYSIWYG HTML Editor到React Native应用

时间:2018-07-13 02:58:56

标签: javascript react-native webview tinymce wysiwyg

我正在尝试将TinyMCE所见即所得HTML编辑器合并到一个响应本机WebView组件中。有执行此任务的方法吗?

1 个答案:

答案 0 :(得分:1)

我在react-native WebView组件中添加了Tinymce WYSIWYG编辑器。我的Webview组件如下所示:

<WebView
 source={require("./WebView.html")}
 style={{width: Dwidth, height: Dheight}}
 onMessage={(event)=>{
 const x= event.nativeEvent.data;
 console.log("x: ",x);
 console.log("Type is: ",typeof(x));
 }}
/>

相应的WebView.html文件:

<head>
<style>
    body {
        padding: 5px;
    }
</style>
<script src="./tinymce.full.js?apiKey=i4g7q0a13kkgwt8x1ydpxethphasaeqgnk09733db5uk2roi">

</script>

<script>
    tinymce.init({
        selector: '#mytextarea'
    });

    function manipulateForm() {
        var textContent = tinymce.activeEditor.getContent({format: 'raw'});
        manipulateFormNew(textContent);
    }

    function manipulateFormNew(textContent) {
        alert(textContent);
        window.postMessage(textContent);
    }
</script>
</head>
<body>
 <form name="myForm" onSubmit="return manipulateForm()" method="post">
  <textarea id="mytextarea">Please Share your thoughts here</textarea>
  <input type="submit" id="submit__button" value="Post Your Thoughts">
 </form>
</body>

此处tinymce.full.js文件包含Tinymce JavaScript代码。同一目录还包含其他Tinymce资源,例如外观,主题,样式等文件。