张延森 5 years ago
parent
commit
b9af5cd550
1 changed files with 13 additions and 2 deletions
  1. 13
    2
      src/components/Wangedit/Wangedit.jsx

+ 13
- 2
src/components/Wangedit/Wangedit.jsx View File

@@ -2,6 +2,11 @@ import React from 'react';
2 2
 import E from 'wangeditor';
3 3
 import { fetch, apis } from '../../utils/request';
4 4
 
5
+
6
+const specialChars = [
7
+  '\u2029',   // 段落分隔符 码点 8233
8
+]
9
+
5 10
 /**
6 11
  * @param {*} props
7 12
  * @returns
@@ -28,10 +33,16 @@ class Wangedit extends React.Component {
28 33
     this.editor = new E(elem)
29 34
     // 使用 onchange 函数监听内容的变化
30 35
     this.editor.customConfig.onchange = html => {
31
-      this.setState({ html })
36
+      // 去掉特殊字符
37
+      // 2020-3-28 yansen
38
+      const pureHtml = specialChars.reduce((acc, char) => {
39
+        return acc.replace(new RegExp(char, 'gi'), '')
40
+      }, html)
41
+
42
+      this.setState({ pureHtml })
32 43
 
33 44
       if (typeof this.props.onChange === 'function') {
34
-        this.props.onChange(html)
45
+        this.props.onChange(pureHtml)
35 46
       }
36 47
     }
37 48
     this.editor.customConfig.zIndex = 100