Commit 52c18217 by yuananting

fix:编辑器字数统计方法修改

parent d975046f
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-07-05 10:47:19
* @LastEditors: yuananting
* @LastEditTime: 2021-07-12 17:05:59
* @LastEditTime: 2021-07-12 17:13:38
* @Description: 描述一下咯
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
......@@ -139,22 +139,17 @@ class GraphicsEditor extends React.Component {
return str;
};
this.editorInt.config.onchange = (html) => {
var str1 = html; // 去除所有特殊字符
str1 = str1.replace(/<xml>[\s\S]*?<\/xml>/gi, '');
str1 = str1.replace(/<style>[\s\S]*?<\/style>/gi, '');
str1 = str1.replace(/<\/?[^>]*>/g, '');
str1 = str1.replace(/[ | ]*\n/g, '\n');
str1 = str1.replace(/\&nbsp\;/gi, ' ');
str1 = str1.replace(/[\r\n]/g, '');
str1 = str1.replace(/<\/?a.*?>/g, '');
var str2 = html; // 保留空格和换行的其他字符
str2 = str2.replace(/<xml>[\s\S]*?<\/xml>/gi, '');
str2 = str2.replace(/<style>[\s\S]*?<\/style>/gi, '');
str2 = str2.replace(/<\/?a.*?>/g, '');
var str = this.editorInt.txt.text(); // 去除所有特殊字符
str = str.replace(/<xml>[\s\S]*?<\/xml>/gi, '');
str = str.replace(/<style>[\s\S]*?<\/style>/gi, '');
str = str.replace(/<\/?[^>]*>/g, '');
str = str.replace(/[ | ]*\n/g, '\n');
str = str.replace(/\&nbsp\;/gi, ' ');
str = str.replace(/[\r\n]/g, '');
str = str.replace(/<\/?a.*?>/g, '');
const videoCount = ((html || '').match(/<iframe/g) || []).length;
const imageCount = ((html || '').match(/<img/g) || []).length;
const textLength = str1.length + videoCount + imageCount;
const textLength = str.length + videoCount + imageCount;
this.setState({ textLength }, () => {
if (textLength > maxLimit) {
message.warning(`内容过长,不能超过${maxLimit}字`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment