@ctzhian/tiptap 1.4.2 → 1.5.1

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,18 +1,23 @@
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 _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
- 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
- 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
2
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
3
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
4
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
7
+ 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); } }
8
+ 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); }); }; }
9
+ 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; }
10
+ 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; }
11
+ 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; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ 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); }
9
14
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
15
  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."); }
11
16
  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); }
12
17
  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; }
13
18
  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; } }
14
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
- import { AlignBottomIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, AlignTopIcon, ArrowDownSLineIcon, AttachmentLineIcon, BrushLineIcon, DeleteLineIcon, DownloadLineIcon, DraggableIcon, FontSizeIcon, FormatClearIcon, H1Icon, H2Icon, H3Icon, ImageLineIcon, Information2LineIcon, ListCheck3Icon, ListOrdered2Icon, ListUnorderedIcon, MovieLineIcon, Music2LineIcon, QuoteTextIcon, Repeat2LineIcon, ScissorsCutLineIcon, SeparatorIcon, TextIcon, TextWrapIcon } from "../Icons";
20
+ import { AddLineIcon, AlignBottomIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, AlignTopIcon, ArrowDownSLineIcon, AttachmentLineIcon, BrushLineIcon, DeleteLineIcon, DownloadLineIcon, DraggableIcon, FontSizeIcon, FormatClearIcon, H1Icon, H2Icon, H3Icon, ImageLineIcon, IndentDecreaseIcon, IndentIncreaseIcon, Information2LineIcon, ListCheck3Icon, ListOrdered2Icon, ListUnorderedIcon, MovieLineIcon, Music2LineIcon, QuoteTextIcon, Repeat2LineIcon, ScissorsCutLineIcon, SeparatorIcon, TextIcon, TextWrapIcon } from "../Icons";
16
21
  import { NODE_TYPE_LABEL, NodeTypeEnum } from "../../contants/enums";
17
22
  import { Box, Divider, Stack, Typography, useTheme } from '@mui/material';
18
23
  import DragHandle from '@tiptap/extension-drag-handle-react';
@@ -35,7 +40,6 @@ var DragIcon = function DragIcon(_ref) {
35
40
  display: 'flex',
36
41
  alignItems: 'center',
37
42
  justifyContent: 'center',
38
- mr: 1,
39
43
  color: 'text.tertiary',
40
44
  cursor: 'grab',
41
45
  borderColor: 'divider',
@@ -56,11 +60,43 @@ var DragIcon = function DragIcon(_ref) {
56
60
  }
57
61
  }));
58
62
  };
59
- var CustomDragHandle = function CustomDragHandle(_ref2) {
63
+ var AddIcon = function AddIcon(_ref2) {
64
+ var onClick = _ref2.onClick;
65
+ return /*#__PURE__*/React.createElement(Box, {
66
+ onClick: onClick,
67
+ sx: {
68
+ width: '1.25rem',
69
+ height: '1.25rem',
70
+ borderRadius: '0.25rem',
71
+ border: '1px solid',
72
+ display: 'flex',
73
+ alignItems: 'center',
74
+ justifyContent: 'center',
75
+ color: 'text.tertiary',
76
+ cursor: 'grab',
77
+ borderColor: 'divider',
78
+ bgcolor: 'background.paper',
79
+ transition: 'all 0.2s ease-in-out',
80
+ '&:hover': {
81
+ color: 'text.secondary',
82
+ bgcolor: 'divider'
83
+ },
84
+ '&:active': {
85
+ color: 'text.primary',
86
+ cursor: 'grabbing'
87
+ }
88
+ }
89
+ }, /*#__PURE__*/React.createElement(AddLineIcon, {
90
+ sx: {
91
+ fontSize: '1.25rem'
92
+ }
93
+ }));
94
+ };
95
+ var CustomDragHandle = function CustomDragHandle(_ref3) {
60
96
  var _current$node3, _current$node4, _current$node5, _current$node6, _current$node7, _current$node8, _current$node9, _current$node10, _current$node11, _current$node12, _current$node13, _current$node14, _current$node15, _current$node16;
61
- var editor = _ref2.editor,
62
- more = _ref2.more,
63
- onTip = _ref2.onTip;
97
+ var editor = _ref3.editor,
98
+ more = _ref3.more,
99
+ onTip = _ref3.onTip;
64
100
  var theme = useTheme();
65
101
  var _useState = useState(true),
66
102
  _useState2 = _slicedToArray(_useState, 2),
@@ -196,9 +232,18 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
196
232
  return hasMarksDeep(child);
197
233
  });
