@vtx/components 4.0.0-beta.7 → 4.0.0-beta.70

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 (161) hide show
  1. package/es/index.js +3 -0
  2. package/es/utils/filterSpecialCharacters.js +47 -46
  3. package/es/utils/index.js +1 -2
  4. package/es/vtx-color-picker/index.js +138 -33
  5. package/es/vtx-color-picker/style/index.js +36 -12
  6. package/es/vtx-combogrid/Combogrid.js +16 -10
  7. package/es/vtx-combogrid/index.js +7 -4
  8. package/es/vtx-combogrid/style/index.js +4 -4
  9. package/es/vtx-datagrid/Store/Provide.js +109 -132
  10. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +11 -5
  11. package/es/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  12. package/es/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  13. package/es/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  14. package/es/vtx-datagrid/ToolBar/index.js +2 -2
  15. package/es/vtx-datagrid/columnState.js +64 -0
  16. package/es/vtx-datagrid/index.js +114 -35
  17. package/es/vtx-datagrid/mergeComponents.js +15 -0
  18. package/es/vtx-datagrid/renderColumnButtons.js +30 -11
  19. package/es/vtx-datagrid/style/index.js +102 -20
  20. package/es/vtx-date-picker/QdatePicker.js +1 -1
  21. package/es/vtx-descriptions/Descriptions.js +29 -0
  22. package/es/vtx-descriptions/index.js +3 -0
  23. package/es/vtx-descriptions/style/index.js +19 -0
  24. package/es/vtx-ellipsis-text/index.js +7 -2
  25. package/es/vtx-ellipsis-text/style/index.js +3 -1
  26. package/es/vtx-export/index.js +25 -25
  27. package/es/vtx-export-async/History.js +7 -3
  28. package/es/vtx-export-async/index.js +42 -14
  29. package/es/vtx-form-layout/Card.js +10 -10
  30. package/es/vtx-form-layout/Divider.js +1 -1
  31. package/es/vtx-form-layout/FormItem.js +18 -17
  32. package/es/vtx-form-layout/Pane.js +23 -12
  33. package/es/vtx-icon/index.js +54 -45
  34. package/es/vtx-icon/index.js1 +90 -0
  35. package/es/vtx-image/Preview.js +11 -6
  36. package/es/vtx-image/style/index.js +0 -1
  37. package/es/vtx-import/index.js +155 -43
  38. package/es/vtx-import/result.js +6 -2
  39. package/es/vtx-import/style/index.js +16 -1
  40. package/es/vtx-import2/Content.js +2 -1
  41. package/es/vtx-import2/index.js +31 -20
  42. package/es/vtx-import2/style/index.js +60 -9
  43. package/es/vtx-input/TextArea/index.js +11 -6
  44. package/es/vtx-modal/index.js +9 -4
  45. package/es/vtx-modal/style/index.js +5 -3
  46. package/es/vtx-page-layout/Content.js +1 -1
  47. package/es/vtx-page-layout/TabLayout.js +1 -7
  48. package/es/vtx-page-layout/TableLayout.js +14 -4
  49. package/es/vtx-page-layout/TableWrap.js +3 -2
  50. package/es/vtx-page-layout/TreeLayout.js +2 -8
  51. package/es/vtx-page-layout/container.js +6 -5
  52. package/es/vtx-page-layout/style/index.js +4 -2
  53. package/es/vtx-provider/index.js +20 -10
  54. package/es/vtx-provider/locale/en_US.js +65 -5
  55. package/es/vtx-provider/locale/zh_CN.js +75 -5
  56. package/es/vtx-provider/useStyle/index.js +8 -4
  57. package/es/vtx-scrollable-row/index.js +38 -28
  58. package/es/vtx-search/index.js +18 -13
  59. package/es/vtx-search/style/index.js +2 -1
  60. package/es/vtx-select/index.js +132 -46
  61. package/es/vtx-select/style/index.js +11 -56
  62. package/es/vtx-signature/index.js +5 -4
  63. package/es/vtx-signature/style/index.js +1 -1
  64. package/es/vtx-split-pane/Resizer.js +0 -1
  65. package/es/vtx-split-pane/SplitPane.js +34 -25
  66. package/es/vtx-split-pane/style/index.js +8 -112
  67. package/es/vtx-time-picker/index.js +27 -1
  68. package/es/vtx-transfer/Transfer.js +29 -0
  69. package/es/vtx-transfer/index.js +3 -0
  70. package/es/vtx-transfer/style/index.js +19 -0
  71. package/es/vtx-transfer-select/TransferSelect.js +143 -0
  72. package/es/vtx-transfer-select/index.js +3 -0
  73. package/es/vtx-transfer-select/style/index.js +19 -0
  74. package/es/vtx-tree/index.js +104 -40
  75. package/es/vtx-tree-select/index.js +75 -105
  76. package/es/vtx-tree-select/style/index.js +9 -3
  77. package/es/vtx-upload/FilePreview.js +2 -1
  78. package/es/vtx-wang-editor/index.js +291 -113
  79. package/es/vtx-wang-editor/wangEditorUtil.js +59 -9
  80. package/lib/index.js +36 -0
  81. package/lib/utils/filterSpecialCharacters.js +48 -46
  82. package/lib/utils/index.js +0 -7
  83. package/lib/vtx-color-picker/index.js +139 -34
  84. package/lib/vtx-color-picker/style/index.js +36 -12
  85. package/lib/vtx-combogrid/Combogrid.js +16 -10
  86. package/lib/vtx-combogrid/index.js +7 -4
  87. package/lib/vtx-combogrid/style/index.js +4 -4
  88. package/lib/vtx-datagrid/Store/Provide.js +116 -138
  89. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/index.js +11 -6
  90. package/lib/vtx-datagrid/ToolBar/components/ColumnSetting/style.js +5 -2
  91. package/lib/vtx-datagrid/ToolBar/components/Density/index.js +3 -0
  92. package/lib/vtx-datagrid/ToolBar/components/TableStyle/index.js +3 -0
  93. package/lib/vtx-datagrid/ToolBar/index.js +2 -2
  94. package/lib/vtx-datagrid/columnState.js +73 -0
  95. package/lib/vtx-datagrid/index.js +115 -35
  96. package/lib/vtx-datagrid/mergeComponents.js +21 -0
  97. package/lib/vtx-datagrid/renderColumnButtons.js +30 -11
  98. package/lib/vtx-datagrid/style/index.js +102 -20
  99. package/lib/vtx-date-picker/QdatePicker.js +1 -1
  100. package/lib/vtx-descriptions/Descriptions.js +38 -0
  101. package/lib/vtx-descriptions/index.js +15 -0
  102. package/lib/vtx-descriptions/style/index.js +25 -0
  103. package/lib/vtx-ellipsis-text/index.js +7 -2
  104. package/lib/vtx-ellipsis-text/style/index.js +3 -1
  105. package/lib/vtx-export/index.js +26 -26
  106. package/lib/vtx-export-async/History.js +7 -3
  107. package/lib/vtx-export-async/index.js +40 -12
  108. package/lib/vtx-form-layout/Card.js +9 -9
  109. package/lib/vtx-form-layout/Divider.js +1 -1
  110. package/lib/vtx-form-layout/FormItem.js +18 -17
  111. package/lib/vtx-form-layout/Pane.js +22 -11
  112. package/lib/vtx-icon/index.js +54 -52
  113. package/lib/vtx-icon/index.js1 +90 -0
  114. package/lib/vtx-image/Preview.js +11 -6
  115. package/lib/vtx-image/style/index.js +0 -1
  116. package/lib/vtx-import/index.js +154 -42
  117. package/lib/vtx-import/result.js +6 -2
  118. package/lib/vtx-import/style/index.js +16 -1
  119. package/lib/vtx-import2/Content.js +2 -1
  120. package/lib/vtx-import2/index.js +30 -19
  121. package/lib/vtx-import2/style/index.js +60 -9
  122. package/lib/vtx-input/TextArea/index.js +11 -6
  123. package/lib/vtx-modal/index.js +9 -4
  124. package/lib/vtx-modal/style/index.js +5 -3
  125. package/lib/vtx-page-layout/Content.js +1 -1
  126. package/lib/vtx-page-layout/TabLayout.js +3 -9
  127. package/lib/vtx-page-layout/TableLayout.js +14 -4
  128. package/lib/vtx-page-layout/TableWrap.js +3 -2
  129. package/lib/vtx-page-layout/TreeLayout.js +4 -10
  130. package/lib/vtx-page-layout/container.js +6 -5
  131. package/lib/vtx-page-layout/style/index.js +4 -2
  132. package/lib/vtx-provider/index.js +19 -10
  133. package/lib/vtx-provider/locale/en_US.js +65 -5
  134. package/lib/vtx-provider/locale/zh_CN.js +75 -5
  135. package/lib/vtx-provider/useStyle/index.js +8 -4
  136. package/lib/vtx-scrollable-row/index.js +38 -28
  137. package/lib/vtx-search/index.js +18 -13
  138. package/lib/vtx-search/style/index.js +2 -1
  139. package/lib/vtx-select/index.js +134 -48
  140. package/lib/vtx-select/style/index.js +11 -56
  141. package/lib/vtx-signature/index.js +4 -3
  142. package/lib/vtx-signature/style/index.js +1 -1
  143. package/lib/vtx-split-pane/Resizer.js +0 -1
  144. package/lib/vtx-split-pane/SplitPane.js +32 -23
  145. package/lib/vtx-split-pane/style/index.js +8 -112
  146. package/lib/vtx-time-picker/index.js +27 -1
  147. package/lib/vtx-transfer/Transfer.js +38 -0
  148. package/lib/vtx-transfer/index.js +15 -0
  149. package/lib/vtx-transfer/style/index.js +25 -0
  150. package/lib/vtx-transfer-select/TransferSelect.js +151 -0
  151. package/lib/vtx-transfer-select/index.js +15 -0
  152. package/lib/vtx-transfer-select/style/index.js +25 -0
  153. package/lib/vtx-tree/index.js +102 -38
  154. package/lib/vtx-tree-select/index.js +75 -105
  155. package/lib/vtx-tree-select/style/index.js +9 -3
  156. package/lib/vtx-upload/FilePreview.js +2 -1
  157. package/lib/vtx-wang-editor/index.js +289 -113
  158. package/lib/vtx-wang-editor/wangEditorUtil.js +59 -10
  159. package/package.json +44 -28
  160. package/es/utils/hooks/useFetchData/index.js +0 -82
  161. package/lib/utils/hooks/useFetchData/index.js +0 -89
