@lingxiteam/lcdp-ueditor-react 1.0.0-alpha.2 → 1.0.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/es/LcdpUeditor.d.ts +4 -0
  2. package/es/LcdpUeditor.js +76 -51
  3. package/es/const.js +4 -4
  4. package/es/defaultConfig.json +76 -76
  5. package/es/tools/UeditorResourceLoader.js +6 -6
  6. package/es/tools/filterHtmlNode.d.ts +5 -0
  7. package/es/tools/filterHtmlNode.js +41 -0
  8. package/es/tools/loadScript.js +3 -3
  9. package/es/type.d.ts +7 -1
  10. package/lib/LcdpUeditor.d.ts +80 -0
  11. package/lib/LcdpUeditor.js +268 -0
  12. package/lib/const.d.ts +12 -0
  13. package/lib/const.js +39 -0
  14. package/lib/defaultConfig.json +77 -0
  15. package/lib/index.d.ts +4 -0
  16. package/lib/index.js +41 -0
  17. package/lib/tools/UeditorResourceLoader.d.ts +21 -0
  18. package/lib/tools/UeditorResourceLoader.js +90 -0
  19. package/lib/tools/filterHtmlNode.d.ts +5 -0
  20. package/lib/tools/filterHtmlNode.js +61 -0
  21. package/lib/tools/loadScript.d.ts +5 -0
  22. package/lib/tools/loadScript.js +39 -0
  23. package/lib/type.d.ts +148 -0
  24. package/lib/type.js +17 -0
  25. package/package.json +32 -32
  26. package/ueditor-resource/dialogs/anchor/anchor.html +62 -62
  27. package/ueditor-resource/dialogs/attachment/attachment.css +716 -716
  28. package/ueditor-resource/dialogs/attachment/attachment.html +61 -61
  29. package/ueditor-resource/dialogs/attachment/attachment.js +803 -803
  30. package/ueditor-resource/dialogs/audio/audio.css +879 -879
  31. package/ueditor-resource/dialogs/audio/audio.html +93 -93
  32. package/ueditor-resource/dialogs/audio/audio.js +815 -815
  33. package/ueditor-resource/dialogs/background/background.css +193 -193
  34. package/ueditor-resource/dialogs/background/background.html +59 -59
  35. package/ueditor-resource/dialogs/background/background.js +370 -370
  36. package/ueditor-resource/dialogs/contentimport/contentimport.html +176 -176
  37. package/ueditor-resource/dialogs/contentimport/contentimport.js +91 -91
  38. package/ueditor-resource/dialogs/emotion/emotion.css +129 -129
  39. package/ueditor-resource/dialogs/emotion/emotion.html +70 -70
  40. package/ueditor-resource/dialogs/emotion/emotion.js +186 -186
  41. package/ueditor-resource/dialogs/formula/formula.html +98 -98
  42. package/ueditor-resource/dialogs/formula/formula.js +147 -147
  43. package/ueditor-resource/dialogs/help/help.css +37 -37
  44. package/ueditor-resource/dialogs/help/help.html +82 -82
  45. package/ueditor-resource/dialogs/help/help.js +57 -57
  46. package/ueditor-resource/dialogs/image/image.css +768 -768
  47. package/ueditor-resource/dialogs/image/image.html +144 -144
  48. package/ueditor-resource/dialogs/image/image.js +1060 -1060
  49. package/ueditor-resource/dialogs/insertframe/insertframe.html +135 -135
  50. package/ueditor-resource/dialogs/internal.js +81 -81
  51. package/ueditor-resource/dialogs/link/link.html +148 -148
  52. package/ueditor-resource/dialogs/preview/preview.html +45 -45
  53. package/ueditor-resource/dialogs/scrawl/scrawl.css +324 -324
  54. package/ueditor-resource/dialogs/scrawl/scrawl.html +95 -95
  55. package/ueditor-resource/dialogs/scrawl/scrawl.js +682 -682
  56. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +144 -144
  57. package/ueditor-resource/dialogs/searchreplace/searchreplace.js +174 -174
  58. package/ueditor-resource/dialogs/spechars/spechars.html +42 -42
  59. package/ueditor-resource/dialogs/spechars/spechars.js +86 -86
  60. package/ueditor-resource/dialogs/table/edittable.css +85 -85
  61. package/ueditor-resource/dialogs/table/edittable.html +69 -69
  62. package/ueditor-resource/dialogs/table/edittable.js +241 -241
  63. package/ueditor-resource/dialogs/table/edittd.html +62 -62
  64. package/ueditor-resource/dialogs/table/edittip.html +33 -33
  65. package/ueditor-resource/dialogs/template/config.js +42 -42
  66. package/ueditor-resource/dialogs/template/template.css +99 -99
  67. package/ueditor-resource/dialogs/template/template.html +26 -26
  68. package/ueditor-resource/dialogs/template/template.js +53 -53
  69. package/ueditor-resource/dialogs/video/video.css +909 -909
  70. package/ueditor-resource/dialogs/video/video.html +114 -114
  71. package/ueditor-resource/dialogs/video/video.js +867 -867
  72. package/ueditor-resource/dialogs/wordimage/wordimage.html +221 -221
  73. package/ueditor-resource/dialogs/wordimage/wordimage.js +93 -93
  74. package/ueditor-resource/lang/en/en.js +686 -686
  75. package/ueditor-resource/lang/zh-cn/zh-cn.js +748 -748
  76. package/ueditor-resource/lang/zh-tw/images/copy.png +0 -0
  77. package/ueditor-resource/lang/zh-tw/images/localimage.png +0 -0
  78. package/ueditor-resource/lang/zh-tw/images/music.png +0 -0
  79. package/ueditor-resource/lang/zh-tw/images/upload.png +0 -0
  80. package/ueditor-resource/lang/zh-tw/zh-tw.js +748 -0
  81. package/ueditor-resource/plugins/demo/demo.js +3 -3
  82. package/ueditor-resource/themes/default/css/ueditor.css +2148 -2148
  83. package/ueditor-resource/themes/default/dialog.css +17 -17
  84. package/ueditor-resource/themes/default/dialogbase.css +132 -132
  85. package/ueditor-resource/themes/default/exts/ai.svg +12 -12
  86. package/ueditor-resource/themes/default/exts/apk.svg +12 -12
  87. package/ueditor-resource/themes/default/exts/chm.svg +12 -12
  88. package/ueditor-resource/themes/default/exts/css.svg +12 -12
  89. package/ueditor-resource/themes/default/exts/doc.svg +22 -22
  90. package/ueditor-resource/themes/default/exts/docx.svg +22 -22
  91. package/ueditor-resource/themes/default/exts/dwg.svg +16 -16
  92. package/ueditor-resource/themes/default/exts/folder.svg +3 -3
  93. package/ueditor-resource/themes/default/exts/gif.svg +14 -14
  94. package/ueditor-resource/themes/default/exts/html.svg +12 -12
  95. package/ueditor-resource/themes/default/exts/jpeg.svg +14 -14
  96. package/ueditor-resource/themes/default/exts/jpg.svg +14 -14
  97. package/ueditor-resource/themes/default/exts/log.svg +12 -12
  98. package/ueditor-resource/themes/default/exts/mp3.svg +14 -14
  99. package/ueditor-resource/themes/default/exts/mp4.svg +12 -12
  100. package/ueditor-resource/themes/default/exts/pdf.svg +14 -14
  101. package/ueditor-resource/themes/default/exts/png.svg +14 -14
  102. package/ueditor-resource/themes/default/exts/ppt.svg +24 -24
  103. package/ueditor-resource/themes/default/exts/pptx.svg +24 -24
  104. package/ueditor-resource/themes/default/exts/psd.svg +12 -12
  105. package/ueditor-resource/themes/default/exts/rar.svg +12 -12
  106. package/ueditor-resource/themes/default/exts/svg.svg +12 -12
  107. package/ueditor-resource/themes/default/exts/torrent.svg +14 -14
  108. package/ueditor-resource/themes/default/exts/txt.svg +14 -14
  109. package/ueditor-resource/themes/default/exts/unknown.svg +12 -12
  110. package/ueditor-resource/themes/default/exts/xls.svg +25 -25
  111. package/ueditor-resource/themes/default/exts/xlsx.svg +25 -25
  112. package/ueditor-resource/themes/default/exts/zip.svg +12 -12
  113. package/ueditor-resource/themes/iframe.css +63 -63
  114. package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +3655 -3655
  115. package/ueditor-resource/third-party/clipboard/clipboard.js +752 -752
  116. package/ueditor-resource/third-party/codemirror/codemirror.css +106 -106
  117. package/ueditor-resource/third-party/codemirror/codemirror.js +3581 -3581
  118. package/ueditor-resource/third-party/jquery-3.5.1.js +1 -1
  119. package/ueditor-resource/third-party/jquery-3.5.1_1.js +4314 -4314
  120. package/ueditor-resource/third-party/webuploader/webuploader.css +88 -88
  121. package/ueditor-resource/third-party/webuploader/webuploader.js +3 -3
  122. package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.js +1255 -1255
  123. package/ueditor-resource/ueditor.all.js +5271 -5270
  124. package/ueditor-resource/ueditor.config.js +655 -656
  125. package/ueditor-resource/ueditor.parse.js +13 -13
  126. package/es/LcdpUeditor.d.ts.map +0 -1
  127. package/es/const.d.ts.map +0 -1
  128. package/es/index.d.ts.map +0 -1
  129. package/es/tools/UeditorResourceLoader.d.ts.map +0 -1
  130. package/es/tools/loadScript.d.ts.map +0 -1
  131. package/es/type.d.ts.map +0 -1
  132. package/ueditor-resource/index.html +0 -146