198
234
  };
199
- var shouldShowButton = function shouldShowButton(_ref3) {
200
- var editor = _ref3.editor,
201
- data = _ref3.data;
235
+ var canCurrentNodeIndent = function canCurrentNodeIndent() {
236
+ return !!(current.node && current.node.type);
237
+ };
238
+ var getCurrentIndentLevel = function getCurrentIndentLevel() {
239
+ if (!canCurrentNodeIndent()) return 0;
240
+ var node = current.node;
241
+ var attrs = current.editor.getAttributes(node.type.name);
242
+ return Number(attrs.indent) || 0;
243
+ };
244
+ var shouldShowButton = function shouldShowButton(_ref4) {
245
+ var editor = _ref4.editor,
246
+ data = _ref4.data;
202
247
  if (!editor || !editor.isEditable) return false;
203
248
  var currentNode = data.node;
204
249
  var empty = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.textContent) === '';
@@ -237,10 +282,42 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
237
282
  return /*#__PURE__*/React.createElement(DragHandle, {
238
283
  editor: editor,
239
284
  onNodeChange: updateNodeChange
240
- }, currentNode ? /*#__PURE__*/React.createElement(Menu, {
285
+ }, /*#__PURE__*/React.createElement(Stack, {
286
+ direction: 'row',
287
+ alignItems: 'center',
288
+ gap: 1,
289
+ sx: {
290
+ mr: 1,
291
+ height: '1.625rem'
292
+ }
293
+ }, /*#__PURE__*/React.createElement(AddIcon, {
294
+ onClick: function onClick(event) {
295
+ event.stopPropagation();
296
+ if (current.node && current.pos !== undefined) {
297
+ if (current.pos === 0) {
298
+ current.editor.chain().focus().insertContentAt(current.pos, {
299
+ type: 'paragraph',
300
+ content: [{
301
+ type: 'text',
302
+ text: '/'
303
+ }]
304
+ }).run();
305
+ } else {
306
+ current.editor.chain().focus().insertContentAt(current.pos + current.node.nodeSize, {
307
+ type: 'paragraph',
308
+ content: [{
309
+ type: 'text',
310
+ text: '/'
311
+ }]
312
+ }).run();
313
+ }
314
+ }
315
+ }
316
+ }), currentNode ? /*#__PURE__*/React.createElement(Menu, {
317
+ context: /*#__PURE__*/React.createElement(DragIcon, null),
241
318
  anchorOrigin: {
242
- vertical: 'top',
243
- horizontal: 'right'
319
+ vertical: 'bottom',
320
+ horizontal: 'left'
244
321
  },
245
322
  transformOrigin: {
246
323
  vertical: 'top',
@@ -252,6 +329,232 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
252
329
  transform: 'rotate(-90deg)'
253
330
  }
254
331
  }),
332
+ header: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Stack, {
333
+ direction: 'row',
334
+ flexWrap: 'wrap',
335
+ sx: {
336
+ fontSize: 14
337
+ }
338
+ }, /*#__PURE__*/React.createElement(ToolbarItem, {
339
+ key: 'indent-decrease',
340
+ onClick: function onClick() {
341
+ if (!canCurrentNodeIndent()) return;
342
+ selectCurrentNode();
343
+ current.editor.chain().focus().decreaseIndent().run();
344
+ setCurrent(function (prev) {
345
+ return _objectSpread({}, prev);
346
+ });
347
+ },
348
+ icon: /*#__PURE__*/React.createElement(IndentDecreaseIcon, {
349
+ sx: {
350
+ fontSize: '1rem'
351
+ }
352
+ }),
353
+ tip: '减少缩进',
354
+ disabled: getCurrentIndentLevel() <= 0
355
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
356
+ key: 'indent-increase',
357
+ onClick: function onClick() {
358
+ if (!canCurrentNodeIndent()) return;
359
+ selectCurrentNode();
360
+ current.editor.chain().focus().increaseIndent().run();
361
+ setCurrent(function (prev) {
362
+ return _objectSpread({}, prev);
363
+ });
364
+ },
365
+ icon: /*#__PURE__*/React.createElement(IndentIncreaseIcon, {
366
+ sx: {
367
+ fontSize: '1rem'
368
+ }
369
+ }),
370
+ tip: '增加缩进',
371
+ disabled: !canCurrentNodeIndent()
372
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
373
+ key: 'insert-divider',
374
+ onClick: function onClick() {
375
+ if (current.node && current.pos !== undefined) {
376
+ var afterPos = current.pos + current.node.nodeSize;
377
+ current.editor.chain().focus().insertContentAt(afterPos, {
378
+ type: 'horizontalRule'
379
+ }).run();
380
+ }
381
+ },
382
+ icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
383
+ sx: {
384
+ fontSize: '1rem'
385
+ }
386
+ }),
387
+ tip: '分割线'
388
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
389
+ key: 'copy',
390
+ onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
391
+ var content, textContent, htmlContent, blob, clipboardItem;
392
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
393
+ while (1) switch (_context.prev = _context.next) {
394
+ case 0:
395
+ if (!(current.node && current.pos !== undefined)) {
396
+ _context.next = 17;
397
+ break;
398
+ }
399
+ content = new Slice(Fragment.from(current.node), 0, 0);
400
+ textContent = current.node.textContent;
401
+ htmlContent = editor.view.serializeForClipboard(content).dom.innerHTML;
402
+ _context.prev = 4;
403
+ if (!(htmlContent && navigator.clipboard && "write" in navigator.clipboard)) {
404
+ _context.next = 11;
405
+ break;
406
+ }
407
+ blob = new Blob([htmlContent], {
408
+ type: "text/html"
409
+ });
410
+ clipboardItem = new ClipboardItem({
411
+ "text/html": blob
412
+ });
413
+ _context.next = 10;
414
+ return navigator.clipboard.write([clipboardItem]);
415
+ case 10:
416
+ onTip === null || onTip === void 0 || onTip('success', '复制成功');
417
+ case 11:
418
+ _context.next = 17;
419
+ break;
420
+ case 13:
421
+ _context.prev = 13;
422
+ _context.t0 = _context["catch"](4);
423
+ _context.next = 17;
424
+ return navigator.clipboard.writeText(textContent);
425
+ case 17:
426
+ case "end":
427
+ return _context.stop();
428
+ }
429
+ }, _callee, null, [[4, 13]]);
430
+ })),
431
+ icon: /*#__PURE__*/React.createElement(FileCopyLineIcon, {
432
+ sx: {
433
+ fontSize: '1rem'
434
+ }
435
+ }),
436
+ tip: "\u590D\u5236".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
437
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
438
+ key: 'cut',
439
+ onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
440
+ var content, textContent, htmlContent, blob, clipboardItem;
441
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
442
+ while (1) switch (_context2.prev = _context2.next) {
443
+ case 0:
444
+ if (!(current.node && current.pos !== undefined)) {
445
+ _context2.next = 23;
446
+ break;
447
+ }
448
+ _context2.prev = 1;
449
+ content = new Slice(Fragment.from(current.node), 0, 0);
450
+ textContent = current.node.textContent;
451
+ htmlContent = editor.view.serializeForClipboard(content).dom.innerHTML;
452
+ _context2.prev = 5;
453
+ if (!(htmlContent && navigator.clipboard && "write" in navigator.clipboard)) {
454
+ _context2.next = 11;
455
+ break;
456
+ }
457
+ blob = new Blob([htmlContent], {
458
+ type: "text/html"
459
+ });
460
+ clipboardItem = new ClipboardItem({
461
+ "text/html": blob
462
+ });
463
+ _context2.next = 11;
464
+ return navigator.clipboard.write([clipboardItem]);
465
+ case 11:
466
+ _context2.next = 17;
467
+ break;
468
+ case 13:
469
+ _context2.prev = 13;
470
+ _context2.t0 = _context2["catch"](5);
471
+ _context2.next = 17;
472
+ return navigator.clipboard.writeText(textContent);
473
+ case 17:
474
+ current.editor.chain().focus().deleteRange({
475
+ from: current.pos,
476
+ to: current.pos + current.node.nodeSize
477
+ }).run();
478
+ _context2.next = 23;
479
+ break;
480
+ case 20:
481
+ _context2.prev = 20;
482
+ _context2.t1 = _context2["catch"](1);
483
+ onTip === null || onTip === void 0 || onTip('error', '剪切失败');
484
+ case 23:
485
+ case "end":
486
+ return _context2.stop();
487
+ }
488
+ }, _callee2, null, [[1, 20], [5, 13]]);
489
+ })),
490
+ icon: /*#__PURE__*/React.createElement(ScissorsCutLineIcon, {
491
+ sx: {
492
+ fontSize: '1rem'
493
+ }
494
+ }),
495
+ tip: "\u526A\u5207".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
496
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
497
+ key: 'delete',
498
+ onClick: function onClick() {
499
+ if (current.node && current.pos !== undefined) {
500
+ current.editor.chain().focus().deleteRange({
501
+ from: current.pos,
502
+ to: current.pos + current.node.nodeSize
503
+ }).run();
504
+ }
505
+ },
506
+ icon: /*#__PURE__*/React.createElement(DeleteLineIcon, {
507
+ sx: {
508
+ fontSize: '1rem'
509
+ }
510
+ }),
511
+ tip: "\u5220\u9664".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
512
+ })), /*#__PURE__*/React.createElement(Stack, {
513
+ direction: 'row',
514
+ flexWrap: 'wrap',
515
+ sx: {
516
+ fontSize: 14
517
+ }
518
+ }, /*#__PURE__*/React.createElement(ToolbarItem, {
519
+ key: 'insert-line-break-top',
520
+ onClick: function onClick() {
521
+ if (current.node && current.pos !== undefined) {
522
+ var afterPos = current.pos;
523
+ current.editor.chain().focus().insertContentAt(afterPos, {
524
+ type: 'paragraph'
525
+ }, {
526
+ updateSelection: true
527
+ }).run();
528
+ }
529
+ },
530
+ icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
531
+ sx: {
532
+ fontSize: '1rem',
533
+ transform: 'rotate(180deg)'
534
+ }
535
+ }),
536
+ text: '上方插入行'
537
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
538
+ key: 'insert-line-break',
539
+ onClick: function onClick() {
540
+ if (current.node && current.pos !== undefined) {
541
+ var afterPos = current.pos + current.node.nodeSize;
542
+ current.editor.chain().focus().insertContentAt(afterPos, {
543
+ type: 'paragraph'
544
+ }).run();
545
+ }
546
+ },
547
+ icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
548
+ sx: {
549
+ fontSize: '1rem'
550
+ }
551
+ }),
552
+ text: '下方插入行'
553
+ })), /*#__PURE__*/React.createElement(Divider, {
554
+ sx: {
555
+ my: 0.5
556
+ }
557
+ })),
255
558
  list: [{
256
559
  customLabel: /*#__PURE__*/React.createElement(Typography, {
257
560
  sx: {
@@ -783,28 +1086,28 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
783
1086
  }
784
1087
  }),
785
1088
  onClick: function () {
786
- var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1089
+ var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
787
1090
  var _current$node17, node, nodeFile, nodeBlob, nodeUrl, nodeName, a;
788
- return _regeneratorRuntime().wrap(function _callee$(_context) {
789
- while (1) switch (_context.prev = _context.next) {
1091
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1092
+ while (1) switch (_context3.prev = _context3.next) {
790
1093
  case 0:
791
1094
  if (!(current.node && current.pos !== undefined)) {
792
- _context.next = 16;
1095
+ _context3.next = 16;
793
1096
  break;
794
1097
  }
795
1098
  if (![NodeTypeEnum.Video, NodeTypeEnum.Audio, NodeTypeEnum.BlockAttachment].includes((_current$node17 = current.node) === null || _current$node17 === void 0 ? void 0 : _current$node17.type.name)) {
796
- _context.next = 16;
1099
+ _context3.next = 16;
797
1100
  break;
798
1101
  }
799
1102
  node = current.node;
800
- _context.next = 5;
1103
+ _context3.next = 5;
801
1104
  return fetch(node.attrs.src || node.attrs.url);
802
1105
  case 5:
803
- nodeFile = _context.sent;
804
- _context.next = 8;
1106
+ nodeFile = _context3.sent;
1107
+ _context3.next = 8;
805
1108
  return nodeFile.blob();
806
1109
  case 8:
807
- nodeBlob = _context.sent;
1110
+ nodeBlob = _context3.sent;
808
1111
  nodeUrl = URL.createObjectURL(nodeBlob);
809
1112
  nodeName = node.attrs.title || "".concat(node.type.name, ".").concat(node.attrs.src.split('.').pop());
810
1113
  a = document.createElement('a');
@@ -814,9 +1117,9 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
814
1117
  URL.revokeObjectURL(nodeUrl);
815
1118
  case 16:
816
1119
  case "end":
817
- return _context.stop();
1120
+ return _context3.stop();
818
1121
  }
819
- }, _callee);
1122
+ }, _callee3);
820
1123
  }));