@@ -1,29 +1,29 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["value", "onChange", "downloadUrl", "uploadUrl", "placeholder", "maxFileSize", "maxNumberOfFiles", "height", "status"];
2
+ var _excluded = ["value", "onChange", "downloadUrl", "uploadUrl", "placeholder", "maxFileSize", "defaultMaxFileSize", "maxNumberOfFiles", "height", "status", "enableSanitization", "toolConfig", "editConfig"];
3
+ 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; }
4
+ 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); } }
5
+ 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); }); }; }
3
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
8
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
9
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
10
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- 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; }
9
- 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); } }
10
- 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); }); }; }
11
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
12
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
14
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
15
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
17
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
18
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
19
19
  /*eslint-disable*/
20
- import React, { forwardRef, useState, useEffect, useContext } from 'react';
20
+ import React, { forwardRef, useState, useEffect, useContext, useCallback, useRef } from 'react';
21
21
  import PropTypes from 'prop-types';
22
22
  import { Editor, Toolbar } from '@wangeditor/editor-for-react';
23
23
  import attachmentModule from '@wangeditor/plugin-upload-attachment';
24
- import { Boot } from '@wangeditor/editor';
25
- import { withEmptyHtml, findAllImgSrcsFromHtml, extractImageDataFromRtf, replaceImagesFileSourceWithInlineRepresentation, replaceAllSpanFontSize } from "./wangEditorUtil";
26
- import { ConfigProvider } from 'antd';
24
+ import { i18nChangeLanguage, Boot } from '@wangeditor/editor';
25
+ import getToken from "../utils/getToken";
26
+ import { withEmptyHtml, findAllImgSrcsFromHtml, extractImageDataFromRtf, replaceImagesFileSourceWithInlineRepresentation, replaceAllSpanFontSize, sanitizeHtml } from "./wangEditorUtil";
27
27
  import cls from 'classnames';