@@ -37,6 +37,10 @@ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
37
37
  * 上传文件函数
38
38
  */
39
39
  private uploadFunction;
40
+ /**
41
+ * 是否加载完成
42
+ */
43
+ private isReady;
40
44
  /**
41
45
  * 初始加载失败
42
46
  */
package/es/LcdpUeditor.js CHANGED
@@ -21,7 +21,8 @@ import React from 'react';
21
21
  import { DEFAULT_UEDITOR_CONFIG, DEFAULT_UEDITOR_PATH } from "./const";
22
22
  import DefaultConfig from "./defaultConfig.json";
23
23
  import UeditorResourceLoader from "./tools/UeditorResourceLoader";
24
- import { debounce } from 'lodash';
24
+ import debounce from 'lodash/debounce';
25
+ import { filterHtmlNode } from "./tools/filterHtmlNode";
25
26
  var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
26
27
  _inherits(LcdpUeditor, _React$Component);
27
28
  var _super = _createSuper(LcdpUeditor);
@@ -29,50 +30,54 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
29
30
  var _this;
30
31
  _classCallCheck(this, LcdpUeditor);
31
32
  _this = _super.call(this, props);
32
- /**
33
- * 静态资源地址
33
+ /**
34
+ * 静态资源地址
34
35
  */
35
36
  _defineProperty(_assertThisInitialized(_this), "ueditorPath", DEFAULT_UEDITOR_PATH);
36
- /**
37
- * 文件上传inputRef
37
+ /**
38
+ * 文件上传inputRef
38
39
  */
39
40
  _defineProperty(_assertThisInitialized(_this), "inputRef", /*#__PURE__*/React.createRef());
40
- /**
41
- * 编辑器容器ref
41
+ /**
42
+ * 编辑器容器ref
42
43
  */
43
44
  _defineProperty(_assertThisInitialized(_this), "containerRef", /*#__PURE__*/React.createRef());
44
- /**
45
- * 编辑器容器id
45
+ /**
46
+ * 编辑器容器id
46
47
  */
47
48
  _defineProperty(_assertThisInitialized(_this), "containerId", void 0);
48
- /**
49
- * 编辑器实例
49
+ /**
50
+ * 编辑器实例
50
51
  */
51
52
  _defineProperty(_assertThisInitialized(_this), "ueditorInst", null);
52
- /**
53
- * 是否上报
53
+ /**
54
+ * 是否上报
54
55
  */
55
56
  _defineProperty(_assertThisInitialized(_this), "isReportFlag", true);
56
- /**
57
- * 值变化节流函数
57
+ /**
58
+ * 值变化节流函数
58
59
  */