821
1124
  function onClick() {
822
1125
  return _onClick.apply(this, arguments);
@@ -849,32 +1152,32 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
849
1152
  }
850
1153
  }, resources.images.length),
851
1154
  onClick: function () {
852
- var _onClick2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1155
+ var _onClick2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
853
1156
  var imageInfos;
854
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
855
- while (1) switch (_context2.prev = _context2.next) {
1157
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1158
+ while (1) switch (_context4.prev = _context4.next) {
856
1159
  case 0:
857
- _context2.prev = 0;
1160
+ _context4.prev = 0;
858
1161
  imageInfos = resources.images.map(function (img) {
859
1162
  return {
860
1163
  src: img.attrs.src,
861
1164
  filename: img.attrs.alt || img.attrs.title || undefined
862
1165
  };
863
1166
  });
864
- _context2.next = 4;
1167
+ _context4.next = 4;
865
1168
  return downloadFiles(imageInfos, 'img');
866
1169
  case 4:
867
- _context2.next = 9;
1170
+ _context4.next = 9;
868
1171
  break;
869
1172
  case 6:
870
- _context2.prev = 6;
871
- _context2.t0 = _context2["catch"](0);
872
- console.error('下载图片失败:', _context2.t0);
1173
+ _context4.prev = 6;
1174
+ _context4.t0 = _context4["catch"](0);
1175
+ console.error('下载图片失败:', _context4.t0);
873
1176
  case 9:
874
1177
  case "end":
875
- return _context2.stop();
1178
+ return _context4.stop();
876
1179
  }
877
- }, _callee2, null, [[0, 6]]);
1180
+ }, _callee4, null, [[0, 6]]);
878
1181
  }));
879
1182
  function onClick() {
880
1183
  return _onClick2.apply(this, arguments);
@@ -907,32 +1210,32 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
907
1210
  }
908
1211
  }, resources.videos.length),
909
1212
  onClick: function () {
910
- var _onClick3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1213
+ var _onClick3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
911
1214
  var videoInfos;
912
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
913
- while (1) switch (_context3.prev = _context3.next) {
1215
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1216
+ while (1) switch (_context5.prev = _context5.next) {
914
1217
  case 0:
915
- _context3.prev = 0;
1218
+ _context5.prev = 0;
916
1219
  videoInfos = resources.videos.map(function (video) {
917
1220
  return {
918
1221
  src: video.attrs.src,
919
1222
  filename: video.attrs.alt || video.attrs.title || undefined
920
1223
  };
921
1224
  });
922
- _context3.next = 4;
1225
+ _context5.next = 4;
923
1226
  return downloadFiles(videoInfos, 'video');
924
1227
  case 4:
925
- _context3.next = 9;
1228
+ _context5.next = 9;
926
1229
  break;
927
1230
  case 6:
928
- _context3.prev = 6;
929
- _context3.t0 = _context3["catch"](0);
930
- console.error('下载视频失败:', _context3.t0);
1231
+ _context5.prev = 6;
1232
+ _context5.t0 = _context5["catch"](0);
1233
+ console.error('下载视频失败:', _context5.t0);
931
1234
  case 9:
932
1235
  case "end":
933
- return _context3.stop();
1236
+ return _context5.stop();
934
1237
  }
935
- }, _callee3, null, [[0, 6]]);
1238
+ }, _callee5, null, [[0, 6]]);
936
1239
  }));
937
1240
  function onClick() {
938
1241
  return _onClick3.apply(this, arguments);
@@ -965,32 +1268,32 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
965
1268
  }
966
1269
  }, resources.audios.length),
967
1270
  onClick: function () {
968
- var _onClick4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
1271
+ var _onClick4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
969
1272
  var audioInfos;
970
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
971
- while (1) switch (_context4.prev = _context4.next) {
1273
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1274
+ while (1) switch (_context6.prev = _context6.next) {
972
1275
  case 0:
973
- _context4.prev = 0;
1276
+ _context6.prev = 0;
974
1277
  audioInfos = resources.audios.map(function (audio) {
975
1278
  return {
976
1279
  src: audio.attrs.src,
977
1280
  filename: audio.attrs.alt || audio.attrs.title || undefined
978
1281
  };
979
1282
  });
980
- _context4.next = 4;
1283
+ _context6.next = 4;
981
1284
  return downloadFiles(audioInfos, 'audio');
982
1285
  case 4:
983
- _context4.next = 9;
1286
+ _context6.next = 9;
984
1287
  break;
985
1288
  case 6:
986
- _context4.prev = 6;
987
- _context4.t0 = _context4["catch"](0);
988
- console.error('下载音频失败:', _context4.t0);
1289
+ _context6.prev = 6;
1290
+ _context6.t0 = _context6["catch"](0);
1291
+ console.error('下载音频失败:', _context6.t0);
989
1292
  case 9:
990
1293
  case "end":
991
- return _context4.stop();
1294
+ return _context6.stop();
992
1295
  }
993
- }, _callee4, null, [[0, 6]]);
1296
+ }, _callee6, null, [[0, 6]]);
994
1297
  }));
