@quansitech/antd-admin 1.1.8 → 1.1.10

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.
@@ -1,4 +1,5 @@
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
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
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; }
3
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); } }
4
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); }); }; }
@@ -102,11 +103,11 @@ export default function (props) {
102
103
  };
103
104
  return /*#__PURE__*/React.createElement("div", {
104
105
  className: props.className
105
- }, /*#__PURE__*/React.createElement(Cascader, {
106
+ }, /*#__PURE__*/React.createElement(Cascader, _extends({}, props.fieldProps, {
106
107
  options: options,
107
108
  onChange: onChange,
108
109
  placeholder: '请选择',
109
110
  value: values,
110
111
  loadData: props.fieldProps.loadDataUrl ? loadData : undefined
111
- }));
112
+ })));
112
113
  }
@@ -2,7 +2,6 @@ declare const _default: {
2
2
  Cascader: () => Promise<typeof import("./Cascader")>;
3
3
  File: () => Promise<typeof import("./File")>;
4
4
  Image: () => Promise<typeof import("./Image")>;
5
- Ueditor: () => Promise<typeof import("./Ueditor")>;
6
5
  Action: () => Promise<typeof import("./Action")>;
7
6
  };
8
7
  export default _default;
@@ -8,9 +8,6 @@ export default {
8
8
  Image: function Image() {
9
9
  return import("./Image");
10
10
  },
11
- Ueditor: function Ueditor() {
12
- return import("./Ueditor");
13
- },
14
11
  Action: function Action() {
15
12
  return import("./Action");
16
13
  }
@@ -2,6 +2,5 @@ declare const _default: {
2
2
  Cascader: () => Promise<typeof import("./Cascader")>;
3
3
  File: () => Promise<typeof import("./File")>;
4
4
  Image: () => Promise<typeof import("./Image")>;
5
- Ueditor: () => Promise<typeof import("./Ueditor")>;
6
5
  };
7
6
  export default _default;
@@ -7,8 +7,5 @@ export default {
7
7
  },
8
8
  Image: function Image() {
9
9
  return import("./Image");
10
- },
11
- Ueditor: function Ueditor() {
12
- return import("./Ueditor");
13
10
  }
14
11
  };
@@ -27,14 +27,14 @@ export default function (props) {
27
27
  }