59
60
  _defineProperty(_assertThisInitialized(_this), "debounceContentChange", void 0);
60
- /**
61
- * 当前值
61
+ /**
62
+ * 当前值
62
63
  */
63
64
  _defineProperty(_assertThisInitialized(_this), "currentContent", '');
64
- /**
65
- * 上传文件函数
65
+ /**
66
+ * 上传文件函数
66
67
  */
67
68
  _defineProperty(_assertThisInitialized(_this), "uploadFunction", void 0);
68
- /**
69
- * 初始加载失败
69
+ /**
70
+ * 是否加载完成
71
+ */
72
+ _defineProperty(_assertThisInitialized(_this), "isReady", false);
73
+ /**
74
+ * 初始加载失败
70
75
  */
71
76
  _defineProperty(_assertThisInitialized(_this), "state", {
72
77
  initError: false
73
78
  });
74
- /**
75
- * 编辑器配置项
79
+ /**
80
+ * 编辑器配置项
76
81
  */
77
82
  _defineProperty(_assertThisInitialized(_this), "editorConfig", {});
78
83
  var config = props.config;
@@ -80,7 +85,8 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
80
85
  if (_this.props.ueditorPath) {
81
86
  _this.ueditorPath = _this.props.ueditorPath;
82
87
  }
83
- _this.currentContent = _this.props.value;
88
+ var nextValue = filterHtmlNode(_this.props.value || '').str;
89
+ _this.currentContent = nextValue;
84
90
  _this.uploadFunction = function (file, type) {
85
91
  var _this$props$config;
86
92
  // TODO 内置上传 图片base64
@@ -105,12 +111,15 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
105
111
  return null;
106
112
  };
107
113
  _this.editorConfig = _objectSpread(_objectSpread({}, DefaultConfig), {}, {
114
+ maximumWords: (config === null || config === void 0 ? void 0 : config.maximumWords) || 10000,
108
115
  initialFrameHeight: (config === null || config === void 0 ? void 0 : config.height) || 300,
109
116
  autoHeightEnabled: false,
110
117
  selectCallback: function selectCallback(cb, type) {
111
118
  _this.fileSelect(cb, type);
112
119
  },
113
- uploadFunction: _this.uploadFunction
120
+ uploadFunction: _this.uploadFunction,
121
+ initialContent: nextValue || '',
122
+ pasteplain: (config === null || config === void 0 ? void 0 : config.pasteplain) === true
114
123
  });
115
124
  _this.debounceContentChange = debounce(_this.onContentChange.bind(_assertThisInitialized(_this)), 300);
116
125
  return _this;