995
1298
  function onClick() {
996
1299
  return _onClick4.apply(this, arguments);
@@ -1023,32 +1326,32 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
1023
1326
  }
1024
1327
  }, resources.attachments.length),
1025
1328
  onClick: function () {
1026
- var _onClick5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
1329
+ var _onClick5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1027
1330
  var attachmentInfos;
1028
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1029
- while (1) switch (_context5.prev = _context5.next) {
1331
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1332
+ while (1) switch (_context7.prev = _context7.next) {
1030
1333
  case 0:
1031
- _context5.prev = 0;
1334
+ _context7.prev = 0;
1032
1335
  attachmentInfos = resources.attachments.map(function (attachment) {
1033
1336
  return {
1034
1337
  src: attachment.attrs.url,
1035
1338
  filename: attachment.attrs.title || undefined
1036
1339
  };
1037
1340
  });
1038
- _context5.next = 4;
1341
+ _context7.next = 4;
1039
1342
  return downloadFiles(attachmentInfos, 'attachment');
1040
1343
  case 4:
1041
- _context5.next = 9;
1344
+ _context7.next = 9;
1042
1345
  break;
1043
1346
  case 6:
1044
- _context5.prev = 6;
1045
- _context5.t0 = _context5["catch"](0);
1046
- console.error('下载附件失败:', _context5.t0);
1347
+ _context7.prev = 6;
1348
+ _context7.t0 = _context7["catch"](0);
1349
+ console.error('下载附件失败:', _context7.t0);
1047
1350
  case 9:
1048
1351
  case "end":
1049
- return _context5.stop();
1352
+ return _context7.stop();
1050
1353
  }
1051
- }, _callee5, null, [[0, 6]]);
1354
+ }, _callee7, null, [[0, 6]]);
1052
1355
  }));
