富文本框:https://www.kancloud.cn/wangfupeng/wangeditor3/335774;
接受服务端 传输的数据显示到富文本框中:
<div id="textBox1" style="width:250px"></div>
<div id="edit" style="width:453px"></div>
服务端 出过来的数据样式:
"<p><img src="http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/40/pcmoren_tian_org.png" alt="[舔屏]" data-w-e="1"><img src="http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/3c/pcmoren_wu_org.png" alt="[污]" data-w-e="1"><
img src="http://
img.t.sinajs.cn/t4/appstyle/expression/ext/normal/50/pcmoren_huaixiao_org.png" alt="[坏笑]" data-w-e="1"><br></p><h1>dasdasdsadas14654156156</h1><p>eqwdoewdpeqwdwq</p><p>dsadsad75er452<
img src="http://
img.t.sinajs.cn/t35/style/images/common/face/ext/normal/60/horse2_thumb.gif" alt="[神马]" data-w-e="1"></p><p><
img src="http://
img.t.sinajs.cn/t35/style/images/common/face/ext/normal/7a/shenshou_thumb.gif" alt="[草泥马]" data-w-e="1"><br></p>"
要转成如下HTML:
<p><img src="http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/40/pcmoren_tian_org.png" alt="[舔屏]" data-w-e="1"><img src="http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/3c/pcmoren_wu_org.png" alt="[污]" data-w-e="1"><img src="http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/50/pcmoren_huaixiao_org.png" alt="[坏笑]" data-w-e="1"><br></p><h1>dasdasdsadas14654156156</h1><p>eqwdoewdpeqwdwq</p><p>
dsadsad75er452<img src="http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/60/horse2_thumb.gif" alt="[神马]" data-w-e="1"></p><p><img src="http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/7a/shenshou_thumb.gif" alt="[草泥马]" data-w-e="1"><br></p>
<script>
var E = window.wangEditor;
var editor2 = new E('#textBox1','#edit')
editor2.customConfig.zIndex = 100;
// editor2.
let a='{*utils.str_escape_by_json(approval_info.apply_info.reason)*}';
// 关闭粘贴样式的过滤
//editor.customConfig.pasteFilterStyle = false
// 忽略粘贴内容中的图片
//editor.customConfig.pasteIgnoreImg = true
// 自定义处理粘贴的文本内容
//editor.customConfig.pasteTextHandle = function (content) {
// content 即粘贴过来的内容(html 或 纯文本),可进行自定义处理然后返回
// return content + '<p>在粘贴内容后面追加一行</p>'
}
editor2.create();
// 轉HTML樣式
editor2.txt.html((a).replace(///g, "/").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'"));
editor2.$textElem.attr('contenteditable', false);
</script>