28
28
  var onStartClick = function onStartClick() {
29
29
  var rowKey = tableContext.getTableProps().rowKey;
30
- allChildren(tableContext.getTableProps().dataSource, function (item) {
30
+ allChildren(tableContext.dataSource, function (item) {
31
31
  var _tableContext$actionR;
32
32
  (_tableContext$actionR = tableContext.actionRef) === null || _tableContext$actionR === void 0 || _tableContext$actionR.startEditable(item[rowKey], item);
33
33
  });
34
34
  };
35
35
  var onCancelClick = function onCancelClick() {
36
36
  var rowKey = tableContext.getTableProps().rowKey;
37
- allChildren(tableContext.getTableProps().dataSource, function (item) {
37
+ allChildren(tableContext.dataSource, function (item) {
38
38
  var _tableContext$actionR2;
39
39
  (_tableContext$actionR2 = tableContext.actionRef) === null || _tableContext$actionR2 === void 0 || _tableContext$actionR2.cancelEditable(item[rowKey]);
40
40
  });
@@ -17,6 +17,7 @@ import tableAction from "../components/Table/Action";
17
17
  import formAction from "../components/Form/Action";
18
18
  import { lazy } from "react";
19
19
  import { lowerFirst } from "lodash";
20
+ import { calc_file_hash } from "./upload";
20
21
  var components = {};
21
22
  var container = {
22
23
  register: function register(name, componentLoader) {
@@ -50,6 +51,16 @@ var container = {
50
51
  schemaHandler: schemaHandler,
51
52
  routerNavigateTo: routerNavigateTo
52
53
  };
54
+ if (typeof window !== 'undefined') {
55
+ ;
56
+ (function (globalThis) {
57
+ if (globalThis.$qsContainer) {
58
+ return;
59
+ }
60
+ globalThis.$qsContainer = container;
61
+ globalThis.calc_file_hash = calc_file_hash;
62
+ })(window);
63
+ }
53
64
  function autoRegister(_x, _x2) {
54
65
  return _autoRegister.apply(this, arguments);
55
66
  } // -------- 通用 -----------
@@ -166,6 +166,7 @@ export function getProValueTypeMap() {
166
166
  }, {});
167
167
  }
168
168
  export function handleCondition(condition, data) {
169
+ var _condition$value, _condition$value2;
169
170
  switch (condition.operator) {
170
171
  case 'eq':
171
172
  case '=':
@@ -187,9 +188,9 @@ export function handleCondition(condition, data) {
187
188
  case '<=':
188
189
  return data[condition.field] <= condition.value;
189
190
  case 'in':
190
- return data[condition.field] && condition.value.includes(data[condition.field]);
191
+ return (_condition$value = condition.value) === null || _condition$value === void 0 ? void 0 : _condition$value.includes(data[condition.field]);
191
192
  case 'not in':
192
- return data[condition.field] && !condition.value.includes(data[condition.field]);
193
+ return !((_condition$value2 = condition.value) !== null && _condition$value2 !== void 0 && _condition$value2.includes(data[condition.field]));
193
194
  }
194
195
  return false;
195
196
  }
@@ -1,5 +1,6 @@
1
+ import axios from "axios";
1
2
  /**
2
3
  * fetchOptions.noHandle 成功时不处理 url 和 info
3
4
  */
4
- declare const http: import("axios").AxiosInstance;
5
+ declare const http: axios.AxiosInstance;
5
6
  export default http;
@@ -105,20 +105,24 @@ export var schemaHandler = {
105
105
  return schema;
106
106
  },
107
107
  dependency: function dependency(schema) {
108
- var _columns = schema.columns,
108
+ var _columns;
109
+ var _columns2 = schema.columns,
109
110
  valueType = schema.valueType;
111
+ _columns2 = ((_columns = _columns2) === null || _columns === void 0 ? void 0 : _columns.map(function (c) {
112
+ commonHandler(c);
113
+ if (container.schemaHandler[c.valueType]) {
114
+ return container.schemaHandler[c.valueType](c);
115
+ }
116
+ return c;
117
+ })) || [];
110
118
  return {
111
119
  valueType: valueType,
112
120
  name: [schema.showCondition.field],
113
121
  columns: function columns(fields) {
114
- _columns = _columns.map(function (c) {
115
- commonHandler(c);
116
- if (container.schemaHandler[c.valueType]) {
117
- return container.schemaHandler[c.valueType](c);
118
- }
119
- return c;
120
- });
121
- return handleCondition(schema.showCondition, fields) ? _columns : [];
122
+ if (schema.showCondition) {
123
+ return handleCondition(schema.showCondition, fields) ? _columns2 : [];
124
+ }
125
+ return _columns2;
122
126
  }
123
127
  };
124
128
  },
@@ -20,9 +20,9 @@ export default function () {
20
20
  var extra_script = "\nimport {container} from \"@quansitech/antd-admin\";\n\n".concat(extras.map(function (e) {
21
21
  var cs = [];
22
22
  for (var componentKey in e.component) {
23
- cs.push("container.register('".concat(componentKey, "', ()=>import('../../../vendor").concat(path.join('/', e.path, e.component[componentKey]), "'));"));
23
+ cs.push("container.register('".concat(componentKey, "', ()=>import('../../../vendor").concat(path.join('/', e.path, e.component[componentKey]).split(path.sep).join('/'), "'));"));
24
24
  }
25
25
  return cs.join('\n');
26
- }), "\n");
26
+ }).join('\n'), "\n");
27
27
  fs.writeFileSync(process.cwd() + '/resources/js/backend/extra.ts', extra_script);
28
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quansitech/antd-admin",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -1,4 +0,0 @@
1
- import { ColumnReadonlyProps } from "./types";
2
- import React from "react";
3
- import "./Ueditor.scss";
4
- export default function (props: ColumnReadonlyProps): React.JSX.Element;
@@ -1,25 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- 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."); }
3
- 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); }
4
- 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; }
5
- 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; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { useEffect, useState } from "react";
8
- import "./Ueditor.scss";
9
- export default function (props) {
10
- var _useState = useState(props.fieldProps.value),
11
- _useState2 = _slicedToArray(_useState, 2),
12
- value = _useState2[0],
13
- setValue = _useState2[1];
14
- useEffect(function () {
15
- var div = document.createElement('div');
16
- div.innerHTML = props.fieldProps.value;
17
- setValue(div.innerText);
18
- }, []);
19
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
20
- className: 'article-content',
21
- dangerouslySetInnerHTML: {
22
- __html: value
23
- }
24
- }));
25
- }
@@ -1,6 +0,0 @@
1
- .article-content {
2
- img {
3
- max-width: 100%;
4
- height: auto;
5
- }
6
- }
@@ -1,26 +0,0 @@
1
- import { ColumnProps } from "./types";
2
- import React, { Component } from "react";
3
- import { ModalContextProps } from "../ModalContext";
4
- declare global {
5
- interface Window {
6
- UE: any;
7
- UE_LOADING_PROMISE: Promise<any>;
8
- }
9
- }
10
- export default class Ueditor extends Component<ColumnProps & {
11
- fieldProps: {
12
- ueditorPath: string;
13
- };
14
- }, any> {
15
- modalContext: ModalContextProps;
16
- editor: any;
17
- containerRef: HTMLElement | null;
18
- state: {
19
- loading: boolean;
20
- containerId: string;
21
- width: string;
22
- };
23
- componentDidMount(): void;
24
- componentWillUnmount(): void;
25
- render(): React.JSX.Element;
26
- }
@@ -1,311 +0,0 @@
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
- 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; }
3
- 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; }
4
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
8
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
11
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14
- 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; }
15
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
- 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); }
17
- import React, { Component } from "react";
18
- import { createScript } from "../../lib/helpers";
19
- import { Spin } from "antd";
20
- import { ModalContext } from "../ModalContext";
21
- import { uniqueId } from "es-toolkit/compat";
22
- var Ueditor = /*#__PURE__*/function (_Component) {
23
- _inherits(Ueditor, _Component);
24
- var _super = _createSuper(Ueditor);
25
- function Ueditor() {
26
- var _this;
27
- _classCallCheck(this, Ueditor);
28
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
- args[_key] = arguments[_key];
30
- }
31
- _this = _super.call.apply(_super, [this].concat(args));
32
- _defineProperty(_assertThisInitialized(_this), "modalContext", {});
33
- _defineProperty(_assertThisInitialized(_this), "editor", null);
34
- _defineProperty(_assertThisInitialized(_this), "containerRef", null);
35
- _defineProperty(_assertThisInitialized(_this), "state", {
36
- loading: true,
37
- containerId: uniqueId('ueditor_'),
38
- width: ''
39
- });
40
- return _this;
41
- }
42
- _createClass(Ueditor, [{
43
- key: "componentDidMount",
44
- value: function componentDidMount() {
45
- var _this$containerRef,
46
- _this$containerRef2,
47
- _this2 = this;
48
- this.setState({
49
- width: (_this$containerRef = this.containerRef) !== null && _this$containerRef !== void 0 && _this$containerRef.offsetWidth ? "".concat((_this$containerRef2 = this.containerRef) === null || _this$containerRef2 === void 0 ? void 0 : _this$containerRef2.offsetWidth, "px") : '100%'
50
- });
51
- if (!window.UE && !window.UE_LOADING_PROMISE) {
52
- window.UE_LOADING_PROMISE = createScript(this.props.fieldProps.configJsPath || this.props.fieldProps.ueditorPath + '/ueditor.config.js').then(function () {
53
- return createScript(_this2.props.fieldProps.ueditorPath + '/ueditor.all.js');
54
- }).then(function () {
55
- return createScript(_this2.props.fieldProps.ueditorPath + '/lang/zh-cn/zh-cn.js');
56
- });
57
- }
58
- window.UE_LOADING_PROMISE.then(function () {
59
- var _this2$props$fieldPro, _this2$props$fieldPro2, _this2$modalContext, _this2$editor;
60
- var that = _this2;
61
- window.UE.plugins['forceCatchRemoteImg'] = function () {
62
- if (this.options.forcecatchremote) {
63
- // @ts-ignore
64
- this.addListener("afterpaste", function (t, a) {
65
- var load_src = that.props.fieldProps.ueditorPath + '/img/load.gif';
66
- var domUtils = window.UE.dom.domUtils;
67
- var parser = new DOMParser();
68
- var pasteDom = parser.parseFromString(a.html, "text/html");
69
-
70
- // @ts-ignore
71
- var allImgs = domUtils.getElementsByTagName(this.document, "img");
72
- var imgs = domUtils.getElementsByTagName(pasteDom, "img");
73
- var notCatch = function notCatch(src) {
74
- if (src.indexOf(location.host) !== -1) {
75
- return true;
76
- }
77
- if (/(^\.)|(^\/)/.test(src)) {
78
- return true;
79
- }
80
- return src.indexOf('img_catch_success') !== -1;
81
- };
82
- var catchGo = false;
83
- for (var i = 0; i < imgs.length; i++) {
84
- if (notCatch(imgs[i].src)) {
85
- continue;
86
- }
87
- for (var l = 0; l < allImgs.length; l++) {
88
- if (allImgs[l].src == imgs[i].src) {
89
- catchGo = true;
90
- domUtils.setAttributes(allImgs[l], {
91
- "src": load_src,
92
- "_src": allImgs[l].src
93
- });
94
- }
95
- }
96
- }
97
- if (catchGo) {
98
- var _that$editor, _that$props$form;
99
- // $('.submit').trigger('startHandlePostData', '正在抓取图片');
100
- that.setState({
101
- loading: true
102
- });
103
- that.props.fieldProps.onChange('[抓取图片中]' + ((_that$editor = that.editor) === null || _that$editor === void 0 ? void 0 : _that$editor.getContent().replace(/^\[抓取图片中]/, '')));
104
- that.props.dataIndex && ((_that$props$form = that.props.form) === null || _that$props$form === void 0 ? void 0 : _that$props$form.validateFields([that.props.dataIndex]));
105
- }
106
- });
107
- this.addListener("catchremotesuccess", function () {
108
- var _that$editor2, _that$props$form2;
109
- that.props.fieldProps.onChange((_that$editor2 = that.editor) === null || _that$editor2 === void 0 ? void 0 : _that$editor2.getContent().replace(/^\[抓取图片中]/, ''));
110
- that.props.dataIndex && ((_that$props$form2 = that.props.form) === null || _that$props$form2 === void 0 ? void 0 : _that$props$form2.validateFields([that.props.dataIndex]));
111
- that.setState({
112
- loading: false
113
- });
114
- // $('.submit').trigger('endHandlePostData');
115
- });
116
- }
117
- };
118
-
119
- // plugins/insert_richtext.js
120
- /**
121
- * 抓取微信富文本
122
- */
123
- window.UE.plugin.register('insert_richtext', function () {
124
- // @ts-ignore
125
- var me = this;
126
- function filter(div) {
127
- var domUtils = window.UE.dom.domUtils;
128
- var browser = window.UE.browser;
129
- var utils = window.UE.utils;
130
- var html;
131
- var ci;
132
- if (div.firstChild) {
133
- //去掉cut中添加的边界值
134
- var nodes = domUtils.getElementsByTagName(div, 'span');
135
- for (var i = 0, ni; ni = nodes[i++];) {
136
- if (ni.id == '_baidu_cut_start' || ni.id == '_baidu_cut_end') {
137
- domUtils.remove(ni);
138
- }
139
- }
140
- if (browser.webkit) {
141
- var brs = div.querySelectorAll('div br');
142
- for (var _i = 0, bi; bi = brs[_i++];) {
143
- var pN = bi.parentNode;
144
- if (pN) {
145
- if (pN.tagName == 'DIV' && pN.childNodes.length == 1) {
146
- pN.innerHTML = '<p><br/></p>';
147
- domUtils.remove(pN);
148
- }
149
- }
150
- }
151
- var divs = div.querySelectorAll('#baidu_pastebin');
152
- for (var _i2 = 0, di; di = divs[_i2++];) {
153
- var _di$parentNode;
154
- var tmpP = me.document.createElement('p');
155
- (_di$parentNode = di.parentNode) === null || _di$parentNode === void 0 || _di$parentNode.insertBefore(tmpP, di);
156
- while (di.firstChild) {
157
- tmpP.appendChild(di.firstChild);
158
- }
159
- domUtils.remove(di);
160
- }
161
- var metas = div.querySelectorAll('meta');
162
- for (var _i3 = 0, _ci; _ci = metas[_i3++];) {
163
- domUtils.remove(_ci);
164
- }
165
- brs = div.querySelectorAll('br');
166
- for (var _i4 = 0; ci = brs[_i4++];) {
167
- if (/^apple-/i.test(ci.className)) {
168
- domUtils.remove(ci);
169
- }
170
- }
171
- }
172
- if (browser.gecko) {
173
- var dirtyNodes = div.querySelectorAll('[_moz_dirty]');
174
- for (var _i5 = 0; ci = dirtyNodes[_i5++];) {
175
- ci.removeAttribute('_moz_dirty');
176
- }
177
- }
178
- if (!browser.ie) {
179
- var spans = div.querySelectorAll('span.Apple-style-span');
180
- for (var _i6 = 0, _ci2; _ci2 = spans[_i6++];) {
181
- domUtils.remove(_ci2, true);
182
- }
183
- }
184
-
185
- //ie下使用innerHTML会产生多余的\r\n字符,也会产生&nbsp;这里过滤掉
186
- html = div.innerHTML; //.replace(/>(?:(\s|&nbsp;)*?)</g,'><');
187
-
188
- //过滤word粘贴过来的冗余属性
189
- html = window.UE.filterWord(html);
190
- //取消了忽略空白的第二个参数,粘贴过来的有些是有空白的,会被套上相关的标签
191
- var root = window.UE.htmlparser(html);
192
-
193
- //如果给了过滤规则就先进行过滤
194
- if (me.options.filterRules) {
195
- window.UE.filterNode(root, me.options.filterRules);
196
- }
197
- //执行默认的处理
198
- me.filterInputRule(root);
199
- //针对chrome的处理
200
- if (browser.webkit) {
201
- var br = root.lastChild();
202
- if (br && br.type == 'element' && br.tagName == 'br') {
203
- root.removeChild(br);
204
- }
205
- utils.each(me.body.querySelectorAll('div'), function (node) {
206
- if (domUtils.isEmptyBlock(node)) {
207
- domUtils.remove(node, true);
208
- }
209
- });
210
- }
211
- html = {
212
- 'html': root.toHtml()
213
- };
214
- me.fireEvent('beforepaste', html, root);
215
- //抢了默认的粘贴,那后边的内容就不执行了,比如表格粘贴
216
- if (!html.html) {
217
- return;
218
- }
219
- root = window.UE.htmlparser(html.html, true);
220
- //如果开启了纯文本模式
221
- if (me.queryCommandState('pasteplain') === 1) {
222
- me.execCommand('insertHtml', window.UE.filterNode(root, me.options.filterTxtRules).toHtml(), true);
223
- } else {
224
- //文本模式
225
- window.UE.filterNode(root, me.options.filterTxtRules);
226
- var txtContent = root.toHtml();
227
- //完全模式
228
- var htmlContent = html.html;
229
- var address = me.selection.getRange().createAddress(true);
230
- // @ts-ignore
231
- me.execCommand('insertHtml', me.getOpt('retainOnlyLabelPasted') === true ? getPureHtml(htmlContent) : htmlContent, true);
232
- }
233
- me.fireEvent("afterpaste", html);
234
- }
235
- }
236
- return {
237
- bindEvents: {
238
- 'afterInsertRichText': function afterInsertRichText(e, html) {
239
- var _that$editor3, _that$props$form3;
240
- me.execCommand('cleardoc');
241
- filter.call(me, html);
242
- me.document.body.innerHTML = "<section>".concat(html, "</section>");
243
- me.fireEvent('catchremoteimage');
244
- that.setState({
245
- loading: true
246
- });
247
- that.props.fieldProps.onChange('[抓取图片中]' + ((_that$editor3 = that.editor) === null || _that$editor3 === void 0 ? void 0 : _that$editor3.getContent().replace(/^\[抓取图片中]/, '')));
248
- that.props.dataIndex && ((_that$props$form3 = that.props.form) === null || _that$props$form3 === void 0 ? void 0 : _that$props$form3.validateFields([that.props.dataIndex]));
249
- }
250
- },
251
- commands: {}
252
- };
253
- });
254
- var config = _objectSpread(_objectSpread({}, (_this2$props$fieldPro = _this2.props.fieldProps) === null || _this2$props$fieldPro === void 0 ? void 0 : _this2$props$fieldPro.config), {}, {
255
- forcecatchremote: typeof ((_this2$props$fieldPro2 = _this2.props.fieldProps) === null || _this2$props$fieldPro2 === void 0 || (_this2$props$fieldPro2 = _this2$props$fieldPro2.config) === null || _this2$props$fieldPro2 === void 0 ? void 0 : _this2$props$fieldPro2.forcecatchremote) === 'undefined' ? true : _this2.props.fieldProps.config.forcecatchremote
256
- });
257
- if ((_this2$modalContext = _this2.modalContext) !== null && _this2$modalContext !== void 0 && _this2$modalContext.inModal) {
258
- config.zIndex = 2000;
259
- config.topOffset = 0;
260
- }
261
- _this2.editor = window.UE.getEditor(_this2.state.containerId, config);
262
- (_this2$editor = _this2.editor) === null || _this2$editor === void 0 || _this2$editor.ready(function () {
263
- var _this2$editor4;
264
- var value = _this2.props.fieldProps.value;
265
- if (value) {
266
- var _this2$editor2, _this2$editor3;
267
- var div = document.createElement('div');
268
- div.innerHTML = value;
269
- (_this2$editor2 = _this2.editor) === null || _this2$editor2 === void 0 || _this2$editor2.setContent(div.innerText || '');
270
- _this2.props.fieldProps.onChange((_this2$editor3 = _this2.editor) === null || _this2$editor3 === void 0 ? void 0 : _this2$editor3.getContent());
271
- }
272
- (_this2$editor4 = _this2.editor) === null || _this2$editor4 === void 0 || _this2$editor4.addListener('contentChange', function () {
273
- var _this2$editor5;
274
- _this2.props.fieldProps.onChange((_this2$editor5 = _this2.editor) === null || _this2$editor5 === void 0 ? void 0 : _this2$editor5.getContent());
275
- });
276
- _this2.setState({
277
- loading: false
278
- });
279
- });
280
- });
281
- }
282
- }, {
283
- key: "componentWillUnmount",
284
- value: function componentWillUnmount() {
285
- var _this$editor;
286
- (_this$editor = this.editor) === null || _this$editor === void 0 || _this$editor.destroy();
287
- }
288
- }, {
289
- key: "render",
290
- value: function render() {
291
- var _this3 = this;
292
- return /*#__PURE__*/React.createElement(ModalContext.Consumer, null, function (modalContext) {
293
- _this3.modalContext = modalContext;
294
- return /*#__PURE__*/React.createElement("div", {
295
- ref: function ref(el) {
296
- return _this3.containerRef = el;
297
- }
298
- }, /*#__PURE__*/React.createElement(Spin, {
299
- spinning: _this3.state.loading
300
- }, /*#__PURE__*/React.createElement("textarea", {
301
- id: _this3.state.containerId,
302
- style: {
303
- width: _this3.state.width
304
- }
305
- })));
306
- });
307
- }
308
- }]);
309
- return Ueditor;
310
- }(Component);
311
- export { Ueditor as default };