1053
1356
  function onClick() {
1054
1357
  return _onClick5.apply(this, arguments);
@@ -1064,10 +1367,10 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
1064
1367
  }
1065
1368
  }),
1066
1369
  onClick: function () {
1067
- var _onClick6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
1370
+ var _onClick6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1068
1371
  var tr, _currentNode, empty, content;
1069
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1070
- while (1) switch (_context6.prev = _context6.next) {
1372
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1373
+ while (1) switch (_context8.prev = _context8.next) {
1071
1374
  case 0:
1072
1375
  if (current.node && current.pos !== undefined) {
1073
1376
  tr = current.editor.state.tr;
@@ -1089,203 +1392,16 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
1089
1392
  }
1090
1393
  case 1:
1091
1394
  case "end":
1092
- return _context6.stop();
1395
+ return _context8.stop();
1093
1396
  }
1094
- }, _callee6);
1397
+ }, _callee8);
1095
1398
  }));
1096
1399
  function onClick() {
1097
1400
  return _onClick6.apply(this, arguments);
1098
1401
  }
1099
1402
  return onClick;
1100
1403
  }()
1101
- }] : [])),
1102
- header: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Stack, {
1103
- direction: 'row',
1104
- flexWrap: 'wrap',
1105
- sx: {
1106
- fontSize: 14
1107
- }
1108
- }, /*#__PURE__*/React.createElement(ToolbarItem, {
1109
- key: 'insert-line-break-top',
1110
- onClick: function onClick() {
1111
- if (current.node && current.pos !== undefined) {
1112
- var afterPos = current.pos;
1113
- current.editor.chain().focus().insertContentAt(afterPos, {
1114
- type: 'paragraph'
1115
- }, {
1116
- updateSelection: true
1117
- }).run();
1118
- }
1119
- },
1120
- icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
1121
- sx: {
1122
- fontSize: '1rem',
1123
- transform: 'rotate(180deg)'
1124
- }
1125
- }),
1126
- tip: '上方插入行'
1127
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
1128
- key: 'insert-line-break',
1129
- onClick: function onClick() {
1130
- if (current.node && current.pos !== undefined) {
1131
- var afterPos = current.pos + current.node.nodeSize;
1132
- current.editor.chain().focus().insertContentAt(afterPos, {
1133
- type: 'paragraph'
1134
- }).run();
1135
- }
1136
- },
1137
- icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
1138
- sx: {
1139
- fontSize: '1rem'
1140
- }
1141
- }),
1142
- tip: '下方插入行'
1143
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
1144
- key: 'insert-divider',
1145
- onClick: function onClick() {
1146
- if (current.node && current.pos !== undefined) {
1147
- var afterPos = current.pos + current.node.nodeSize;
1148
- current.editor.chain().focus().insertContentAt(afterPos, {
1149
- type: 'horizontalRule'
1150
- }).run();
1151
- }
1152
- },
1153
- icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
1154
- sx: {
1155
- fontSize: '1rem'
1156
- }
1157
- }),
1158
- tip: '分割线'
1159
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
1160
- key: 'copy',
1161
- onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1162
- var content, textContent, htmlContent, blob, clipboardItem;
1163
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1164
- while (1) switch (_context7.prev = _context7.next) {
1165
- case 0:
1166
- if (!(current.node && current.pos !== undefined)) {
1167
- _context7.next = 17;
1168
- break;
1169
- }
1170
- content = new Slice(Fragment.from(current.node), 0, 0);
1171
- textContent = current.node.textContent;
1172
- htmlContent = editor.view.serializeForClipboard(content).dom.innerHTML;
1173
- _context7.prev = 4;
1174
- if (!(htmlContent && navigator.clipboard && "write" in navigator.clipboard)) {
1175
- _context7.next = 11;
1176
- break;
1177
- }
1178
- blob = new Blob([htmlContent], {
1179
- type: "text/html"
1180
- });
1181
- clipboardItem = new ClipboardItem({
1182
- "text/html": blob
1183
- });
1184
- _context7.next = 10;
1185
- return navigator.clipboard.write([clipboardItem]);
1186
- case 10:
1187
- onTip === null || onTip === void 0 || onTip('success', '复制成功');
1188
- case 11:
1189
- _context7.next = 17;
1190
- break;
1191
- case 13:
1192
- _context7.prev = 13;
1193
- _context7.t0 = _context7["catch"](4);
1194
- _context7.next = 17;
1195
- return navigator.clipboard.writeText(textContent);
1196
- case 17:
1197
- case "end":
1198
- return _context7.stop();
1199
- }
1200
- }, _callee7, null, [[4, 13]]);
1201
- })),
1202
- icon: /*#__PURE__*/React.createElement(FileCopyLineIcon, {
1203
- sx: {
1204
- fontSize: '1rem'
1205
- }
1206
- }),
1207
- tip: "\u590D\u5236".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
1208
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
1209
- key: 'cut',
1210
- onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1211
- var content, textContent, htmlContent, blob, clipboardItem;
1212
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1213
- while (1) switch (_context8.prev = _context8.next) {
1214
- case 0:
1215
- if (!(current.node && current.pos !== undefined)) {
1216
- _context8.next = 23;
1217
- break;
1218
- }
1219
- _context8.prev = 1;
1220
- content = new Slice(Fragment.from(current.node), 0, 0);
1221
- textContent = current.node.textContent;
1222
- htmlContent = editor.view.serializeForClipboard(content).dom.innerHTML;
1223
- _context8.prev = 5;
1224
- if (!(htmlContent && navigator.clipboard && "write" in navigator.clipboard)) {
1225
- _context8.next = 11;
1226
- break;
1227
- }
1228
- blob = new Blob([htmlContent], {
1229
- type: "text/html"
1230
- });
1231
- clipboardItem = new ClipboardItem({
1232
- "text/html": blob
1233
- });
1234
- _context8.next = 11;
1235
- return navigator.clipboard.write([clipboardItem]);
1236
- case 11:
1237
- _context8.next = 17;
1238
- break;
1239
- case 13:
1240
- _context8.prev = 13;
1241
- _context8.t0 = _context8["catch"](5);
1242
- _context8.next = 17;
1243
- return navigator.clipboard.writeText(textContent);
1244
- case 17:
1245
- current.editor.chain().focus().deleteRange({
1246
- from: current.pos,
1247
- to: current.pos + current.node.nodeSize
1248
- }).run();
1249
- _context8.next = 23;
1250
- break;
1251
- case 20:
1252
- _context8.prev = 20;
1253
- _context8.t1 = _context8["catch"](1);
1254
- onTip === null || onTip === void 0 || onTip('error', '剪切失败');
1255
- case 23:
1256
- case "end":
1257
- return _context8.stop();
1258
- }
1259
- }, _callee8, null, [[1, 20], [5, 13]]);
1260
- })),
1261
- icon: /*#__PURE__*/React.createElement(ScissorsCutLineIcon, {
1262
- sx: {
1263
- fontSize: '1rem'
1264
- }
1265
- }),
1266
- tip: "\u526A\u5207".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
1267
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
1268
- key: 'delete',
1269
- onClick: function onClick() {
1270
- if (current.node && current.pos !== undefined) {
1271
- current.editor.chain().focus().deleteRange({
1272
- from: current.pos,
1273
- to: current.pos + current.node.nodeSize
1274
- }).run();
1275
- }
1276
- },
1277
- icon: /*#__PURE__*/React.createElement(DeleteLineIcon, {
1278
- sx: {
1279
- fontSize: '1rem'
1280
- }
1281
- }),
1282
- tip: "\u5220\u9664".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
1283
- })), /*#__PURE__*/React.createElement(Divider, {
1284
- sx: {
1285
- my: 0.5
1286
- }
1287
- })),
1288
- context: /*#__PURE__*/React.createElement(DragIcon, null)
1289
- }) : /*#__PURE__*/React.createElement(DragIcon, null));
1404
+ }] : []))
1405
+ }) : /*#__PURE__*/React.createElement(DragIcon, null)));
1290
1406
  };
1291
1407
  export default CustomDragHandle;