Commit 2c7c3cf3 by yuananting

fix:编辑器(简介)复制张贴字数判断调整

parent 9dd083d3
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-07-05 10:47:19 * @Date: 2021-07-05 10:47:19
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-07-08 10:51:30 * @LastEditTime: 2021-07-12 16:24:33
* @Description: 描述一下咯 * @Description: 描述一下咯
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
...@@ -132,7 +132,14 @@ class GraphicsEditor extends React.Component { ...@@ -132,7 +132,14 @@ class GraphicsEditor extends React.Component {
// 自定义处理粘贴的文本内容 // 自定义处理粘贴的文本内容
this.editorInt.config.pasteTextHandle = (content) => { this.editorInt.config.pasteTextHandle = (content) => {
if (content == '' && !content) return ''; if (content == '' && !content) return '';
var str1 = content; // 去除所有特殊字符 var str = content; // 保留空格和换行的其他字符
str = str.replace(/<xml>[\s\S]*?<\/xml>/gi, '');
str = str.replace(/<style>[\s\S]*?<\/style>/gi, '');
str = str.replace(/<\/?a.*?>/g, '');
return str;
};
this.editorInt.config.onchange = (html) => {
var str1 = html; // 去除所有特殊字符
str1 = str1.replace(/<xml>[\s\S]*?<\/xml>/gi, ''); str1 = str1.replace(/<xml>[\s\S]*?<\/xml>/gi, '');
str1 = str1.replace(/<style>[\s\S]*?<\/style>/gi, ''); str1 = str1.replace(/<style>[\s\S]*?<\/style>/gi, '');
str1 = str1.replace(/<\/?[^>]*>/g, ''); str1 = str1.replace(/<\/?[^>]*>/g, '');
...@@ -140,24 +147,18 @@ class GraphicsEditor extends React.Component { ...@@ -140,24 +147,18 @@ class GraphicsEditor extends React.Component {
str1 = str1.replace(/\&nbsp\;/gi, ' '); str1 = str1.replace(/\&nbsp\;/gi, ' ');
str1 = str1.replace(/[\r\n]/g, ''); str1 = str1.replace(/[\r\n]/g, '');
str1 = str1.replace(/<\/?a.*?>/g, ''); str1 = str1.replace(/<\/?a.*?>/g, '');
var str2 = content; // 保留空格和换行的其他字符 var str2 = html; // 保留空格和换行的其他字符
str2 = str2.replace(/<xml>[\s\S]*?<\/xml>/gi, ''); str2 = str2.replace(/<xml>[\s\S]*?<\/xml>/gi, '');
str2 = str2.replace(/<style>[\s\S]*?<\/style>/gi, ''); str2 = str2.replace(/<style>[\s\S]*?<\/style>/gi, '');
str2 = str2.replace(/<\/?a.*?>/g, ''); str2 = str2.replace(/<\/?a.*?>/g, '');
const videoCount = ((content || '').match(/<iframe/g) || []).length; const videoCount = ((html || '').match(/<iframe/g) || []).length;
const imageCount = ((content || '').match(/<img/g) || []).length; const imageCount = ((html || '').match(/<img/g) || []).length;
const textLength = this.editorInt.txt.text().length + str1.length + videoCount + imageCount; const textLength = this.editorInt.txt.text().length + str1.length + videoCount + imageCount;
this.setState({ textLength }, () => {
if (textLength > maxLimit) { if (textLength > maxLimit) {
message.warning(`内容过长,不能超过${maxLimit}字`); message.warning(`内容过长,不能超过${maxLimit}字`);
} }
return str2;
};
this.editorInt.config.onchange = (html) => {
const videoCount = ((html || '').match(/<iframe/g) || []).length;
const imageCount = ((html || '').match(/<img/g) || []).length;
const textLength = this.editorInt.txt.text().replace(/\&nbsp\;/gi, ' ').length + videoCount + imageCount;
this.setState({ textLength }, () => {
Bus.trigger('editorLimit', textLength, editorType); Bus.trigger('editorLimit', textLength, editorType);
onChange(html, this.state.textLength); onChange(html, this.state.textLength);
}); });
......
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