@ctzhian/tiptap 1.4.2 → 1.5.0
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.
- package/dist/component/CustomDragHandle/index.js +308 -254
- package/dist/component/Icons/indent-decrease-icon.d.ts +6 -0
- package/dist/component/Icons/indent-decrease-icon.js +13 -0
- package/dist/component/Icons/indent-increase-icon.d.ts +6 -0
- package/dist/component/Icons/indent-increase-icon.js +13 -0
- package/dist/component/Icons/index.d.ts +2 -0
- package/dist/component/Icons/index.js +2 -0
- package/dist/extension/component/Alert/index.js +2 -0
- package/dist/extension/index.js +12 -2
- package/dist/extension/node/Indent.d.ts +17 -0
- package/dist/extension/node/Indent.js +103 -0
- package/dist/extension/node/Table.d.ts +1 -1
- package/dist/extension/node/index.d.ts +1 -0
- package/dist/extension/node/index.js +1 -0
- package/dist/index.css +33 -0
- package/package.json +1 -1
|
@@ -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 { 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';
|
|
@@ -196,6 +201,15 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
196
201
|
return hasMarksDeep(child);
|
|
197
202
|
});
|
|
198
203
|
};
|
|
204
|
+
var canCurrentNodeIndent = function canCurrentNodeIndent() {
|
|
205
|
+
return !!(current.node && current.node.type);
|
|
206
|
+
};
|
|
207
|
+
var getCurrentIndentLevel = function getCurrentIndentLevel() {
|
|
208
|
+
if (!canCurrentNodeIndent()) return 0;
|
|
209
|
+
var node = current.node;
|
|
210
|
+
var attrs = current.editor.getAttributes(node.type.name);
|
|
211
|
+
return Number(attrs.indent) || 0;
|
|
212
|
+
};
|
|
199
213
|
var shouldShowButton = function shouldShowButton(_ref3) {
|
|
200
214
|
var editor = _ref3.editor,
|
|
201
215
|
data = _ref3.data;
|
|
@@ -238,9 +252,10 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
238
252
|
editor: editor,
|
|
239
253
|
onNodeChange: updateNodeChange
|
|
240
254
|
}, currentNode ? /*#__PURE__*/React.createElement(Menu, {
|
|
255
|
+
context: /*#__PURE__*/React.createElement(DragIcon, null),
|
|
241
256
|
anchorOrigin: {
|
|
242
|
-
vertical: '
|
|
243
|
-
horizontal: '
|
|
257
|
+
vertical: 'bottom',
|
|
258
|
+
horizontal: 'left'
|
|
244
259
|
},
|
|
245
260
|
transformOrigin: {
|
|
246
261
|
vertical: 'top',
|
|
@@ -252,6 +267,232 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
252
267
|
transform: 'rotate(-90deg)'
|
|
253
268
|
}
|
|
254
269
|
}),
|
|
270
|
+
header: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Stack, {
|
|
271
|
+
direction: 'row',
|
|
272
|
+
flexWrap: 'wrap',
|
|
273
|
+
sx: {
|
|
274
|
+
fontSize: 14
|
|
275
|
+
}
|
|
276
|
+
}, /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
277
|
+
key: 'indent-decrease',
|
|
278
|
+
onClick: function onClick() {
|
|
279
|
+
if (!canCurrentNodeIndent()) return;
|
|
280
|
+
selectCurrentNode();
|
|
281
|
+
current.editor.chain().focus().decreaseIndent().run();
|
|
282
|
+
setCurrent(function (prev) {
|
|
283
|
+
return _objectSpread({}, prev);
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
icon: /*#__PURE__*/React.createElement(IndentDecreaseIcon, {
|
|
287
|
+
sx: {
|
|
288
|
+
fontSize: '1rem'
|
|
289
|
+
}
|
|
290
|
+
}),
|
|
291
|
+
tip: '减少缩进',
|
|
292
|
+
disabled: getCurrentIndentLevel() <= 0
|
|
293
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
294
|
+
key: 'indent-increase',
|
|
295
|
+
onClick: function onClick() {
|
|
296
|
+
if (!canCurrentNodeIndent()) return;
|
|
297
|
+
selectCurrentNode();
|
|
298
|
+
current.editor.chain().focus().increaseIndent().run();
|
|
299
|
+
setCurrent(function (prev) {
|
|
300
|
+
return _objectSpread({}, prev);
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
icon: /*#__PURE__*/React.createElement(IndentIncreaseIcon, {
|
|
304
|
+
sx: {
|
|
305
|
+
fontSize: '1rem'
|
|
306
|
+
}
|
|
307
|
+
}),
|
|
308
|
+
tip: '增加缩进',
|
|
309
|
+
disabled: !canCurrentNodeIndent()
|
|
310
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
311
|
+
key: 'insert-divider',
|
|
312
|
+
onClick: function onClick() {
|
|
313
|
+
if (current.node && current.pos !== undefined) {
|
|
314
|
+
var afterPos = current.pos + current.node.nodeSize;
|
|
315
|
+
current.editor.chain().focus().insertContentAt(afterPos, {
|
|
316
|
+
type: 'horizontalRule'
|
|
317
|
+
}).run();
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
|
|
321
|
+
sx: {
|
|
322
|
+
fontSize: '1rem'
|
|
323
|
+
}
|
|
324
|
+
}),
|
|
325
|
+
tip: '分割线'
|
|
326
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
327
|
+
key: 'copy',
|
|
328
|
+
onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
329
|
+
var content, textContent, htmlContent, blob, clipboardItem;
|
|
330
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
331
|
+
while (1) switch (_context.prev = _context.next) {
|
|
332
|
+
case 0:
|
|
333
|
+
if (!(current.node && current.pos !== undefined)) {
|
|
334
|
+
_context.next = 17;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
content = new Slice(Fragment.from(current.node), 0, 0);
|
|
338
|
+
textContent = current.node.textContent;
|
|
339
|
+
htmlContent = editor.view.serializeForClipboard(content).dom.innerHTML;
|
|
340
|
+
_context.prev = 4;
|
|
341
|
+
if (!(htmlContent && navigator.clipboard && "write" in navigator.clipboard)) {
|
|
342
|
+
_context.next = 11;
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
blob = new Blob([htmlContent], {
|
|
346
|
+
type: "text/html"
|
|
347
|
+
});
|
|
348
|
+
clipboardItem = new ClipboardItem({
|
|
349
|
+
"text/html": blob
|
|
350
|
+
});
|
|
351
|
+
_context.next = 10;
|
|
352
|
+
return navigator.clipboard.write([clipboardItem]);
|
|
353
|
+
case 10:
|
|
354
|
+
onTip === null || onTip === void 0 || onTip('success', '复制成功');
|
|
355
|
+
case 11:
|
|
356
|
+
_context.next = 17;
|
|
357
|
+
break;
|
|
358
|
+
case 13:
|
|
359
|
+
_context.prev = 13;
|
|
360
|
+
_context.t0 = _context["catch"](4);
|
|
361
|
+
_context.next = 17;
|
|
362
|
+
return navigator.clipboard.writeText(textContent);
|
|
363
|
+
case 17:
|
|
364
|
+
case "end":
|
|
365
|
+
return _context.stop();
|
|
366
|
+
}
|
|
367
|
+
}, _callee, null, [[4, 13]]);
|
|
368
|
+
})),
|
|
369
|
+
icon: /*#__PURE__*/React.createElement(FileCopyLineIcon, {
|
|
370
|
+
sx: {
|
|
371
|
+
fontSize: '1rem'
|
|
372
|
+
}
|
|
373
|
+
}),
|
|
374
|
+
tip: "\u590D\u5236".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
|
|
375
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
376
|
+
key: 'cut',
|
|
377
|
+
onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
378
|
+
var content, textContent, htmlContent, blob, clipboardItem;
|
|
379
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
380
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
381
|
+
case 0:
|
|
382
|
+
if (!(current.node && current.pos !== undefined)) {
|
|
383
|
+
_context2.next = 23;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
_context2.prev = 1;
|
|
387
|
+
content = new Slice(Fragment.from(current.node), 0, 0);
|
|
388
|
+
textContent = current.node.textContent;
|
|
389
|
+
htmlContent = editor.view.serializeForClipboard(content).dom.innerHTML;
|
|
390
|
+
_context2.prev = 5;
|
|
391
|
+
if (!(htmlContent && navigator.clipboard && "write" in navigator.clipboard)) {
|
|
392
|
+
_context2.next = 11;
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
blob = new Blob([htmlContent], {
|
|
396
|
+
type: "text/html"
|
|
397
|
+
});
|
|
398
|
+
clipboardItem = new ClipboardItem({
|
|
399
|
+
"text/html": blob
|
|
400
|
+
});
|
|
401
|
+
_context2.next = 11;
|
|
402
|
+
return navigator.clipboard.write([clipboardItem]);
|
|
403
|
+
case 11:
|
|
404
|
+
_context2.next = 17;
|
|
405
|
+
break;
|
|
406
|
+
case 13:
|
|
407
|
+
_context2.prev = 13;
|
|
408
|
+
_context2.t0 = _context2["catch"](5);
|
|
409
|
+
_context2.next = 17;
|
|
410
|
+
return navigator.clipboard.writeText(textContent);
|
|
411
|
+
case 17:
|
|
412
|
+
current.editor.chain().focus().deleteRange({
|
|
413
|
+
from: current.pos,
|
|
414
|
+
to: current.pos + current.node.nodeSize
|
|
415
|
+
}).run();
|
|
416
|
+
_context2.next = 23;
|
|
417
|
+
break;
|
|
418
|
+
case 20:
|
|
419
|
+
_context2.prev = 20;
|
|
420
|
+
_context2.t1 = _context2["catch"](1);
|
|
421
|
+
onTip === null || onTip === void 0 || onTip('error', '剪切失败');
|
|
422
|
+
case 23:
|
|
423
|
+
case "end":
|
|
424
|
+
return _context2.stop();
|
|
425
|
+
}
|
|
426
|
+
}, _callee2, null, [[1, 20], [5, 13]]);
|
|
427
|
+
})),
|
|
428
|
+
icon: /*#__PURE__*/React.createElement(ScissorsCutLineIcon, {
|
|
429
|
+
sx: {
|
|
430
|
+
fontSize: '1rem'
|
|
431
|
+
}
|
|
432
|
+
}),
|
|
433
|
+
tip: "\u526A\u5207".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
|
|
434
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
435
|
+
key: 'delete',
|
|
436
|
+
onClick: function onClick() {
|
|
437
|
+
if (current.node && current.pos !== undefined) {
|
|
438
|
+
current.editor.chain().focus().deleteRange({
|
|
439
|
+
from: current.pos,
|
|
440
|
+
to: current.pos + current.node.nodeSize
|
|
441
|
+
}).run();
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
icon: /*#__PURE__*/React.createElement(DeleteLineIcon, {
|
|
445
|
+
sx: {
|
|
446
|
+
fontSize: '1rem'
|
|
447
|
+
}
|
|
448
|
+
}),
|
|
449
|
+
tip: "\u5220\u9664".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
|
|
450
|
+
})), /*#__PURE__*/React.createElement(Stack, {
|
|
451
|
+
direction: 'row',
|
|
452
|
+
flexWrap: 'wrap',
|
|
453
|
+
sx: {
|
|
454
|
+
fontSize: 14
|
|
455
|
+
}
|
|
456
|
+
}, /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
457
|
+
key: 'insert-line-break-top',
|
|
458
|
+
onClick: function onClick() {
|
|
459
|
+
if (current.node && current.pos !== undefined) {
|
|
460
|
+
var afterPos = current.pos;
|
|
461
|
+
current.editor.chain().focus().insertContentAt(afterPos, {
|
|
462
|
+
type: 'paragraph'
|
|
463
|
+
}, {
|
|
464
|
+
updateSelection: true
|
|
465
|
+
}).run();
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
|
|
469
|
+
sx: {
|
|
470
|
+
fontSize: '1rem',
|
|
471
|
+
transform: 'rotate(180deg)'
|
|
472
|
+
}
|
|
473
|
+
}),
|
|
474
|
+
text: '上方插入行'
|
|
475
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
476
|
+
key: 'insert-line-break',
|
|
477
|
+
onClick: function onClick() {
|
|
478
|
+
if (current.node && current.pos !== undefined) {
|
|
479
|
+
var afterPos = current.pos + current.node.nodeSize;
|
|
480
|
+
current.editor.chain().focus().insertContentAt(afterPos, {
|
|
481
|
+
type: 'paragraph'
|
|
482
|
+
}).run();
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
|
|
486
|
+
sx: {
|
|
487
|
+
fontSize: '1rem'
|
|
488
|
+
}
|
|
489
|
+
}),
|
|
490
|
+
text: '下方插入行'
|
|
491
|
+
})), /*#__PURE__*/React.createElement(Divider, {
|
|
492
|
+
sx: {
|
|
493
|
+
my: 0.5
|
|
494
|
+
}
|
|
495
|
+
})),
|
|
255
496
|
list: [{
|
|
256
497
|
customLabel: /*#__PURE__*/React.createElement(Typography, {
|
|
257
498
|
sx: {
|
|
@@ -783,28 +1024,28 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
783
1024
|
}
|
|
784
1025
|
}),
|
|
785
1026
|
onClick: function () {
|
|
786
|
-
var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1027
|
+
var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
787
1028
|
var _current$node17, node, nodeFile, nodeBlob, nodeUrl, nodeName, a;
|
|
788
|
-
return _regeneratorRuntime().wrap(function
|
|
789
|
-
while (1) switch (
|
|
1029
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1030
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
790
1031
|
case 0:
|
|
791
1032
|
if (!(current.node && current.pos !== undefined)) {
|
|
792
|
-
|
|
1033
|
+
_context3.next = 16;
|
|
793
1034
|
break;
|
|
794
1035
|
}
|
|
795
1036
|
if (![NodeTypeEnum.Video, NodeTypeEnum.Audio, NodeTypeEnum.BlockAttachment].includes((_current$node17 = current.node) === null || _current$node17 === void 0 ? void 0 : _current$node17.type.name)) {
|
|
796
|
-
|
|
1037
|
+
_context3.next = 16;
|
|
797
1038
|
break;
|
|
798
1039
|
}
|
|
799
1040
|
node = current.node;
|
|
800
|
-
|
|
1041
|
+
_context3.next = 5;
|
|
801
1042
|
return fetch(node.attrs.src || node.attrs.url);
|
|
802
1043
|
case 5:
|
|
803
|
-
nodeFile =
|
|
804
|
-
|
|
1044
|
+
nodeFile = _context3.sent;
|
|
1045
|
+
_context3.next = 8;
|
|
805
1046
|
return nodeFile.blob();
|
|
806
1047
|
case 8:
|
|
807
|
-
nodeBlob =
|
|
1048
|
+
nodeBlob = _context3.sent;
|
|
808
1049
|
nodeUrl = URL.createObjectURL(nodeBlob);
|
|
809
1050
|
nodeName = node.attrs.title || "".concat(node.type.name, ".").concat(node.attrs.src.split('.').pop());
|
|
810
1051
|
a = document.createElement('a');
|
|
@@ -814,9 +1055,9 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
814
1055
|
URL.revokeObjectURL(nodeUrl);
|
|
815
1056
|
case 16:
|
|
816
1057
|
case "end":
|
|
817
|
-
return
|
|
1058
|
+
return _context3.stop();
|
|
818
1059
|
}
|
|
819
|
-
},
|
|
1060
|
+
}, _callee3);
|
|
820
1061
|
}));
|
|
821
1062
|
function onClick() {
|
|
822
1063
|
return _onClick.apply(this, arguments);
|
|
@@ -849,32 +1090,32 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
849
1090
|
}
|
|
850
1091
|
}, resources.images.length),
|
|
851
1092
|
onClick: function () {
|
|
852
|
-
var _onClick2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1093
|
+
var _onClick2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
853
1094
|
var imageInfos;
|
|
854
|
-
return _regeneratorRuntime().wrap(function
|
|
855
|
-
while (1) switch (
|
|
1095
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1096
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
856
1097
|
case 0:
|
|
857
|
-
|
|
1098
|
+
_context4.prev = 0;
|
|
858
1099
|
imageInfos = resources.images.map(function (img) {
|
|
859
1100
|
return {
|
|
860
1101
|
src: img.attrs.src,
|
|
861
1102
|
filename: img.attrs.alt || img.attrs.title || undefined
|
|
862
1103
|
};
|
|
863
1104
|
});
|
|
864
|
-
|
|
1105
|
+
_context4.next = 4;
|
|
865
1106
|
return downloadFiles(imageInfos, 'img');
|
|
866
1107
|
case 4:
|
|
867
|
-
|
|
1108
|
+
_context4.next = 9;
|
|
868
1109
|
break;
|
|
869
1110
|
case 6:
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
console.error('下载图片失败:',
|
|
1111
|
+
_context4.prev = 6;
|
|
1112
|
+
_context4.t0 = _context4["catch"](0);
|
|
1113
|
+
console.error('下载图片失败:', _context4.t0);
|
|
873
1114
|
case 9:
|
|
874
1115
|
case "end":
|
|
875
|
-
return
|
|
1116
|
+
return _context4.stop();
|
|
876
1117
|
}
|
|
877
|
-
},
|
|
1118
|
+
}, _callee4, null, [[0, 6]]);
|
|
878
1119
|
}));
|
|
879
1120
|
function onClick() {
|
|
880
1121
|
return _onClick2.apply(this, arguments);
|
|
@@ -907,32 +1148,32 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
907
1148
|
}
|
|
908
1149
|
}, resources.videos.length),
|
|
909
1150
|
onClick: function () {
|
|
910
|
-
var _onClick3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1151
|
+
var _onClick3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
911
1152
|
var videoInfos;
|
|
912
|
-
return _regeneratorRuntime().wrap(function
|
|
913
|
-
while (1) switch (
|
|
1153
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1154
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
914
1155
|
case 0:
|
|
915
|
-
|
|
1156
|
+
_context5.prev = 0;
|
|
916
1157
|
videoInfos = resources.videos.map(function (video) {
|
|
917
1158
|
return {
|
|
918
1159
|
src: video.attrs.src,
|
|
919
1160
|
filename: video.attrs.alt || video.attrs.title || undefined
|
|
920
1161
|
};
|
|
921
1162
|
});
|
|
922
|
-
|
|
1163
|
+
_context5.next = 4;
|
|
923
1164
|
return downloadFiles(videoInfos, 'video');
|
|
924
1165
|
case 4:
|
|
925
|
-
|
|
1166
|
+
_context5.next = 9;
|
|
926
1167
|
break;
|
|
927
1168
|
case 6:
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
console.error('下载视频失败:',
|
|
1169
|
+
_context5.prev = 6;
|
|
1170
|
+
_context5.t0 = _context5["catch"](0);
|
|
1171
|
+
console.error('下载视频失败:', _context5.t0);
|
|
931
1172
|
case 9:
|
|
932
1173
|
case "end":
|
|
933
|
-
return
|
|
1174
|
+
return _context5.stop();
|
|
934
1175
|
}
|
|
935
|
-
},
|
|
1176
|
+
}, _callee5, null, [[0, 6]]);
|
|
936
1177
|
}));
|
|
937
1178
|
function onClick() {
|
|
938
1179
|
return _onClick3.apply(this, arguments);
|
|
@@ -965,32 +1206,32 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
965
1206
|
}
|
|
966
1207
|
}, resources.audios.length),
|
|
967
1208
|
onClick: function () {
|
|
968
|
-
var _onClick4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1209
|
+
var _onClick4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
969
1210
|
var audioInfos;
|
|
970
|
-
return _regeneratorRuntime().wrap(function
|
|
971
|
-
while (1) switch (
|
|
1211
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1212
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
972
1213
|
case 0:
|
|
973
|
-
|
|
1214
|
+
_context6.prev = 0;
|
|
974
1215
|
audioInfos = resources.audios.map(function (audio) {
|
|
975
1216
|
return {
|
|
976
1217
|
src: audio.attrs.src,
|
|
977
1218
|
filename: audio.attrs.alt || audio.attrs.title || undefined
|
|
978
1219
|
};
|
|
979
1220
|
});
|
|
980
|
-
|
|
1221
|
+
_context6.next = 4;
|
|
981
1222
|
return downloadFiles(audioInfos, 'audio');
|
|
982
1223
|
case 4:
|
|
983
|
-
|
|
1224
|
+
_context6.next = 9;
|
|
984
1225
|
break;
|
|
985
1226
|
case 6:
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
console.error('下载音频失败:',
|
|
1227
|
+
_context6.prev = 6;
|
|
1228
|
+
_context6.t0 = _context6["catch"](0);
|
|
1229
|
+
console.error('下载音频失败:', _context6.t0);
|
|
989
1230
|
case 9:
|
|
990
1231
|
case "end":
|
|
991
|
-
return
|
|
1232
|
+
return _context6.stop();
|
|
992
1233
|
}
|
|
993
|
-
},
|
|
1234
|
+
}, _callee6, null, [[0, 6]]);
|
|
994
1235
|
}));
|
|
995
1236
|
function onClick() {
|
|
996
1237
|
return _onClick4.apply(this, arguments);
|
|
@@ -1023,32 +1264,32 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
1023
1264
|
}
|
|
1024
1265
|
}, resources.attachments.length),
|
|
1025
1266
|
onClick: function () {
|
|
1026
|
-
var _onClick5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1267
|
+
var _onClick5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1027
1268
|
var attachmentInfos;
|
|
1028
|
-
return _regeneratorRuntime().wrap(function
|
|
1029
|
-
while (1) switch (
|
|
1269
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1270
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1030
1271
|
case 0:
|
|
1031
|
-
|
|
1272
|
+
_context7.prev = 0;
|
|
1032
1273
|
attachmentInfos = resources.attachments.map(function (attachment) {
|
|
1033
1274
|
return {
|
|
1034
1275
|
src: attachment.attrs.url,
|
|
1035
1276
|
filename: attachment.attrs.title || undefined
|
|
1036
1277
|
};
|
|
1037
1278
|
});
|
|
1038
|
-
|
|
1279
|
+
_context7.next = 4;
|
|
1039
1280
|
return downloadFiles(attachmentInfos, 'attachment');
|
|
1040
1281
|
case 4:
|
|
1041
|
-
|
|
1282
|
+
_context7.next = 9;
|
|
1042
1283
|
break;
|
|
1043
1284
|
case 6:
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
console.error('下载附件失败:',
|
|
1285
|
+
_context7.prev = 6;
|
|
1286
|
+
_context7.t0 = _context7["catch"](0);
|
|
1287
|
+
console.error('下载附件失败:', _context7.t0);
|
|
1047
1288
|
case 9:
|
|
1048
1289
|
case "end":
|
|
1049
|
-
return
|
|
1290
|
+
return _context7.stop();
|
|
1050
1291
|
}
|
|
1051
|
-
},
|
|
1292
|
+
}, _callee7, null, [[0, 6]]);
|
|
1052
1293
|
}));
|
|
1053
1294
|
function onClick() {
|
|
1054
1295
|
return _onClick5.apply(this, arguments);
|
|
@@ -1064,10 +1305,10 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
1064
1305
|
}
|
|
1065
1306
|
}),
|
|
1066
1307
|
onClick: function () {
|
|
1067
|
-
var _onClick6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1308
|
+
var _onClick6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1068
1309
|
var tr, _currentNode, empty, content;
|
|
1069
|
-
return _regeneratorRuntime().wrap(function
|
|
1070
|
-
while (1) switch (
|
|
1310
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1311
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1071
1312
|
case 0:
|
|
1072
1313
|
if (current.node && current.pos !== undefined) {
|
|
1073
1314
|
tr = current.editor.state.tr;
|
|
@@ -1089,203 +1330,16 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
1089
1330
|
}
|
|
1090
1331
|
case 1:
|
|
1091
1332
|
case "end":
|
|
1092
|
-
return
|
|
1333
|
+
return _context8.stop();
|
|
1093
1334
|
}
|
|
1094
|
-
},
|
|
1335
|
+
}, _callee8);
|
|
1095
1336
|
}));
|
|
1096
1337
|
function onClick() {
|
|
1097
1338
|
return _onClick6.apply(this, arguments);
|
|
1098
1339
|
}
|
|
1099
1340
|
return onClick;
|
|
1100
1341
|
}()
|
|
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)
|
|
1342
|
+
}] : []))
|
|
1289
1343
|
}) : /*#__PURE__*/React.createElement(DragIcon, null));
|
|
1290
1344
|
};
|
|
1291
1345
|
export default CustomDragHandle;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
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
|
+
import { SvgIcon } from "@mui/material";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export var IndentDecreaseIcon = function IndentDecreaseIcon(props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement(SvgIcon, _extends({
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
version: "1.1",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
d: "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z"
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
IndentDecreaseIcon.displayName = 'icon-indent-decrease';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
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
|
+
import { SvgIcon } from "@mui/material";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export var IndentIncreaseIcon = function IndentIncreaseIcon(props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement(SvgIcon, _extends({
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
version: "1.1",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
d: "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z"
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
IndentIncreaseIcon.displayName = 'icon-indent-increase';
|
|
@@ -59,6 +59,8 @@ export { HeadingIcon } from './heading-icon';
|
|
|
59
59
|
export { ImageAddLineIcon } from './image-add-line-icon';
|
|
60
60
|
export { ImageLineIcon } from './image-line-icon';
|
|
61
61
|
export { ImportLineIcon } from './import-line-icon';
|
|
62
|
+
export { IndentDecreaseIcon } from './indent-decrease-icon';
|
|
63
|
+
export { IndentIncreaseIcon } from './indent-increase-icon';
|
|
62
64
|
export { Information2FillIcon } from './information-2-fill-icon';
|
|
63
65
|
export { Information2LineIcon } from './information-2-line-icon';
|
|
64
66
|
export { InsertColumnLeftIcon } from './insert-column-left-icon';
|
|
@@ -62,6 +62,8 @@ export { HeadingIcon } from "./heading-icon";
|
|
|
62
62
|
export { ImageAddLineIcon } from "./image-add-line-icon";
|
|
63
63
|
export { ImageLineIcon } from "./image-line-icon";
|
|
64
64
|
export { ImportLineIcon } from "./import-line-icon";
|
|
65
|
+
export { IndentDecreaseIcon } from "./indent-decrease-icon";
|
|
66
|
+
export { IndentIncreaseIcon } from "./indent-increase-icon";
|
|
65
67
|
export { Information2FillIcon } from "./information-2-fill-icon";
|
|
66
68
|
export { Information2LineIcon } from "./information-2-line-icon";
|
|
67
69
|
export { InsertColumnLeftIcon } from "./insert-column-left-icon";
|
|
@@ -45,6 +45,7 @@ var VARIANT_DATA = {
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
var AlertView = function AlertView(_ref) {
|
|
48
|
+
var _node$attrs;
|
|
48
49
|
var editor = _ref.editor,
|
|
49
50
|
node = _ref.node,
|
|
50
51
|
updateAttributes = _ref.updateAttributes,
|
|
@@ -71,6 +72,7 @@ var AlertView = function AlertView(_ref) {
|
|
|
71
72
|
"data-drag-handle": true,
|
|
72
73
|
as: 'div',
|
|
73
74
|
style: {
|
|
75
|
+
marginLeft: (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.indent ? node.attrs.indent * 32 : undefined,
|
|
74
76
|
border: '1px solid',
|
|
75
77
|
borderColor: variantData.color,
|
|
76
78
|
color: variantData.color,
|
package/dist/extension/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import StarterKit from '@tiptap/starter-kit';
|
|
|
15
15
|
import { PLACEHOLDER } from "../contants/placeholder";
|
|
16
16
|
import { SlashCommands, StructuredDiffExtension } from "./extension";
|
|
17
17
|
import { CodeExtension } from "./mark/Code";
|
|
18
|
-
import { AlertExtension, AudioExtension, BlockAttachmentExtension, BlockLinkExtension, CodeBlockLowlightExtension, CustomBlockMathExtension, CustomInlineMathExtension, DetailsContentExtension, DetailsExtension, DetailsSummaryExtension, EmojiExtension, FileHandlerExtension, IframeExtension, ImageExtension, InlineAttachmentExtension, InlineLinkExtension, ListExtension, MentionExtension, TableExtension, TableOfContents, UploadProgressExtension, VerticalAlign, VideoExtension, YoutubeExtension } from "./node";
|
|
18
|
+
import { AlertExtension, AudioExtension, BlockAttachmentExtension, BlockLinkExtension, CodeBlockLowlightExtension, CustomBlockMathExtension, CustomInlineMathExtension, DetailsContentExtension, DetailsExtension, DetailsSummaryExtension, EmojiExtension, FileHandlerExtension, IframeExtension, ImageExtension, Indent, InlineAttachmentExtension, InlineLinkExtension, ListExtension, MentionExtension, TableExtension, TableOfContents, UploadProgressExtension, VerticalAlign, VideoExtension, YoutubeExtension } from "./node";
|
|
19
19
|
export var getExtensions = function getExtensions(_ref) {
|
|
20
20
|
var limit = _ref.limit,
|
|
21
21
|
exclude = _ref.exclude,
|
|
@@ -47,7 +47,17 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
47
47
|
defaultAlignment: null
|
|
48
48
|
}), CodeBlockLowlightExtension, CharacterCount.configure({
|
|
49
49
|
limit: limit !== null && limit !== void 0 ? limit : null
|
|
50
|
-
}), Subscript, Superscript, TextStyleKit,
|
|
50
|
+
}), Subscript, Superscript, TextStyleKit, Indent.configure({
|
|
51
|
+
types: [
|
|
52
|
+
// 常见块级与项目中定义的节点
|
|
53
|
+
'paragraph', 'heading', 'blockquote', 'alert', 'codeBlock', 'horizontalRule', 'orderedList', 'bulletList', 'taskList', 'taskItem', 'listItem', 'details', 'detailsContent', 'detailsSummary', 'table', 'image', 'video', 'audio', 'iframe', 'blockAttachment', 'inlineAttachment', 'blockLink',
|
|
54
|
+
// 公式
|
|
55
|
+
'blockMath', 'inlineMath'
|
|
56
|
+
// 扩展里还有:youtube 等,如需也可开启
|
|
57
|
+
],
|
|
58
|
+
maxLevel: 8,
|
|
59
|
+
indentPx: 32
|
|
60
|
+
}), CodeExtension, AlertExtension, Highlight.configure({
|
|
51
61
|
multicolor: true
|
|
52
62
|
}), Placeholder.configure({
|
|
53
63
|
emptyNodeClass: 'custom-placeholder-node',
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
export interface IndentOptions {
|
|
3
|
+
types: string[];
|
|
4
|
+
maxLevel: number;
|
|
5
|
+
indentPx: number;
|
|
6
|
+
}
|
|
7
|
+
declare module '@tiptap/core' {
|
|
8
|
+
interface Commands<ReturnType> {
|
|
9
|
+
indent: {
|
|
10
|
+
setIndent: (level: number) => ReturnType;
|
|
11
|
+
increaseIndent: () => ReturnType;
|
|
12
|
+
decreaseIndent: () => ReturnType;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export declare const Indent: Extension<IndentOptions, any>;
|
|
17
|
+
export default Indent;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
export var Indent = Extension.create({
|
|
3
|
+
name: 'indent',
|
|
4
|
+
addOptions: function addOptions() {
|
|
5
|
+
return {
|
|
6
|
+
// 若为 [], 则对所有节点类型生效
|
|
7
|
+
types: [],
|
|
8
|
+
maxLevel: 8,
|
|
9
|
+
indentPx: 24
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
addGlobalAttributes: function addGlobalAttributes() {
|
|
13
|
+
var _this = this,
|
|
14
|
+
_editorInstance$schem;
|
|
15
|
+
var descriptor = {
|
|
16
|
+
attributes: {
|
|
17
|
+
indent: {
|
|
18
|
+
default: 0,
|
|
19
|
+
parseHTML: function parseHTML(element) {
|
|
20
|
+
var data = element.getAttribute('data-indent');
|
|
21
|
+
if (data) return parseInt(data, 10) || 0;
|
|
22
|
+
var style = element.style.marginLeft;
|
|
23
|
+
if (!style) return 0;
|
|
24
|
+
var match = style.match(/(\d+)(px|em|rem)/);
|
|
25
|
+
if (!match) return 0;
|
|
26
|
+
var val = parseInt(match[1], 10);
|
|
27
|
+
return isNaN(val) ? 0 : Math.round(val / _this.options.indentPx);
|
|
28
|
+
},
|
|
29
|
+
renderHTML: function renderHTML(attributes) {
|
|
30
|
+
var level = Number(attributes.indent) || 0;
|
|
31
|
+
if (!level) return {};
|
|
32
|
+
var px = level * _this.options.indentPx;
|
|
33
|
+
return {
|
|
34
|
+
'data-indent': String(level),
|
|
35
|
+
style: "margin-left: ".concat(px, "px;")
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var editorInstance = this.editor;
|
|
42
|
+
var typesList = this.options.types && this.options.types.length > 0 ? this.options.types : Object.keys((editorInstance === null || editorInstance === void 0 || (_editorInstance$schem = editorInstance.schema) === null || _editorInstance$schem === void 0 ? void 0 : _editorInstance$schem.nodes) || {});
|
|
43
|
+
descriptor.types = typesList;
|
|
44
|
+
return [descriptor];
|
|
45
|
+
},
|
|
46
|
+
addCommands: function addCommands() {
|
|
47
|
+
var _this2 = this;
|
|
48
|
+
return {
|
|
49
|
+
setIndent: function setIndent(level) {
|
|
50
|
+
return function (_ref) {
|
|
51
|
+
var _selection$node, _selection$$from;
|
|
52
|
+
var commands = _ref.commands,
|
|
53
|
+
editor = _ref.editor;
|
|
54
|
+
var _ref2 = editor.state,
|
|
55
|
+
selection = _ref2.selection;
|
|
56
|
+
var nodeTypeName = (selection === null || selection === void 0 || (_selection$node = selection.node) === null || _selection$node === void 0 || (_selection$node = _selection$node.type) === null || _selection$node === void 0 ? void 0 : _selection$node.name) || (selection === null || selection === void 0 || (_selection$$from = selection.$from) === null || _selection$$from === void 0 || (_selection$$from = _selection$$from.parent) === null || _selection$$from === void 0 || (_selection$$from = _selection$$from.type) === null || _selection$$from === void 0 ? void 0 : _selection$$from.name);
|
|
57
|
+
if (!nodeTypeName) return false;
|
|
58
|
+
var next = Math.max(0, Math.min(level, _this2.options.maxLevel));
|
|
59
|
+
return commands.updateAttributes(nodeTypeName, {
|
|
60
|
+
indent: next
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
increaseIndent: function increaseIndent() {
|
|
65
|
+
return function (_ref3) {
|
|
66
|
+
var _selection$node2, _selection$$from2;
|
|
67
|
+
var commands = _ref3.commands,
|
|
68
|
+
editor = _ref3.editor;
|
|
69
|
+
var _ref4 = editor.state,
|
|
70
|
+
selection = _ref4.selection;
|
|
71
|
+
var nodeTypeName = (selection === null || selection === void 0 || (_selection$node2 = selection.node) === null || _selection$node2 === void 0 || (_selection$node2 = _selection$node2.type) === null || _selection$node2 === void 0 ? void 0 : _selection$node2.name) || (selection === null || selection === void 0 || (_selection$$from2 = selection.$from) === null || _selection$$from2 === void 0 || (_selection$$from2 = _selection$$from2.parent) === null || _selection$$from2 === void 0 || (_selection$$from2 = _selection$$from2.type) === null || _selection$$from2 === void 0 ? void 0 : _selection$$from2.name);
|
|
72
|
+
if (!nodeTypeName) return false;
|
|
73
|
+
var attrs = editor.getAttributes(nodeTypeName);
|
|
74
|
+
var current = Number(attrs.indent) || 0;
|
|
75
|
+
var next = Math.max(0, Math.min(current + 1, _this2.options.maxLevel));
|
|
76
|
+
if (next === current) return false;
|
|
77
|
+
return commands.updateAttributes(nodeTypeName, {
|
|
78
|
+
indent: next
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
decreaseIndent: function decreaseIndent() {
|
|
83
|
+
return function (_ref5) {
|
|
84
|
+
var _selection$node3, _selection$$from3;
|
|
85
|
+
var commands = _ref5.commands,
|
|
86
|
+
editor = _ref5.editor;
|
|
87
|
+
var _ref6 = editor.state,
|
|
88
|
+
selection = _ref6.selection;
|
|
89
|
+
var nodeTypeName = (selection === null || selection === void 0 || (_selection$node3 = selection.node) === null || _selection$node3 === void 0 || (_selection$node3 = _selection$node3.type) === null || _selection$node3 === void 0 ? void 0 : _selection$node3.name) || (selection === null || selection === void 0 || (_selection$$from3 = selection.$from) === null || _selection$$from3 === void 0 || (_selection$$from3 = _selection$$from3.parent) === null || _selection$$from3 === void 0 || (_selection$$from3 = _selection$$from3.type) === null || _selection$$from3 === void 0 ? void 0 : _selection$$from3.name);
|
|
90
|
+
if (!nodeTypeName) return false;
|
|
91
|
+
var attrs = editor.getAttributes(nodeTypeName);
|
|
92
|
+
var current = Number(attrs.indent) || 0;
|
|
93
|
+
var next = Math.max(0, Math.min(current - 1, _this2.options.maxLevel));
|
|
94
|
+
if (next === current) return false;
|
|
95
|
+
return commands.updateAttributes(nodeTypeName, {
|
|
96
|
+
indent: next
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
export default Indent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/core';
|
|
2
2
|
export declare const TableExtension: ({ editable }: {
|
|
3
3
|
editable: boolean;
|
|
4
|
-
}) => (import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableHeaderOptions, any>
|
|
4
|
+
}) => (Extension<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableHeaderOptions, any>)[];
|
|
5
5
|
export default TableExtension;
|
package/dist/index.css
CHANGED
|
@@ -6,6 +6,39 @@
|
|
|
6
6
|
color: var(--mui-palette-text-secondary);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/* 节点缩进(依赖 data-indent 属性) */
|
|
10
|
+
.tiptap.ProseMirror [data-indent="1"] {
|
|
11
|
+
margin-left: 32px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.tiptap.ProseMirror [data-indent="2"] {
|
|
15
|
+
margin-left: 64px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.tiptap.ProseMirror [data-indent="3"] {
|
|
19
|
+
margin-left: 96px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.tiptap.ProseMirror [data-indent="4"] {
|
|
23
|
+
margin-left: 128px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tiptap.ProseMirror [data-indent="5"] {
|
|
27
|
+
margin-left: 160px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.tiptap.ProseMirror [data-indent="6"] {
|
|
31
|
+
margin-left: 192px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.tiptap.ProseMirror [data-indent="7"] {
|
|
35
|
+
margin-left: 224px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.tiptap.ProseMirror [data-indent="8"] {
|
|
39
|
+
margin-left: 256px;
|
|
40
|
+
}
|
|
41
|
+
|
|
9
42
|
.tiptap.ProseMirror[contenteditable="false"] {
|
|
10
43
|
padding: 0;
|
|
11
44
|
}
|