@ctzhian/tiptap 1.6.3 → 1.6.5

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,7 +1,3 @@
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
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -18,6 +14,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
18
14
  var _useState = useState({
19
15
  undo: false,
20
16
  redo: false,
17
+ format: false,
21
18
  quote: false,
22
19
  bold: false,
23
20
  italic: false,
@@ -36,9 +33,11 @@ var EditorToolbar = function EditorToolbar(_ref) {
36
33
  active = _useState2[0],
37
34
  setActive = _useState2[1];
38
35
  var updateSelection = function updateSelection() {
36
+ var _editor$can$chain$und, _editor$can$chain$red, _editor$can$chain$uns;
39
37
  setActive({
40
- undo: editor.can().undo(),
41
- redo: editor.can().redo(),
38
+ undo: (_editor$can$chain$und = editor.can().chain().undo().run()) !== null && _editor$can$chain$und !== void 0 ? _editor$can$chain$und : false,
39
+ redo: (_editor$can$chain$red = editor.can().chain().redo().run()) !== null && _editor$can$chain$red !== void 0 ? _editor$can$chain$red : false,
40
+ format: (_editor$can$chain$uns = editor.can().chain().unsetAllMarks().run()) !== null && _editor$can$chain$uns !== void 0 ? _editor$can$chain$uns : false,
42
41
  quote: editor.isActive('blockquote'),
43
42
  bold: editor.isActive('bold'),
44
43
  italic: editor.isActive('italic'),
@@ -107,7 +106,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
107
106
  }
108
107
  }),
109
108
  onClick: function onClick() {
110
- return editor.commands.setAiWriting(!active.aiWriting);
109
+ return editor.chain().focus().setAiWriting(!active.aiWriting).run();
111
110
  },
112
111
  className: active.aiWriting ? 'tool-active' : ''
113
112
  }), /*#__PURE__*/React.createElement(Divider, {
@@ -149,36 +148,10 @@ var EditorToolbar = function EditorToolbar(_ref) {
149
148
  fontSize: '1rem'
150
149
  }
151
150
  }),
152
- disabled: editor.state.selection.empty,
153
- onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
154
- var tr, currentNode, empty, content;
155
- return _regeneratorRuntime().wrap(function _callee$(_context) {
156
- while (1) switch (_context.prev = _context.next) {
157
- case 0:
158
- if (!editor.state.selection.empty) {
159
- tr = editor.state.tr;
160
- currentNode = editor.state.selection.content();
161
- empty = currentNode.content.size === 0;
162
- if (!empty) {
163
- content = currentNode.content.content;
164
- if (content && content.length > 0) {
165
- tr.doc.nodesBetween(editor.state.selection.from, editor.state.selection.to, function (node, pos) {
166
- if (!node.isInline) return true;
167
- node.marks.forEach(function (mark) {
168
- tr.removeMark(pos, pos + node.nodeSize, mark.type);
169
- });
170
- return true;
171
- });
172
- }
173
- }
174
- editor.view.dispatch(tr);
175
- }
176
- case 1:
177
- case "end":
178
- return _context.stop();
179
- }
180
- }, _callee);
181
- }))
151
+ disabled: !active.format,
152
+ onClick: function onClick() {
153
+ return editor.chain().focus().unsetAllMarks().run();
154
+ }
182
155
  }), /*#__PURE__*/React.createElement(Divider, {
183
156
  orientation: "vertical",
184
157
  flexItem: true,
@@ -24,7 +24,7 @@ import DragHandle from '@tiptap/extension-drag-handle-react';
24
24
  import { Fragment, Slice } from '@tiptap/pm/model';
25
25
  import { NodeSelection } from '@tiptap/pm/state';
26
26
  import React, { useCallback, useState } from 'react';
27
- import { convertNodeAt, downloadFiles, filterResourcesByType, getAllResources } from "../../util";
27
+ import { convertNodeAt, downloadFiles, filterResourcesByType, getAllResources, getShortcutKeyText } from "../../util";
28
28
  import Menu from "../Menu";
29
29
  import { ToolbarItem } from "../Toolbar";
30
30
  var DragIcon = function DragIcon(_ref) {
@@ -258,7 +258,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
258
258
  var updateNodeChange = useCallback(function (data) {
259
259
  var _data$node, _current$node2;
260
260
  if ((data.pos !== current.pos || ((_data$node = data.node) === null || _data$node === void 0 ? void 0 : _data$node.type.name) !== ((_current$node2 = current.node) === null || _current$node2 === void 0 ? void 0 : _current$node2.type.name)) && data.pos !== -1 || data.node === null && data.pos >= 0) {
261
- var _data$node2;
261
+ var _data$node2, _editor$can$chain$uns;
262
262
  var allResources = data.node ? getAllResources(data.node) : [];
263
263
  var videos = filterResourcesByType(allResources, [NodeTypeEnum.Video]);
264
264
  var audios = filterResourcesByType(allResources, [NodeTypeEnum.Audio]);
@@ -272,10 +272,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
272
272
  images: images,
273
273
  attachments: attachments
274
274
  });
275
- setShowFormat(shouldShowButton({
276
- editor: editor,
277
- data: data
278
- }));
275
+ setShowFormat((_editor$can$chain$uns = editor.can().chain().unsetAllMarks().run()) !== null && _editor$can$chain$uns !== void 0 ? _editor$can$chain$uns : false);
279
276
  }
280
277
  }, [current.pos, current.node]);
281
278
  return /*#__PURE__*/React.createElement(DragHandle, {
@@ -680,7 +677,6 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
680
677
  }] : []), _toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.align ? [{
681
678
  key: 'align',
682
679
  label: '对齐方式',
683
- width: 160,
684
680
  icon: /*#__PURE__*/React.createElement(AlignLeftIcon, {
685
681
  sx: {
686
682
  fontSize: '1rem'
@@ -698,6 +694,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
698
694
  key: 'align-horizontal'
699
695
  }, {
700
696
  label: '左侧对齐',
697
+ extra: /*#__PURE__*/React.createElement(Typography, {
698
+ sx: {
699
+ fontSize: '12px',
700
+ color: 'text.disabled'
701
+ }
702
+ }, getShortcutKeyText(['ctrl', 'shift', 'L'], '+')),
701
703
  key: 'align-horizontal-left',
702
704
  icon: /*#__PURE__*/React.createElement(AlignLeftIcon, {
703
705
  sx: {
@@ -716,6 +718,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
716
718
  }
717
719
  }, {
718
720
  label: '居中对齐',
721
+ extra: /*#__PURE__*/React.createElement(Typography, {
722
+ sx: {
723
+ fontSize: '12px',
724
+ color: 'text.disabled'
725
+ }
726
+ }, getShortcutKeyText(['ctrl', 'shift', 'E'], '+')),
719
727
  key: 'align-horizontal-center',
720
728
  icon: /*#__PURE__*/React.createElement(AlignCenterIcon, {
721
729
  sx: {
@@ -734,6 +742,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
734
742
  }
735
743
  }, {
736
744
  label: '右侧对齐',
745
+ extra: /*#__PURE__*/React.createElement(Typography, {
746
+ sx: {
747
+ fontSize: '12px',
748
+ color: 'text.disabled'
749
+ }
750
+ }, getShortcutKeyText(['ctrl', 'shift', 'R'], '+')),
737
751
  key: 'align-horizontal-right',
738
752
  icon: /*#__PURE__*/React.createElement(AlignRightIcon, {
739
753
  sx: {
@@ -752,6 +766,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
752
766
  }
753
767
  }, {
754
768
  label: '两端对齐',
769
+ extra: /*#__PURE__*/React.createElement(Typography, {
770
+ sx: {
771
+ fontSize: '12px',
772
+ color: 'text.disabled'
773
+ }
774
+ }, getShortcutKeyText(['ctrl', 'shift', 'J'], '+')),
755
775
  key: 'align-horizontal-justify',
756
776
  icon: /*#__PURE__*/React.createElement(AlignJustifyIcon, {
757
777
  sx: {
@@ -780,6 +800,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
780
800
  key: 'align-vertical'
781
801
  }, {
782
802
  label: '顶部对齐',
803
+ extra: /*#__PURE__*/React.createElement(Typography, {
804
+ sx: {
805
+ fontSize: '12px',
806
+ color: 'text.disabled'
807
+ }
808
+ }, getShortcutKeyText(['ctrl', 'alt', 'T'], '+')),
783
809
  key: 'align-vertical-top',
784
810
  icon: /*#__PURE__*/React.createElement(AlignTopIcon, {
785
811
  sx: {
@@ -798,6 +824,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
798
824
  }
799
825
  }, {
800
826
  label: '居中对齐',
827
+ extra: /*#__PURE__*/React.createElement(Typography, {
828
+ sx: {
829
+ fontSize: '12px',
830
+ color: 'text.disabled'
831
+ }
832
+ }, getShortcutKeyText(['ctrl', 'alt', 'M'], '+')),
801
833
  key: 'align-vertical-center',
802
834
  icon: /*#__PURE__*/React.createElement(AlignCenterIcon, {
803
835
  sx: {
@@ -816,6 +848,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
816
848
  }
817
849
  }, {
818
850
  label: '底部对齐',
851
+ extra: /*#__PURE__*/React.createElement(Typography, {
852
+ sx: {
853
+ fontSize: '12px',
854
+ color: 'text.disabled'
855
+ }
856
+ }, getShortcutKeyText(['ctrl', 'alt', 'B'], '+')),
819
857
  key: 'align-vertical-bottom',
820
858
  icon: /*#__PURE__*/React.createElement(AlignBottomIcon, {
821
859
  sx: {
@@ -867,7 +905,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
867
905
  }
868
906
  }
869
907
  }, {
870
- label: '一级标题',
908
+ label: '标题1',
871
909
  selected: ((_current$node4 = current.node) === null || _current$node4 === void 0 ? void 0 : _current$node4.type.name) === 'heading' && ((_current$node5 = current.node) === null || _current$node5 === void 0 ? void 0 : _current$node5.attrs.level) === 1,
872
910
  key: 'convert-to-heading-1',
873
911
  icon: /*#__PURE__*/React.createElement(H1Icon, {
@@ -893,7 +931,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
893
931
  }
894
932
  }
895
933
  }, {
896
- label: '二级标题',
934
+ label: '标题2',
897
935
  selected: ((_current$node6 = current.node) === null || _current$node6 === void 0 ? void 0 : _current$node6.type.name) === 'heading' && ((_current$node7 = current.node) === null || _current$node7 === void 0 ? void 0 : _current$node7.attrs.level) === 2,
898
936
  key: 'convert-to-heading-2',
899
937
  icon: /*#__PURE__*/React.createElement(H2Icon, {
@@ -919,7 +957,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
919
957
  }
920
958
  }
921
959
  }, {
922
- label: '三级标题',
960
+ label: '标题3',
923
961
  selected: ((_current$node8 = current.node) === null || _current$node8 === void 0 ? void 0 : _current$node8.type.name) === 'heading' && ((_current$node9 = current.node) === null || _current$node9 === void 0 ? void 0 : _current$node9.attrs.level) === 3,
924
962
  key: 'convert-to-heading-3',
925
963
  icon: /*#__PURE__*/React.createElement(H3Icon, {
@@ -1370,41 +1408,9 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
1370
1408
  fontSize: '1rem'
1371
1409
  }
1372
1410
  }),
1373
- onClick: function () {
1374
- var _onClick6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1375
- var tr, _currentNode, empty, content;
1376
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1377
- while (1) switch (_context8.prev = _context8.next) {
1378
- case 0:
1379
- if (current.node && current.pos !== undefined) {
1380
- tr = current.editor.state.tr;
1381
- _currentNode = current.node;
1382
- empty = (_currentNode === null || _currentNode === void 0 ? void 0 : _currentNode.textContent) === '';
1383
- if (!empty) {
1384
- content = _currentNode === null || _currentNode === void 0 ? void 0 : _currentNode.content.content;
1385
- if (content && content.length > 0) {
1386
- tr.doc.nodesBetween(current.pos, current.pos + current.node.nodeSize, function (node, pos) {
1387
- if (!node.isInline) return true;
1388
- node.marks.forEach(function (mark) {
1389
- tr.removeMark(pos, pos + node.nodeSize, mark.type);
1390
- });
1391
- return true;
1392
- });
1393
- }
1394
- }
1395
- editor.view.dispatch(tr);
1396
- }
1397
- case 1:
1398
- case "end":
1399
- return _context8.stop();
1400
- }
1401
- }, _callee8);
1402
- }));
1403
- function onClick() {
1404
- return _onClick6.apply(this, arguments);
1405
- }
1406
- return onClick;
1407
- }()
1411
+ onClick: function onClick() {
1412
+ current.editor.chain().focus().unsetAllMarks().run();
1413
+ }
1408
1414
  }] : []))
1409
1415
  }) : /*#__PURE__*/React.createElement(DragIcon, null)));
1410
1416
  };
@@ -0,0 +1,6 @@
1
+ import { SvgIconProps } from "@mui/material";
2
+ import * as React from "react";
3
+ export declare const CommandLineIcon: {
4
+ (props: SvgIconProps): React.JSX.Element;
5
+ displayName: string;
6
+ };
@@ -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 CommandLineIcon = function CommandLineIcon(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: "M10 8H14V6.5C14 4.567 15.567 3 17.5 3C19.433 3 21 4.567 21 6.5C21 8.433 19.433 10 17.5 10H16V14H17.5C19.433 14 21 15.567 21 17.5C21 19.433 19.433 21 17.5 21C15.567 21 14 19.433 14 17.5V16H10V17.5C10 19.433 8.433 21 6.5 21C4.567 21 3 19.433 3 17.5C3 15.567 4.567 14 6.5 14H8V10H6.5C4.567 10 3 8.433 3 6.5C3 4.567 4.567 3 6.5 3C8.433 3 10 4.567 10 6.5V8ZM8 8V6.5C8 5.67157 7.32843 5 6.5 5C5.67157 5 5 5.67157 5 6.5C5 7.32843 5.67157 8 6.5 8H8ZM8 16H6.5C5.67157 16 5 16.6716 5 17.5C5 18.3284 5.67157 19 6.5 19C7.32843 19 8 18.3284 8 17.5V16ZM16 8H17.5C18.3284 8 19 7.32843 19 6.5C19 5.67157 18.3284 5 17.5 5C16.6716 5 16 5.67157 16 6.5V8ZM16 16V17.5C16 18.3284 16.6716 19 17.5 19C18.3284 19 19 18.3284 19 17.5C19 16.6716 18.3284 16 17.5 16H16ZM10 10V14H14V10H10Z"
11
+ }));
12
+ };
13
+ CommandLineIcon.displayName = 'icon-command-line';
@@ -28,6 +28,7 @@ export { CloseCircleFillIcon } from './close-circle-fill-icon';
28
28
  export { CodeBoxLineIcon } from './code-box-line-icon';
29
29
  export { CodeLineIcon } from './code-line-icon';
30
30
  export { CodeSSlashLineIcon } from './code-s-slash-line-icon';
31
+ export { CommandLineIcon } from './command-line-icon';
31
32
  export { CopyIcon } from './copy-icon';
32
33
  export { CustomSizeIcon } from './custom-size-icon';
33
34
  export { DeleteColumnIcon } from './delete-column-icon';
@@ -72,6 +73,7 @@ export { InsertColumnRightIcon } from './insert-column-right-icon';
72
73
  export { InsertRowBottomIcon } from './insert-row-bottom-icon';
73
74
  export { InsertRowTopIcon } from './insert-row-top-icon';
74
75
  export { ItalicIcon } from './italic-icon';
76
+ export { KeyboardLineIcon } from './keyboard-line-icon';
75
77
  export { LayoutLeft2LineIcon } from './layout-left-2-line-icon';
76
78
  export { LayoutTop2LineIcon } from './layout-top-2-line-icon';
77
79
  export { LinkIcon } from './link-icon';
@@ -31,6 +31,7 @@ export { CloseCircleFillIcon } from "./close-circle-fill-icon";
31
31
  export { CodeBoxLineIcon } from "./code-box-line-icon";
32
32
  export { CodeLineIcon } from "./code-line-icon";
33
33
  export { CodeSSlashLineIcon } from "./code-s-slash-line-icon";
34
+ export { CommandLineIcon } from "./command-line-icon";
34
35
  export { CopyIcon } from "./copy-icon";
35
36
  export { CustomSizeIcon } from "./custom-size-icon";
36
37
  export { DeleteColumnIcon } from "./delete-column-icon";
@@ -75,6 +76,7 @@ export { InsertColumnRightIcon } from "./insert-column-right-icon";
75
76
  export { InsertRowBottomIcon } from "./insert-row-bottom-icon";
76
77
  export { InsertRowTopIcon } from "./insert-row-top-icon";
77
78
  export { ItalicIcon } from "./italic-icon";
79
+ export { KeyboardLineIcon } from "./keyboard-line-icon";
78
80
  export { LayoutLeft2LineIcon } from "./layout-left-2-line-icon";
79
81
  export { LayoutTop2LineIcon } from "./layout-top-2-line-icon";
80
82
  export { LinkIcon } from "./link-icon";
@@ -0,0 +1,6 @@
1
+ import { SvgIconProps } from "@mui/material";
2
+ import * as React from "react";
3
+ export declare const KeyboardLineIcon: {
4
+ (props: SvgIconProps): React.JSX.Element;
5
+ displayName: string;
6
+ };
@@ -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 KeyboardLineIcon = function KeyboardLineIcon(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 17H21V19H3V17ZM3 11H6V14H3V11ZM8 11H11V14H8V11ZM3 5H6V8H3V5ZM13 5H16V8H13V5ZM18 5H21V8H18V5ZM13 11H16V14H13V11ZM18 11H21V14H18V11ZM8 5H11V8H8V5Z"
11
+ }));
12
+ };
13
+ KeyboardLineIcon.displayName = 'icon-keyboard-line';
@@ -57,11 +57,12 @@ var NestedList = function NestedList(_ref) {
57
57
  };