28
28
  import { useStyle } from "./style/index";
29
29
  import { FormItemInputContext } from 'antd/es/form/context';
@@ -44,13 +44,30 @@ var VtxWangEditor = function VtxWangEditor(props) {
44
44
  var _useStyle = useStyle(prefixCls),
45
45
  wrapSSR = _useStyle.wrapSSR,
46
46
  hashId = _useStyle.hashId;
47
+ // 添加加载状态管理
48
+ var _useState = useState(false),
49
+ _useState2 = _slicedToArray(_useState, 2),
50
+ loading = _useState2[0],
51
+ setLoading = _useState2[1];
52
+ var _useState3 = useState(null),
53
+ _useState4 = _slicedToArray(_useState3, 2),
54
+ error = _useState4[0],
55
+ setError = _useState4[1];
56
+
57
+ // 添加错误边界处理
58
+ var handleError = useCallback(function (error) {
59
+ console.error('VtxWangEditor Error:', error);
60
+ setError(error.message);
61
+ // 可以在这里添加错误上报逻辑
62
+ }, []);
63
+ var valueRef = useRef();
47
64
  var _React$useContext = React.useContext(FormItemInputContext),
48
65
  contextStatus = _React$useContext.status,
49
66
  hasFeedback = _React$useContext.hasFeedback,
50
67
  isFormItemInput = _React$useContext.isFormItemInput,
51
68
  feedbackIcon = _React$useContext.feedbackIcon;
52
69
  var value = props.value,
53
- _onChange = props.onChange,
70
+ onChange = props.onChange,
54
71
  _props$downloadUrl = props.downloadUrl,
55
72
  downloadUrl = _props$downloadUrl === void 0 ? '/cloudFile/common/downloadFile?id=' : _props$downloadUrl,
56
73
  _props$uploadUrl = props.uploadUrl,
@@ -59,77 +76,293 @@ var VtxWangEditor = function VtxWangEditor(props) {
59
76
  placeholder = _props$placeholder === void 0 ? '' : _props$placeholder,
60
77
  _props$maxFileSize = props.maxFileSize,
61
78
  maxFileSize = _props$maxFileSize === void 0 ? 5 * 1024 * 1024 : _props$maxFileSize,
79
+ _props$defaultMaxFile = props.defaultMaxFileSize,
80
+ defaultMaxFileSize = _props$defaultMaxFile === void 0 ? 1024 * 1024 * 1024 : _props$defaultMaxFile,
62
81
  _props$maxNumberOfFil = props.maxNumberOfFiles,
63
82
  maxNumberOfFiles = _props$maxNumberOfFil === void 0 ? 5 : _props$maxNumberOfFil,
64
83
  _props$height = props.height,
65
84
  height = _props$height === void 0 ? 350 : _props$height,
66
85
  customStatus = props.status,
86
+ _props$enableSanitiza = props.enableSanitization,
87
+ enableSanitization = _props$enableSanitiza === void 0 ? true : _props$enableSanitiza,
88
+ _props$toolConfig = props.toolConfig,
89
+ toolConfig = _props$toolConfig === void 0 ? {} : _props$toolConfig,
90
+ _props$editConfig = props.editConfig,
91
+ editConfig = _props$editConfig === void 0 ? {} : _props$editConfig,
67
92
  rest = _objectWithoutProperties(props, _excluded);
93
+ var language = props !== null && props !== void 0 && props.language || (intl === null || intl === void 0 ? void 0 : intl.locale) == 'en_US' ? 'en' : 'zh-CN' || 'zh-CN'; // en || zh-CN
94
+ var TextEnum = _objectSpread({
95
+ messageOverSizeText: intl.getMessage('wangEditor.messageOverSizeText', '超过文件大小限制,最大文件大小为'),
96
+ messageUploadFailText: intl.getMessage('wangEditor.imageUploadFailed', '上传出错'),
97
+ messageInsertImgFailText: intl.getMessage('wangEditor.imageUploadFailed', '插入图片失败'),
98
+ messageInsertVideoFailText: intl.getMessage('wangEditor.imageUploadFailed', '插入视频失败'),
99
+ messageInsertAttachmentFailText: ('wangEditor.imageUploadFailed', '插入附件失败')
100
+ }, props.customEnumText);
68
101
  var mergedStatus = getMergedStatus(contextStatus, customStatus);
69
- var _useState = useState(null),
70
- _useState2 = _slicedToArray(_useState, 2),
71
- editor = _useState2[0],
72
- setEditor = _useState2[1];
102
+ var _useState5 = useState(null),
103
+ _useState6 = _slicedToArray(_useState5, 2),
104
+ editor = _useState6[0],
105
+ setEditor = _useState6[1];
106
+ useEffect(function () {
107
+ if (language) {
108
+ console.log('language', language);
109
+ i18nChangeLanguage(language);
110
+ }
111
+ }, [language]);
73
112
 
74
113
  // 及时销毁 editor ,重要!
75
114
  useEffect(function () {
76
115
  return function () {
116
+ window.REGISTRY_UPLOAD_FILE = false;
117
+ if (editor == null) return;
77
118
  if (editor) {
78
119
  editor.destroy();
79
120
  setEditor(null);
80
121
  }
81
122
  };
82
123
  }, []);
124
+ useEffect(function () {
125
+ valueRef.current = value;
126
+ }, [value]);
127
+
128
+ // 修改安全的粘贴处理函数
129
+ var handleSafePaste = useCallback( /*#__PURE__*/function () {
130
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(editor, event) {
131
+ var html, rtf, plainText, imgSrcs, rtfImageData;
132
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
133
+ while (1) switch (_context.prev = _context.next) {
134
+ case 0:
135
+ event.preventDefault();
136
+ _context.prev = 1;
137
+ // 获取粘贴内容
138
+ html = event.clipboardData.getData('text/html');
139
+ rtf = event.clipboardData.getData('text/rtf');
140
+ plainText = event.clipboardData.getData('text/plain'); // 如果没有HTML内容,直接粘贴纯文本
141
+ if (html) {
142
+ _context.next = 8;
143
+ break;
144
+ }
145
+ if (plainText) {
146
+ setTimeout(function () {
147
+ editor.insertText(plainText);
148
+ }, 0);
149
+ }
150
+ return _context.abrupt("return", false);
151
+ case 8:
152
+ // 安全过滤原始HTML内容
153
+ if (enableSanitization) {
154
+ html = sanitizeHtml(html);
155
+ }
156
+
157
+ // 处理Word粘贴(包含RTF数据)
158
+ if (!rtf) {
159
+ _context.next = 32;
160
+ break;
161
+ }
162
+ _context.prev = 10;
163
+ // 列表缩进会超出边框,直接过滤掉
164
+ html = html.replace(/text\-indent:\-(.*?)pt/gi, '');
165
+
166
+ // 从html内容中查找粘贴内容中是否有图片元素
167
+ imgSrcs = findAllImgSrcsFromHtml(html);
168
+ html = replaceAllSpanFontSize(html);
169
+
170
+ // 处理图片(如果有的话)
171
+ if (!(imgSrcs && Array.isArray(imgSrcs) && imgSrcs.length)) {
172
+ _context.next = 27;
173
+ break;
174
+ }
175
+ rtfImageData = extractImageDataFromRtf(rtf);
176
+ if (!rtfImageData.length) {
177
+ _context.next = 27;
178
+ break;
179
+ }
180
+ _context.prev = 17;
181
+ _context.next = 20;
182
+ return replaceImagesFileSourceWithInlineRepresentation(html, imgSrcs, rtfImageData, true, uploadUrl, downloadUrl);
183
+ case 20:
184
+ html = _context.sent;
185
+ // 对处理后的HTML再次进行安全过滤
186
+ if (enableSanitization) {
187
+ html = sanitizeHtml(html);
188
+ }
189
+ _context.next = 27;
190
+ break;
191
+ case 24:
192
+ _context.prev = 24;
193
+ _context.t0 = _context["catch"](17);
194
+ console.warn('图片处理失败,将跳过图片处理:', _context.t0.message);
195
+ // 图片处理失败时,保留原始HTML(不含图片)
196
+ // 不抛出错误,继续处理文字内容
197
+ case 27:
198
+ _context.next = 32;
199
+ break;
200
+ case 29:
201
+ _context.prev = 29;
202
+ _context.t1 = _context["catch"](10);
203
+ console.warn('Word内容处理失败,将粘贴原始内容:', _context.t1.message);
204
+ // 处理失败时,回退到原始HTML
205
+ case 32:
206
+ // 安全插入HTML(无论是处理过的还是原始的)
207
+ setTimeout(function () {
208
+ try {
209
+ editor.dangerouslyInsertHtml(html);
210
+ } catch (insertError) {
211
+ // 如果HTML插入失败,尝试插入纯文本作为备选
212
+ if (plainText) {
213
+ editor.insertText(plainText);
214
+ }
215
+ handleError(new Error('内容插入失败: ' + insertError.message));
216
+ }
217
+ }, 0);
218
+ return _context.abrupt("return", false);
219
+ case 36:
220
+ _context.prev = 36;
221
+ _context.t2 = _context["catch"](1);
222
+ // 最后的兜底处理
223
+ console.error('粘贴处理严重错误:', _context.t2);
224
+ if (event.clipboardData.getData('text/plain')) {
225
+ // 至少确保文字能够粘贴
226
+ setTimeout(function () {
227
+ editor.insertText(event.clipboardData.getData('text/plain'));
228
+ }, 0);
229
+ }
230
+ handleError(new Error('粘贴处理失败: ' + _context.t2.message));
231
+ return _context.abrupt("return", false);
232
+ case 42:
233
+ case "end":
234
+ return _context.stop();
235
+ }
236
+ }, _callee, null, [[1, 36], [10, 29], [17, 24]]);
237
+ }));
238
+ return function (_x, _x2) {
239
+ return _ref.apply(this, arguments);
240
+ };
241
+ }(), [uploadUrl, downloadUrl, enableSanitization, handleError]);
242
+
243
+ // 添加安全的onChange处理
244
+ var handleEditorChange = useCallback(function (editor) {
245
+ try {
246
+ var newValue = editor.getHtml() || undefined;
247
+ // 对输出内容也进行安全过滤
248
+ var processedValue = enableSanitization && newValue !== undefined ? sanitizeHtml(newValue) : newValue;
249
+ // console.log('编辑器内容变化,处理前内容:', newValue);
250
+ // console.log('编辑器内容变化,处理后内容:', processedValue);
251
+ if (processedValue !== valueRef.current) {
252
+ if (processedValue === undefined) {
253
+ onChange('');
254
+ } else {
255
+ onChange(processedValue);
256
+ }
257
+ }
258
+ } catch (error) {
259
+ handleError(new Error('编辑器内容处理失败: ' + error.message));
260
+ }
261
+ }, [value, onChange, enableSanitization, handleError]);
262
+
83
263
  // 编辑器配置