@@ -123,26 +132,28 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
123
132
  }, {
124
133
  key: "componentWillReceiveProps",
125
134
  value: function componentWillReceiveProps(nextProps) {
126
- if ('value' in nextProps && this.currentContent !== nextProps.value) {
127
- this.isReportFlag = false;
128
- if (this.ueditorInst) {
129
- this.ueditorInst.setContent(nextProps.value);
135
+ if (this.isReady) {
136
+ if ('value' in nextProps && this.currentContent !== nextProps.value) {
137
+ this.isReportFlag = false;
138
+ this.ueditorInst.setContent(filterHtmlNode(nextProps.value || '').str);
130
139
  }
131
- }
132
- // 禁用操作需要调用指定的api进行操作
133
- if (nextProps.disabled !== this.props.disabled && this.ueditorInst) {
134
- if (nextProps.disabled) {
135
- this.ueditorInst.setDisabled();
136
- } else {
137
- this.ueditorInst.setEnabled();
140
+ // 禁用操作需要调用指定的api进行操作
141
+ if (nextProps.disabled !== this.props.disabled) {
142
+ if (nextProps.disabled) {
143
+ this.ueditorInst.setDisabled();
144
+ } else {
145
+ this.ueditorInst.setEnabled();
146
+ }
138
147
  }
139
148
  }
140
149
  }
141
150
  }, {
142
151
  key: "componentWillUnmount",
143
152
  value: function componentWillUnmount() {
144
- var _this$ueditorInst, _this$ueditorInst$des;
145
- (_this$ueditorInst = this.ueditorInst) === null || _this$ueditorInst === void 0 || (_this$ueditorInst$des = _this$ueditorInst.destroy) === null || _this$ueditorInst$des === void 0 || _this$ueditorInst$des.call(_this$ueditorInst);
153
+ if (this.isReady) {
154
+ var _this$ueditorInst, _this$ueditorInst$des;
155
+ (_this$ueditorInst = this.ueditorInst) === null || _this$ueditorInst === void 0 || (_this$ueditorInst$des = _this$ueditorInst.destroy) === null || _this$ueditorInst$des === void 0 || _this$ueditorInst$des.call(_this$ueditorInst);
156
+ }
146
157
  }
147
158
  }, {
148
159
  key: "onContentChange",
@@ -150,8 +161,12 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
150
161
  if (!this.isReportFlag) {
151
162
  this.isReportFlag = true;
152
163
  } else if (this.props.onChange) {
153
- this.currentContent = this.ueditorInst.getContent();
154
- this.props.onChange(this.currentContent);
164
+ this.currentContent = this.ueditorInst.getContent() || '';
165
+ var _filterHtmlNode = filterHtmlNode(this.currentContent),
166
+ str = _filterHtmlNode.str,
167
+ flag = _filterHtmlNode.flag,
168
+ source = _filterHtmlNode.source;
169
+ this.props.onChange(flag ? str : source);
155
170
  }
156
171
  }
157
172
  }, {
@@ -163,10 +178,10 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
163
178
  return str || '';
164
179
  }
165
180
 
166
- /**
167
- * 文件选择
168
- * @param cb 回调给编辑器
169
- * @param type 类型
181
+ /**
182
+ * 文件选择
183
+ * @param cb 回调给编辑器
184
+ * @param type 类型
170
185
  */
171
186
  }, {
172
187
  key: "fileSelect",
@@ -244,8 +259,8 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
244
259
  }
245
260
  return fileSelect;
246
261
  }()
247
- /**
248
- * 对外暴露编辑器实例
262
+ /**
263
+ * 对外暴露编辑器实例
249
264
  */
250
265
  )
251
266
  }, {
@@ -256,8 +271,8 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
256
271
  }
257
272
  }
258
273
 
259
- /**
260
- * 初始化样式
274
+ /**
275
+ * 初始化样式
261
276
  */
262
277
  }, {
263
278
  key: "initStyle",
@@ -279,8 +294,8 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
279
294
  }
280
295
  }
281
296
 
282
- /**
283
- * 初始化编辑器实例
297
+ /**
298
+ * 初始化编辑器实例
284
299
  */