58
58
  return /*#__PURE__*/React.createElement(Box, {
59
59
  className: "menu-select-list",
60
- sx: {
60
+ sx: _objectSpread({
61
61
  minWidth: 160,
62
- width: width,
63
62
  lineHeight: 1.625
64
- }
63
+ }, width ? {
64
+ width: width
65
+ } : {})
65
66
  }, list.map(function (item) {
66
67
  var _item$children2;
67
68
  return item.customLabel ? /*#__PURE__*/React.createElement(Box, {
@@ -103,13 +104,13 @@ var NestedList = function NestedList(_ref) {
103
104
  onClose: handleItemLeave,
104
105
  sx: {
105
106
  pointerEvents: 'none'
106
- }
107
+ },
108
+ disableScrollLock: true
107
109
  }, childrenProps), /*#__PURE__*/React.createElement(Box, {
108
110
  className: "menu-select-sub-list",
109
111
  sx: _objectSpread(_objectSpread(_objectSpread({
110
112
  pointerEvents: 'auto',
111
113
  p: 0.5,
112
- width: width,
113
114
  minWidth: 160,
114
115
  maxHeight: 360,
115
116
  overflow: 'auto'
@@ -10,8 +10,7 @@ import NestedList from "./NestedList";
10
10
  var Menu = function Menu(_ref) {
11
11
  var _ref$id = _ref.id,
12
12
  id = _ref$id === void 0 ? 'menu-select' : _ref$id,
13
- _ref$width = _ref.width,
14
- width = _ref$width === void 0 ? 160 : _ref$width,
13
+ width = _ref.width,
15
14
  arrowIcon = _ref.arrowIcon,
16
15
  list = _ref.list,
17
16
  _ref$header = _ref.header,
@@ -69,7 +68,8 @@ var Menu = function Menu(_ref) {
69
68
  anchorEl: anchorEl,
70
69
  onClose: handleClose,
71
70
  anchorOrigin: anchorOrigin,
72
- transformOrigin: transformOrigin
71
+ transformOrigin: transformOrigin,
72
+ disableScrollLock: true
73
73
  }, /*#__PURE__*/React.createElement(Box, {
74
74
  sx: {
75
75
  p: 0.5
@@ -162,7 +162,7 @@ var EditorHeading = function EditorHeading(_ref) {
162
162
  fontSize: '12px',
163
163
  color: 'text.disabled'
164
164
  }
165
- }, getShortcutKeyText(it.shortcutKey, ' ')),
165
+ }, getShortcutKeyText(it.shortcutKey, '+')),
166
166
  onClick: function onClick() {
167
167
  return handleChange(it.id);
168
168
  }
@@ -287,21 +287,6 @@ var EditorInsert = function EditorInsert(_ref) {
287
287
  });
288
288
  }
289
289
  }]
290
- }, {
291
- label: 'Iframe 链接',
292
- key: 'iframe',
293
- icon: /*#__PURE__*/React.createElement(WindowFillIcon, {
294
- sx: {
295
- fontSize: '1rem'
296
- }
297
- }),
298
- onClick: function onClick() {
299
- return editor.commands.setIframe({
300
- src: '',
301
- width: 760,
302
- height: 400
303
- });
304
- }
305
290
  }, {
306
291
  customLabel: /*#__PURE__*/React.createElement(Typography, {
307
292
  sx: {
@@ -8,7 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  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; }
9
9
  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; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
- import { MoreLineIcon, Notification3LineIcon } from "../../Icons";
11
+ import { CommandLineIcon, MoreLineIcon } from "../../Icons";
12
12
  import ToolbarItem from "../Item";
13
13
  import { Box, MenuItem, Select, Stack } from "@mui/material";
14
14
  import React, { useState } from "react";
@@ -22,7 +22,7 @@ var EditorMore = function EditorMore(_ref) {
22
22
  setShowDialog = _useState2[1];
23
23
  var options = [{
24
24
  id: 'notification',
25
- icon: /*#__PURE__*/React.createElement(Notification3LineIcon, {
25
+ icon: /*#__PURE__*/React.createElement(CommandLineIcon, {
26
26
  sx: {
27
27
  fontSize: '1rem'
28
28
  }
@@ -1,7 +1,8 @@
1
1
  import { Editor } from '@tiptap/react';
2
2
  import * as React from 'react';
3
- export declare const slashCommands: {
3
+ export declare const slashCommands: ({
4
4
  title: string;
5
+ shortcutKey: string[];
5
6
  icon: React.JSX.Element;
6
7
  command: ({ editor, range, attrs }: {
7
8
  editor: Editor;
@@ -11,4 +12,16 @@ export declare const slashCommands: {
11
12
  };
12
13
  attrs: any;
13
14
  }) => void;
14
- }[];
15
+ } | {
16
+ title: string;
17
+ icon: React.JSX.Element;
18
+ command: ({ editor, range, attrs }: {
19
+ editor: Editor;
20
+ range: {
21
+ from: number;
22
+ to: number;
23
+ };
24
+ attrs: any;
25
+ }) => void;
26
+ shortcutKey?: undefined;
27
+ })[];
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { AttachmentLineIcon, CodeBoxLineIcon, CodeLineIcon, DoubleQuotesLIcon, FunctionsIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, H6Icon, ImageLineIcon, Information2LineIcon, LinkIcon, ListCheck2Icon, ListOrdered2Icon, ListUnorderedIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, Table2Icon, TextWrapIcon, WindowFillIcon } from "../component/Icons";
3
3
  export var slashCommands = [{
4
- title: '一级标题',
4
+ title: '标题1',
5
+ shortcutKey: ['ctrl', 'alt', '1'],
5
6
  icon: /*#__PURE__*/React.createElement(H1Icon, {
6
7
  sx: {
7
8
  fontSize: '1rem'
@@ -15,7 +16,8 @@ export var slashCommands = [{
15
16
  }).run();
16
17
  }
17
18
  }, {
18
- title: '二级标题',
19
+ title: '标题2',
20
+ shortcutKey: ['ctrl', 'alt', '2'],
19
21
  icon: /*#__PURE__*/React.createElement(H2Icon, {
20
22
  sx: {
21
23
  fontSize: '1rem'
@@ -29,7 +31,8 @@ export var slashCommands = [{
29
31
  }).run();
30
32
  }
31
33
  }, {
32
- title: '三级标题',
34
+ title: '标题3',
35
+ shortcutKey: ['ctrl', 'alt', '3'],
33
36
  icon: /*#__PURE__*/React.createElement(H3Icon, {
34
37
  sx: {
35
38
  fontSize: '1rem'
@@ -43,7 +46,8 @@ export var slashCommands = [{
43
46
  }).run();
44
47
  }
45
48
  }, {
46
- title: '四级标题',
49
+ title: '标题4',
50
+ shortcutKey: ['ctrl', 'alt', '4'],
47
51
  icon: /*#__PURE__*/React.createElement(H4Icon, {
48
52
  sx: {
49
53
  fontSize: '1rem'
@@ -57,7 +61,8 @@ export var slashCommands = [{
57
61
  }).run();
58
62
  }
59
63
  }, {
60
- title: '五级标题',
64
+ title: '标题5',
65
+ shortcutKey: ['ctrl', 'alt', '5'],
61
66
  icon: /*#__PURE__*/React.createElement(H5Icon, {
62
67
  sx: {
63
68
  fontSize: '1rem'
@@ -71,7 +76,8 @@ export var slashCommands = [{
71
76
  }).run();
72
77
  }
73
78
  }, {
74
- title: '六级标题',
79
+ title: '标题6',
80
+ shortcutKey: ['ctrl', 'alt', '6'],
75
81
  icon: /*#__PURE__*/React.createElement(H6Icon, {
76
82
  sx: {
77
83
  fontSize: '1rem'
@@ -86,6 +92,7 @@ export var slashCommands = [{
86
92
  }
87
93
  }, {
88
94
  title: '有序列表',
95
+ shortcutKey: ['ctrl', 'shift', '7'],
89
96
  icon: /*#__PURE__*/React.createElement(ListOrdered2Icon, {
90
97
  sx: {
91
98
  fontSize: '1rem'
@@ -98,6 +105,7 @@ export var slashCommands = [{
98
105
  }
99
106
  }, {
100
107
  title: '无序列表',
108
+ shortcutKey: ['ctrl', 'shift', '8'],
101
109
  icon: /*#__PURE__*/React.createElement(ListUnorderedIcon, {
102
110
  sx: {
103
111
  fontSize: '1rem'
@@ -110,6 +118,7 @@ export var slashCommands = [{
110
118
  }
111
119
  }, {
112
120
  title: '任务列表',
121
+ shortcutKey: ['ctrl', 'shift', '9'],
113
122
  icon: /*#__PURE__*/React.createElement(ListCheck2Icon, {
114
123
  sx: {
115
124
  fontSize: '1rem'
@@ -146,6 +155,7 @@ export var slashCommands = [{
146
155
  }
147
156
  }, {
148
157
  title: '引用块',
158
+ shortcutKey: ['ctrl', 'shift', 'B'],
149
159
  icon: /*#__PURE__*/React.createElement(DoubleQuotesLIcon, {
150
160
  sx: {
151
161
  fontSize: '1rem'
@@ -158,6 +168,7 @@ export var slashCommands = [{
158
168
  }
159
169
  }, {
160
170
  title: '行内代码',
171
+ shortcutKey: ['ctrl', 'E'],
161
172
  icon: /*#__PURE__*/React.createElement(CodeLineIcon, {
162
173
  sx: {
163
174
  fontSize: '1rem'
@@ -170,6 +181,7 @@ export var slashCommands = [{
170
181
  }
171
182
  }, {
172
183
  title: '代码块',
184
+ shortcutKey: ['ctrl', 'alt', 'C'],
173
185
  icon: /*#__PURE__*/React.createElement(CodeBoxLineIcon, {
174
186
  sx: {
175
187
  fontSize: '1rem'
@@ -182,6 +194,7 @@ export var slashCommands = [{
182
194
  }
183
195
  }, {
184
196
  title: '链接',
197
+ shortcutKey: ['ctrl', '1'],
185
198
  icon: /*#__PURE__*/React.createElement(LinkIcon, {
186
199
  sx: {
187
200
  fontSize: '1rem'
@@ -196,6 +209,7 @@ export var slashCommands = [{
196
209
  }
197
210
  }, {
198
211
  title: '折叠块',
212
+ shortcutKey: ['ctrl', '8'],
199
213
  icon: /*#__PURE__*/React.createElement(MenuFold2FillIcon, {
200
214
  sx: {
201
215
  fontSize: '1rem'
@@ -224,6 +238,7 @@ export var slashCommands = [{
224
238
  }
225
239
  }, {
226
240
  title: '表格',
241
+ shortcutKey: ['ctrl', '9'],
227
242
  icon: /*#__PURE__*/React.createElement(Table2Icon, {
228
243
  sx: {
229
244
  fontSize: '1rem'
@@ -8,7 +8,8 @@ import { NestedList } from "../../../component";
8
8
  import { ArrowDownSLineIcon, AttachmentLineIcon, CheckboxCircleFillIcon, CloseCircleFillIcon, ErrorWarningFillIcon, FormulaIcon, FunctionsIcon, ImageLineIcon, Information2FillIcon, Information2LineIcon, MovieLineIcon, Music2LineIcon, SquareRootIcon, Table2Icon, UploadIcon } from "../../../component/Icons";
9
9
  import { ToolbarItem } from "../../../component/Toolbar";
10
10
  import TableSizePicker from "../../../component/Toolbar/TableSizePicker";
11
- import { Box, Divider, Stack } from '@mui/material';
11
+ import { getShortcutKeyText } from "../../../util";
12
+ import { Box, Divider, Stack, Typography } from '@mui/material';
12
13
  import React, { forwardRef } from 'react';
13
14
  var SlashCommandsList = /*#__PURE__*/forwardRef(function (_ref, ref) {
14
15
  var items = _ref.items,
@@ -27,6 +28,7 @@ var SlashCommandsList = /*#__PURE__*/forwardRef(function (_ref, ref) {
27
28
  }, items.slice(0, 17).map(function (item, index) {
28
29
  return /*#__PURE__*/React.createElement(ToolbarItem, {
29
30
  key: index,
31
+ shortcutKey: (item === null || item === void 0 ? void 0 : item.shortcutKey) || [],
30
32
  onClick: function onClick() {
31
33
  return command(item);
32
34
  },
@@ -46,6 +48,12 @@ var SlashCommandsList = /*#__PURE__*/forwardRef(function (_ref, ref) {
46
48
  fontSize: '1rem'
47
49
  }
48
50
  }),
51
+ extra: /*#__PURE__*/React.createElement(Typography, {
52
+ sx: {
53
+ fontSize: '12px',
54
+ color: 'text.disabled'
55
+ }
56
+ }, getShortcutKeyText(['ctrl', '9'], '+')),
49
57
  children: [{
50
58
  key: 'table-size-picker',
51
59
  customLabel: /*#__PURE__*/React.createElement(TableSizePicker, {
@@ -162,6 +170,12 @@ var SlashCommandsList = /*#__PURE__*/forwardRef(function (_ref, ref) {
162
170
  children: [{
163
171
  label: '行内数学公式',
164
172
  key: 'inline-math',
173
+ extra: /*#__PURE__*/React.createElement(Typography, {
174
+ sx: {
175
+ fontSize: '12px',
176
+ color: 'text.disabled'
177
+ }
178
+ }, getShortcutKeyText(['ctrl', '6'], '+')),
165
179
  icon: /*#__PURE__*/React.createElement(SquareRootIcon, {
166
180
  sx: {
167
181
  fontSize: '1rem'
@@ -176,6 +190,12 @@ var SlashCommandsList = /*#__PURE__*/forwardRef(function (_ref, ref) {
176
190
  }, {
177
191
  label: '块级数学公式',
178
192
  key: 'block-math',
193
+ extra: /*#__PURE__*/React.createElement(Typography, {
194
+ sx: {
195
+ fontSize: '12px',
196
+ color: 'text.disabled'
197
+ }
198
+ }, getShortcutKeyText(['ctrl', '7'], '+')),
179
199
  icon: /*#__PURE__*/React.createElement(FunctionsIcon, {
180
200
  sx: {
181
201
  fontSize: '1rem'
@@ -199,6 +219,12 @@ var SlashCommandsList = /*#__PURE__*/forwardRef(function (_ref, ref) {
199
219
  children: [{
200
220
  label: '上传图片',
201
221
  key: 'image',
222
+ extra: /*#__PURE__*/React.createElement(Typography, {
223
+ sx: {
224
+ fontSize: '12px',
225
+ color: 'text.disabled'
226
+ }
227
+ }, getShortcutKeyText(['ctrl', '2'], '+')),
202
228
  icon: /*#__PURE__*/React.createElement(ImageLineIcon, {
203
229
  sx: {
204
230
  fontSize: '1rem'
@@ -213,6 +239,12 @@ var SlashCommandsList = /*#__PURE__*/forwardRef(function (_ref, ref) {
213
239
  }, {
214
240
  label: '上传视频',
215
241
  key: 'video',
242
+ extra: /*#__PURE__*/React.createElement(Typography, {
243
+ sx: {
244
+ fontSize: '12px',
245
+ color: 'text.disabled'
246
+ }
247
+ }, getShortcutKeyText(['ctrl', '3'], '+')),
216
248
  icon: /*#__PURE__*/React.createElement(MovieLineIcon, {
217
249
  sx: {
218
250
  fontSize: '1rem'
@@ -227,6 +259,12 @@ var SlashCommandsList = /*#__PURE__*/forwardRef(function (_ref, ref) {
227
259
  }, {
228
260
  label: '上传音频',
229
261
  key: 'audio',
262
+ extra: /*#__PURE__*/React.createElement(Typography, {
263
+ sx: {
264
+ fontSize: '12px',
265
+ color: 'text.disabled'
266
+ }
267
+ }, getShortcutKeyText(['ctrl', '4'], '+')),
230
268
  icon: /*#__PURE__*/React.createElement(Music2LineIcon, {
231
269
  sx: {
232
270
  fontSize: '1rem'
@@ -241,6 +279,12 @@ var SlashCommandsList = /*#__PURE__*/forwardRef(function (_ref, ref) {
241
279
  }, {
242
280
  label: '上传附件',
243
281
  key: 'attachment',
282
+ extra: /*#__PURE__*/React.createElement(Typography, {
283
+ sx: {
284
+ fontSize: '12px',
285
+ color: 'text.disabled'
286
+ }
287
+ }, getShortcutKeyText(['ctrl', '5'], '+')),
244
288
  icon: /*#__PURE__*/React.createElement(AttachmentLineIcon, {
245
289
  sx: {
246
290
  fontSize: '1rem'
@@ -1,4 +1,4 @@
1
1
  import { UploadFunction } from "../../type";
2
2
  export declare const FileHandlerExtension: (props: {
3
3
  onUpload?: UploadFunction;
4
- }) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "editor" | "key">, any>;
4
+ }) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "key" | "editor">, any>;
@@ -4,8 +4,9 @@ import { SuggestionProps } from '@tiptap/suggestion';
4
4
  export declare const slashSuggestion: () => {
5
5
  items: ({ query }: {
6
6
  query: string;
7
- }) => {
7
+ }) => ({
8
8
  title: string;
9
+ shortcutKey: string[];
9
10
  icon: import("react").JSX.Element;
10
11
  command: ({ editor, range, attrs }: {
11
12
  editor: Editor;
@@ -15,7 +16,19 @@ export declare const slashSuggestion: () => {
15
16
  };
16
17
  attrs: any;
17
18
  }) => void;
18
- }[];
19
+ } | {
20
+ title: string;
21
+ icon: import("react").JSX.Element;
22
+ command: ({ editor, range, attrs }: {
23
+ editor: Editor;
24
+ range: {
25
+ from: number;
26
+ to: number;
27
+ };
28
+ attrs: any;
29
+ }) => void;
30
+ shortcutKey?: undefined;
31
+ })[];
19
32
  decorationTag: string;
20
33
  decorationClass: string;
21
34
  decorationContent: string;
@@ -113,6 +113,7 @@ export interface SlashCommandItem {
113
113
  };
114
114
  }) => void;
115
115
  attrs?: Record<string, unknown>;
116
+ shortcutKey?: string[];
116
117
  children?: SlashCommandItem[];
117
118
  }
118
119
  export interface SlashCommandsListProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",