84
- var editorConfig = {
264
+ var editorConfig = _objectSpread(_objectSpread({}, editConfig), {}, {
85
265
  MENU_CONF: {
86
266
  // 插入图片
87
267
  uploadImage: {
88
268
  server: uploadUrl,
89
- maxFileSize: maxFileSize,
269
+ maxFileSize: defaultMaxFileSize,
90
270
  maxNumberOfFiles: maxNumberOfFiles,
271
+ headers: {
272
+ access_token: getToken(),
273
+ Authorization: 'Bearer ' + getToken()
274
+ },
91
275
  // onSuccess(file, res) {},
276
+ onBeforeUpload: function onBeforeUpload(file) {
277
+ for (var key in file) {
278
+ if (file[key].size > maxFileSize) {
279
+ message.warn("".concat(TextEnum.messageOverSizeText).concat(maxFileSize / 1024 / 1024, "M"));
280
+ // return { [key]: false };
281
+ return {};
282
+ }
283
+ }
284
+ return file;
285
+ },
286
+ onError: function onError(file, err, res) {
287
+ console.log("".concat(file.name, " ").concat(TextEnum.messageUploadFailText), err, res);
288
+ },
92
289
  customInsert: function customInsert(res, insertFn) {
93
- console.log(res, insertFn);
94
- // res 即服务端的返回结果
95
- // 从 res 中找到 url alt href ,然后插入图片
96
- if (res.result == 0) {
97
- res.data.map(function (item) {
98
- insertFn("".concat(downloadUrl).concat(item.id), item.fileName);
99
- });
100
- } else {
101
- console.log(111);
102
- throw new Error(intl.getMessage('wangEditor.imageInsertionFailed', '插入图片失败'));
290
+ try {
291
+ // res 即服务端的返回结果
292
+ // 从 res 中找到 url alt href ,然后插入图片
293
+ if (res.result == 0) {
294
+ res.data.map(function (item) {
295
+ insertFn("".concat(downloadUrl).concat(item.id), item.fileName);
296
+ });
297
+ } else {
298
+ throw new Error("".concat(TextEnum.messageInsertImgFailText));
299
+ }
300
+ } catch (error) {
301
+ handleError(error);
103
302
  }
104
303
  }
105
304
  },
106
305
  // 插入视频
107
306
  uploadVideo: {
108
307
  server: uploadUrl,
308
+ maxFileSize: defaultMaxFileSize,
309
+ headers: {
310
+ access_token: getToken(),
311
+ Authorization: 'Bearer ' + getToken()
312
+ },
313
+ onError: function onError(file, err, res) {
314
+ console.log("".concat(file.name, " ").concat(TextEnum.messageUploadFailText), err, res);
315
+ },
316
+ onBeforeUpload: function onBeforeUpload(file) {
317
+ for (var key in file) {
318
+ if (file[key].size > maxFileSize) {
319
+ message.warn("".concat(TextEnum.messageOverSizeText).concat(maxFileSize / 1024 / 1024, "M"));
320
+
321
+ // return { [key]: false };
322
+ return {};
323
+ }
324
+ }
325
+ return file;
326
+ },
109
327
  // onSuccess(file, res) {},
110
328
  // 上传成功后,用户自定义插入文件
111
329
  customInsert: function customInsert(res, insertFn) {
112
- if (res.result == 0) {
113
- res.data.map(function (item) {
114
- insertFn("".concat(downloadUrl).concat(item.id), item.fileName);
115
- });
116
- } else {
117
- throw new Error(intl.getMessage('wangEditor.videoInsertionFailed', '插入视频失败'));
330
+ try {
331
+ if (res.result == 0) {
332
+ res.data.map(function (item) {
333
+ insertFn("".concat(downloadUrl).concat(item.id), item.fileName);
334
+ });
335
+ } else {
336
+ throw new Error("".concat(TextEnum.messageInsertVideoFailText));
337
+ }
338
+ } catch (error) {
339
+ handleError(error);
118
340
  }
119
341
  }
120
342
  },
121
343
  // 插入附件
122
344
  uploadAttachment: {
123
345
  server: uploadUrl,
346
+ headers: {
347
+ access_token: getToken(),
348
+ Authorization: 'Bearer ' + getToken()
349
+ },
350
+ onError: function onError(file, err, res) {
351
+ console.log("".concat(file.name, " ").concat(TextEnum.messageUploadFailText), err, res);
352
+ },
124
353
  // onSuccess(file, res) {},
125
354
  // 上传成功后,用户自定义插入文件
126
355
  customInsert: function customInsert(res, file, insertFn) {
127
- if (res.result == 0) {
128
- res.data.map(function (item) {
129
- insertFn(item.fileName, "".concat(downloadUrl).concat(item.id));
130
- });
131
- } else {
132
- throw new Error(intl.getMessage('wangEditor.attachmentInsertionFailed', '插入附件失败'));
356
+ try {
357
+ if (res.result == 0) {
358
+ res.data.map(function (item) {
359
+ insertFn(item.fileName, "".concat(downloadUrl).concat(item.id));
360
+ });
361
+ } else {
362
+ throw new Error("".concat(TextEnum.messageInsertAttachmentFailText));
363
+ }
364
+ } catch (error) {
365
+ handleError(error);
133
366
  }
134
367
  }
135
368
  }
@@ -141,74 +374,19 @@ var VtxWangEditor = function VtxWangEditor(props) {
141
374
  menuKeys: ['downloadAttachment'] // “下载附件”菜单
142
375
  }
143
376
  },
144
- customPaste: function () {
145
- var _customPaste = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(editor, event) {
146
- var html, rtf, imgSrcs, rtfImageData;
147
- return _regeneratorRuntime().wrap(function _callee$(_context) {
148
- while (1) switch (_context.prev = _context.next) {
149
- case 0:
150
- event.preventDefault();
151
- // 获取粘贴的html部分(??没错粘贴word时候,一部分内容就是html),该部分包含了图片img标签
152
- html = event.clipboardData.getData('text/html'); // 获取rtf数据(从word、wps复制粘贴时有),复制粘贴过程中图片的数据就保存在rtf中
153
- rtf = event.clipboardData.getData('text/rtf'); // 该条件分支即表示要自定义word粘贴
154
- if (!(html && rtf)) {
155
- _context.next = 17;
156
- break;
157
- }
158
- // 列表缩进会超出边框,直接过滤掉
159
- html = html.replace(/text\-indent:\-(.*?)pt/gi, '');
160
-
161
- // 从html内容中查找粘贴内容中是否有图片元素,并返回img标签的属性src值的集合
162
- imgSrcs = findAllImgSrcsFromHtml(html);
163
- html = replaceAllSpanFontSize(html);
164
-
165
- // 如果有图片
166
- if (!(imgSrcs && Array.isArray(imgSrcs) && imgSrcs.length)) {
167
- _context.next = 13;
168
- break;
169
- }
170
- // 从rtf内容中查找图片数据
171
- // 从rtf内容中查找图片数据
172
- rtfImageData = extractImageDataFromRtf(rtf);
173
- if (!rtfImageData.length) {
174
- _context.next = 13;
175
- break;
176
- }
177
- _context.next = 12;
178
- return replaceImagesFileSourceWithInlineRepresentation(html, imgSrcs, rtfImageData, true, uploadUrl, downloadUrl);
179
- case 12:
180
- html = _context.sent;
181
- case 13:
182
- editor.dangerouslyInsertHtml(html);
183
- return _context.abrupt("return", false);
184
- case 17:
185
- if (!html) {
186
- _context.next = 20;
187
- break;
188
- }
189
- editor.dangerouslyInsertHtml(html);
190
- return _context.abrupt("return", false);
191
- case 20:
192
- case "end":
193
- return _context.stop();
194
- }
195
- }, _callee);
196
- }));
197
- function customPaste(_x, _x2) {
198
- return _customPaste.apply(this, arguments);
199
- }
200
- return customPaste;
201
- }()
202
- };
377
+ // 使用安全的粘贴处理函数
378
+ customPaste: handleSafePaste
379
+ });
203
380
  // 工具栏配置
204
- var toolbarConfig = {
381
+ var toolbarConfig = _objectSpread(_objectSpread({}, toolConfig), {}, {
382
+ // 自定义工具栏
205
383
  insertKeys: {
206
384
  // 自定义插入的位置
207
385
  index: 24,
208
386
  // “上传附件”菜单
209
387
  keys: ['uploadAttachment']
210
388
  }
211
- };
389
+ });
212
390
  return /*#__PURE__*/_jsxs("div", {
213
391
  className: cls(prefixCls, getStatusClassNames(prefixCls, mergedStatus, hasFeedback), props.prefixCls),
214
392
  children: [/*#__PURE__*/_jsx(Toolbar, {
@@ -217,19 +395,14 @@ var VtxWangEditor = function VtxWangEditor(props) {
217
395
  mode: "default"
218
396
  }), /*#__PURE__*/_jsx(Editor, _objectSpread({
219
397
  defaultConfig: editorConfig,
220
- value: value ? value : '',
221
- onCreated: function onCreated(editor) {
222
- setEditor(editor);
223
- },
224
- onChange: function onChange(editor) {
225
- var nextValue = value ? value : undefined;
226
- var prevValue = editor.getHtml() ? editor.getHtml() : undefined;
227
- if (nextValue !== prevValue) {
228
- _onChange(editor.getHtml());
229
- }
230
- },
398
+ value: value ? enableSanitization ? sanitizeHtml(value) : value : '',
399
+ onCreated: setEditor,
400
+ onChange: handleEditorChange,
231
401
  mode: "default",
232
- className: cls("".concat(prefixCls, "-content"), hashId)
402
+ className: cls("".concat(prefixCls, "-content"), hashId),
403
+ style: {
404
+ height: height
405
+ }
233
406
  }, rest))]
234
407
  });
235
408
  };
@@ -241,5 +414,10 @@ VtxWangEditor.propTypes = {
241
414
  placeholder: PropTypes.string,
242
415
  downloadUrl: PropTypes.string,
243
416
  uploadUrl: PropTypes.string,
244
- height: PropTypes.number
417
+ height: PropTypes.number,
418
+ maxFileSize: PropTypes.number,
419
+ maxNumberOfFiles: PropTypes.number,
420
+ status: PropTypes.string,
421
+ prefixCls: PropTypes.string,
422
+ enableSanitization: PropTypes.bool // 是否启用HTML过滤
245
423
  };