285
300
  }, {
286
301
  key: "initUeditor",
@@ -292,8 +307,18 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
292
307
  while (1) switch (_context3.prev = _context3.next) {
293
308
  case 0:
294
309
  UeditorResourceLoader.onReady(function () {
310
+ if (_this3.props.toolbars) {
311
+ _this3.editorConfig.toolbars = _this3.props.toolbars;
312
+ }
295
313
  _this3.ueditorInst = window.UE.getEditor(_this3.containerId, _this3.editorConfig);
296
314
  _this3.ueditorInst.ready(function () {
315
+ _this3.isReady = true;
316
+ // 禁用状态设置
317
+ if (_this3.props.disabled) {
318
+ _this3.ueditorInst.setDisabled();
319
+ } else {
320
+ _this3.ueditorInst.setEnabled();
321
+ }
297
322
  _this3.ueditorInst.addListener('contentChange', function () {
298
323
  _this3.debounceContentChange();
299
324
  });
@@ -301,7 +326,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) {
301
326
  });
302
327
  _this3.mountRef();
303
328
  });
304
- jsList = ["".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.UEDITOR_CONFIG), "".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.UEDITOR_ALL), "".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.GET_UEDITOR_LANG())];
329
+ jsList = ["".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.UEDITOR_CONFIG), "".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.UEDITOR_ALL), "".concat(this.ueditorPath, "/").concat(DEFAULT_UEDITOR_CONFIG.GET_UEDITOR_LANG(this.props.lang || 'zh-cn'))];
305
330
  UeditorResourceLoader.onLoadError(function () {
306
331
  _this3.setState({
307
332
  initError: true
package/es/const.js CHANGED
@@ -1,10 +1,10 @@
1
- /**
2
- * 默认的ueditor资源路径
1
+ /**
2
+ * 默认的ueditor资源路径
3
3
  */
4
4
  export var DEFAULT_UEDITOR_PATH = './ueditor-resource';
5
5
 
6
- /**
7
- * ueditor 资源文件名
6
+ /**
7
+ * ueditor 资源文件名
8
8
  */
9
9
  export var DEFAULT_UEDITOR_CONFIG = {
10
10
  // 配置文件
@@ -1,77 +1,77 @@
1
- {
2
- "imageActionName": "image",
3
- "imageFieldName": "file",
4
- "imageMaxSize": 10485760,
5
- "imageAllowFiles": [
6
- ".jpg",
7
- ".png",
8
- ".jpeg"
9
- ],
10
- "imageCompressEnable": true,
11
- "imageCompressBorder": 5000,
12
- "imageInsertAlign": "none",
13
- "imageUrlPrefix": "",
14
- "scrawlActionName": "crawl",
15
- "scrawlFieldName": "file",
16
- "scrawlMaxSize": 10485760,
17
- "scrawlUrlPrefix": "",
18
- "scrawlInsertAlign": "none",
19
- "snapscreenActionName": "snap",
20
- "snapscreenUrlPrefix": "",
21
- "snapscreenInsertAlign": "none",
22
- "catcherLocalDomain": [
23
- "127.0.0.1",
24
- "localhost"
25
- ],
26
- "catcherActionName": "catch",
27
- "catcherFieldName": "source",
28
- "catcherUrlPrefix": "",
29
- "catcherMaxSize": 10485760,
30
- "catcherAllowFiles": [
31
- ".jpg",
32
- ".png",
33
- ".jpeg"
34
- ],
35
- "videoActionName": "video",
36
- "videoFieldName": "file",
37
- "videoUrlPrefix": "",
38
- "videoMaxSize": 104857600,
39
- "videoAllowFiles": [
40
- ".mp4",
41
- ".webm",
42
- ".mkv"
43
- ],
44
- "audioActionName": "audio",
45
- "audioFieldName": "file",
46
- "audioUrlPrefix": "",
47
- "audioMaxSize": 104857600,
48
- "audioAllowFiles": [
49
- ".mp3"
50
- ],
51
- "fileActionName": "file",
52
- "fileFieldName": "file",
53
- "fileUrlPrefix": "",
54
- "fileMaxSize": 104857600,
55
- "fileAllowFiles": [
56
- ".zip",
57
- ".pdf",
58
- ".doc"
59
- ],
60
- "imageManagerActionName": "listImage",
61
- "imageManagerListSize": 20,
62
- "imageManagerUrlPrefix": "",
63
- "imageManagerInsertAlign": "none",
64
- "imageManagerAllowFiles": [
65
- ".jpg",
66
- ".png",
67
- ".jpeg"
68
- ],
69
- "fileManagerActionName": "listFile",
70
- "fileManagerUrlPrefix": "",
71
- "fileManagerListSize": 20,
72
- "fileManagerAllowFiles": [
73
- ".zip",
74
- ".pdf",
75
- ".doc"
76
- ]
1
+ {
2
+ "imageActionName": "image",
3
+ "imageFieldName": "file",
4
+ "imageMaxSize": 10485760,
5
+ "imageAllowFiles": [
6
+ ".jpg",
7
+ ".png",
8
+ ".jpeg"
9
+ ],
10
+ "imageCompressEnable": true,
11
+ "imageCompressBorder": 5000,
12
+ "imageInsertAlign": "none",
13
+ "imageUrlPrefix": "",
14
+ "scrawlActionName": "crawl",
15
+ "scrawlFieldName": "file",
16
+ "scrawlMaxSize": 10485760,
17
+ "scrawlUrlPrefix": "",
18
+ "scrawlInsertAlign": "none",
19
+ "snapscreenActionName": "snap",
20
+ "snapscreenUrlPrefix": "",
21
+ "snapscreenInsertAlign": "none",
22
+ "catcherLocalDomain": [
23
+ "127.0.0.1",
24
+ "localhost"
25
+ ],
26
+ "catcherActionName": "catch",
27
+ "catcherFieldName": "source",
28
+ "catcherUrlPrefix": "",
29
+ "catcherMaxSize": 10485760,
30
+ "catcherAllowFiles": [
31
+ ".jpg",
32
+ ".png",
33
+ ".jpeg"
34
+ ],
35
+ "videoActionName": "video",
36
+ "videoFieldName": "file",
37
+ "videoUrlPrefix": "",
38
+ "videoMaxSize": 104857600,
39
+ "videoAllowFiles": [
40
+ ".mp4",
41
+ ".webm",
42
+ ".mkv"
43
+ ],
44
+ "audioActionName": "audio",
45
+ "audioFieldName": "file",
46
+ "audioUrlPrefix": "",
47
+ "audioMaxSize": 104857600,
48
+ "audioAllowFiles": [
49
+ ".mp3"
50
+ ],
51
+ "fileActionName": "file",
52
+ "fileFieldName": "file",
53
+ "fileUrlPrefix": "",
54
+ "fileMaxSize": 104857600,
55
+ "fileAllowFiles": [
56
+ ".zip",
57
+ ".pdf",
58
+ ".doc"
59
+ ],
60
+ "imageManagerActionName": "listImage",
61
+ "imageManagerListSize": 20,
62
+ "imageManagerUrlPrefix": "",
63
+ "imageManagerInsertAlign": "none",
64
+ "imageManagerAllowFiles": [
65
+ ".jpg",
66
+ ".png",
67
+ ".jpeg"
68
+ ],
69
+ "fileManagerActionName": "listFile",
70
+ "fileManagerUrlPrefix": "",
71
+ "fileManagerListSize": 20,
72
+ "fileManagerAllowFiles": [
73
+ ".zip",
74
+ ".pdf",
75
+ ".doc"
76
+ ]
77
77
  }
@@ -82,9 +82,9 @@ var UeditorResourceLoader = /*#__PURE__*/function () {
82
82
  return this.instance;
83
83
  }
84
84
 
85
- /**
86
- * 加载完成执行
87
- * @param callback 回调函数
85
+ /**
86
+ * 加载完成执行
87
+ * @param callback 回调函数
88
88
  */
89
89
  }, {
90
90
  key: "onReady",
@@ -97,9 +97,9 @@ var UeditorResourceLoader = /*#__PURE__*/function () {
97
97
  }
98
98
  }
99
99
 
100
- /**
101
- * 资源加载失败执行
102
- * @param callback
100
+ /**
101
+ * 资源加载失败执行
102
+ * @param callback
103
103
  */
104
104
  }, {
105
105
  key: "onLoadError",
@@ -0,0 +1,5 @@
1
+ export declare const filterHtmlNode: (str: string) => {
2
+ str: string;
3
+ flag: boolean;
4
+ source: string;
5
+ };
@@ -0,0 +1,41 @@
1
+ export var filterHtmlNode = function filterHtmlNode(str) {
2
+ var flag = false;
3
+ if (typeof str !== 'string') return str || '';
4
+ var blacklist = ['script', 'style', 'iframe'];
5
+
6
+ // 创建一个新的 DOM 解析器对象
7
+ var parser = new DOMParser();
8
+
9
+ // 使用 parseFromString 方法将 HTML 片段转换为 DOM 对象
10
+ var doc = parser.parseFromString(str, 'text/html');
11
+
12
+ // 遍历 DOM 树并删除恶意节点
13
+ function cleanNode(node) {
14
+ if (node.nodeType === 1) {
15
+ // 元素节点
16
+ if (blacklist.indexOf(node.nodeName.toLowerCase()) !== -1) {
17
+ var _node$parentNode;
18
+ (_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 || _node$parentNode.removeChild(node);
19
+ return;
20
+ }
21
+
22
+ // 移除元素节点上所有事件属性
23
+ for (var i = node.attributes.length - 1; i >= 0; i -= 1) {
24
+ var attr = node.attributes[i];
25
+ if (attr.name.startsWith('on') || String(node.getAttribute(attr.name)).toLowerCase().indexOf('javascript:') !== -1) {
26
+ node.removeAttribute(attr.name);
27
+ flag = true;
28
+ }
29
+ }
30
+ }
31
+ for (var _i = 0; _i < node.childNodes.length; _i += 1) {
32
+ cleanNode(node.childNodes[_i]);
33
+ }
34
+ }
35
+ cleanNode(doc.body);
36
+ return {
37
+ str: doc.body.innerHTML,
38
+ flag: flag,
39
+ source: str
40
+ };
41
+ };
@@ -2,9 +2,9 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
4
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
- /**
6
- * 同步加载js
7
- * @param strs 路径地址
5
+ /**
6
+ * 同步加载js
7
+ * @param strs 路径地址
8
8
  */
9
9
  export var loadScriptSync = /*#__PURE__*/function () {
10
10
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(strs) {
package/es/type.d.ts CHANGED
@@ -23,6 +23,10 @@ export interface ILcdpUeditorProps {
23
23
  * 富文本配置
24
24
  */
25
25
  config?: {
26
+ /**
27
+ * 是否默认为纯文本粘贴。false为不使用纯文本粘贴,true为使用纯文本粘贴 默认false
28
+ */
29
+ pasteplain?: boolean;
26
30
  /**
27
31
  * 编辑器高度 默认300px
28
32
  */
@@ -63,12 +67,14 @@ export interface ILcdpUeditorProps {
63
67
  * 上传视频格式限制
64
68
  */
65
69
  videoAllowFiles?: string[];
70
+ maximumWords?: number;
66
71
  };
72
+ toolbars?: string[][];
67
73
  /**
68
74
  * 语言 默认 zh-cn
69
75
  * zh-cn 中文 en 英文
70
76
  */
71
- lang?: 'zh-cn' | 'en';
77
+ lang?: 'zh-cn' | 'en' | 'zh-tw';
72
78
  /**
73
79
  * 上传方法
74
80
  * @param file 文件
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import type { ILcdpUeditorProps } from './type';
3
+ declare class LcdpUeditor extends React.Component<ILcdpUeditorProps, {}> {
4
+ /**
5
+ * 静态资源地址
6
+ */
7
+ ueditorPath: string;
8
+ /**
9
+ * 文件上传inputRef
10
+ */
11
+ private inputRef;
12
+ /**
13
+ * 编辑器容器ref
14
+ */
15
+ private containerRef;
16
+ /**
17
+ * 编辑器容器id
18
+ */
19
+ private containerId;
20
+ /**
21
+ * 编辑器实例
22
+ */
23
+ private ueditorInst;
24
+ /**
25
+ * 是否上报
26
+ */
27
+ private isReportFlag;
28
+ /**
29
+ * 值变化节流函数
30
+ */
31
+ private debounceContentChange;
32
+ /**
33
+ * 当前值
34
+ */
35
+ private currentContent;
36
+ /**
37
+ * 上传文件函数
38
+ */
39
+ private uploadFunction;
40
+ /**
41
+ * 是否加载完成
42
+ */
43
+ private isReady;
44
+ /**
45
+ * 初始加载失败
46
+ */
47
+ state: Readonly<{
48
+ initError: boolean;
49
+ }>;
50
+ /**
51
+ * 编辑器配置项
52
+ */
53
+ editorConfig: any;
54
+ constructor(props: ILcdpUeditorProps);
55
+ componentDidMount(): void;
56
+ componentWillReceiveProps(nextProps: ILcdpUeditorProps): void;
57
+ componentWillUnmount(): void;
58
+ private onContentChange;
59
+ private getExtString;
60
+ /**
61
+ * 文件选择
62
+ * @param cb 回调给编辑器
63
+ * @param type 类型
64
+ */
65
+ private fileSelect;
66
+ /**
67
+ * 对外暴露编辑器实例
68
+ */
69
+ private mountRef;
70
+ /**
71
+ * 初始化样式
72
+ */
73
+ private initStyle;
74
+ /**
75
+ * 初始化编辑器实例
76
+ */
77
+ initUeditor(): Promise<void>;
78
+ render(): React.ReactNode;
79
+ }
80
+ export default LcdpUeditor;