@ctzhian/tiptap 1.6.2 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/Editor/demo.js +6 -47
  2. package/dist/EditorToolbar/index.js +74 -103
  3. package/dist/component/CustomDragHandle/index.js +57 -47
  4. package/dist/component/Icons/add-circle-fill-icon.d.ts +6 -0
  5. package/dist/component/Icons/add-circle-fill-icon.js +13 -0
  6. package/dist/component/Icons/command-line-icon.d.ts +6 -0
  7. package/dist/component/Icons/command-line-icon.js +13 -0
  8. package/dist/component/Icons/eraser-line-icon.d.ts +6 -0
  9. package/dist/component/Icons/eraser-line-icon.js +13 -0
  10. package/dist/component/Icons/folder-2-line-icon.d.ts +6 -0
  11. package/dist/component/Icons/folder-2-line-icon.js +13 -0
  12. package/dist/component/Icons/index.d.ts +5 -0
  13. package/dist/component/Icons/index.js +5 -0
  14. package/dist/component/Icons/keyboard-line-icon.d.ts +6 -0
  15. package/dist/component/Icons/keyboard-line-icon.js +13 -0
  16. package/dist/component/Menu/NestedList.d.ts +1 -0
  17. package/dist/component/Menu/NestedList.js +11 -5
  18. package/dist/component/Menu/index.js +4 -1
  19. package/dist/component/Toolbar/EditorHeading.js +67 -79
  20. package/dist/component/Toolbar/EditorInsert/index.d.ts +2 -2
  21. package/dist/component/Toolbar/EditorInsert/index.js +414 -178
  22. package/dist/component/Toolbar/EditorMore/index.js +2 -2
  23. package/dist/component/Toolbar/Item.d.ts +1 -1
  24. package/dist/contants/slash-commands.d.ts +15 -2
  25. package/dist/contants/slash-commands.js +21 -6
  26. package/dist/extension/component/SlashCommandsList/index.js +45 -1
  27. package/dist/extension/index.js +1 -1
  28. package/dist/extension/suggestion/slash.d.ts +15 -2
  29. package/dist/type/index.d.ts +3 -0
  30. package/dist/util/shortcutKey.d.ts +1 -1
  31. package/dist/util/shortcutKey.js +2 -1
  32. package/package.json +1 -1
  33. /package/dist/types/{images.d.ts → declare.d.ts} +0 -0
@@ -5,7 +5,6 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
5
5
  import { Editor, EditorThemeProvider, EditorToolbar, useTiptap } from "./..";
6
6
  import { Box } from '@mui/material';
7
7
  import React from 'react';
8
- import { AiGenerate2Icon } from "../component/Icons";
9
8
  import "../index.css";
10
9
  var Reader = function Reader() {
11
10
  var _useTiptap = useTiptap({
@@ -15,17 +14,13 @@ var Reader = function Reader() {
15
14
  console.log(editor.getHTML());
16
15
  editor.commands.setContent(editor.getHTML());
17
16
  },
18
- onCreate: function onCreate(_ref) {
19
- var currentEditor = _ref.editor;
20
- currentEditor.commands.setAiWriting(true);
21
- },
22
17
  onAiWritingGetSuggestion: function () {
23
- var _onAiWritingGetSuggestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
18
+ var _onAiWritingGetSuggestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
24
19
  var prefix, suffix;
25
20
  return _regeneratorRuntime().wrap(function _callee$(_context) {
26
21
  while (1) switch (_context.prev = _context.next) {
27
22
  case 0:
28
- prefix = _ref2.prefix, suffix = _ref2.suffix;
23
+ prefix = _ref.prefix, suffix = _ref.suffix;
29
24
  console.log('onAiWritingGetSuggestion', prefix, suffix);
30
25
  return _context.abrupt("return", new Promise(function (resolve) {
31
26
  resolve(['this is a default suggestion.', 'we are good.', 'what is your name?', 'how are you?', 'what is your favorite color?', 'what is your favorite food?', 'what is your favorite animal?', 'what is your favorite book?', 'what is your favorite movie?', 'what is your favorite song?', 'what is your favorite artist?', 'what is your favorite band?', 'what is your favorite city?', 'what is your favorite country?', 'what is your favorite sport?'][Math.floor(Math.random() * 10)]);
@@ -43,12 +38,12 @@ var Reader = function Reader() {
43
38
  }(),
44
39
  // onTocUpdate: handleTocUpdate,
45
40
  onMentionFilter: function () {
46
- var _onMentionFilter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
41
+ var _onMentionFilter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
47
42
  var query;
48
43
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
49
44
  while (1) switch (_context2.prev = _context2.next) {
50
45
  case 0:
51
- query = _ref3.query;
46
+ query = _ref2.query;
52
47
  return _context2.abrupt("return", new Promise(function (resolve) {
53
48
  resolve(['Winona Ryder', 'Molly Ringwald', 'Ally Sheedy', 'Debbie Harry', 'Olivia Newton-John', 'Elton John', 'Michael J. Fox', 'Axl Rose', 'Emilio Estevez', 'Ralph Macchio', 'Rob Lowe', 'Jennifer Grey'].filter(function (item) {
54
49
  return item.toLowerCase().startsWith(query.toLowerCase());
@@ -125,19 +120,7 @@ var Reader = function Reader() {
125
120
  marginBottom: '30px'
126
121
  }
127
122
  }, /*#__PURE__*/React.createElement(EditorToolbar, {
128
- editor: editor,
129
- menuInToolbarMore: [{
130
- id: 'ai',
131
- icon: /*#__PURE__*/React.createElement(AiGenerate2Icon, {
132
- sx: {
133
- fontSize: '1rem'
134
- }
135
- }),
136
- onClick: function onClick() {
137
- alert('ai');
138
- },
139
- label: 'AI 文本润色'
140
- }]
123
+ editor: editor
141
124
  })), /*#__PURE__*/React.createElement(Box, {
142
125
  sx: {
143
126
  '.tiptap': {
@@ -149,31 +132,7 @@ var Reader = function Reader() {
149
132
  }
150
133
  }
151
134
  }, /*#__PURE__*/React.createElement(Editor, {
152
- editor: editor,
153
- menuInDragHandle: [{
154
- label: '文本润色',
155
- key: 'ai',
156
- icon: /*#__PURE__*/React.createElement(AiGenerate2Icon, {
157
- sx: {
158
- fontSize: '1rem'
159
- }
160
- }),
161
- onClick: function onClick() {
162
- alert('ai');
163
- }
164
- }],
165
- menuInBubbleMenu: [{
166
- label: '文本润色',
167
- key: 'ai',
168
- icon: /*#__PURE__*/React.createElement(AiGenerate2Icon, {
169
- sx: {
170
- fontSize: '1rem'
171
- }
172
- }),
173
- onClick: function onClick() {
174
- alert('ai');
175
- }
176
- }]
135
+ editor: editor
177
136
  }))));
178
137
  };
179
138
  export default Reader;
@@ -6,15 +6,15 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { Box, Divider, Stack } from '@mui/material';
8
8
  import React, { useEffect, useState } from 'react';
9
- import { ArrowGoBackLineIcon, ArrowGoForwardLineIcon, BoldIcon, DoubleQuotesLIcon, Information2LineIcon, ItalicIcon, LinkIcon, MenuFold2FillIcon, StrikethroughIcon, Table2Icon, UnderlineIcon, WindowFillIcon } from "../component/Icons";
10
- import { EditorAlignSelect, EditorCode, EditorFontBgColor, EditorFontColor, EditorFontSize, EditorHeading, EditorInsert, EditorListSelect, EditorMath, EditorMore, EditorScript, EditorVerticalAlignSelect, ToolbarItem } from "../component/Toolbar";
11
- import TableSizePicker from "../component/Toolbar/TableSizePicker";
9
+ import { AiGenerate2Icon, ArrowGoBackLineIcon, ArrowGoForwardLineIcon, BoldIcon, EraserLineIcon, ItalicIcon, LinkIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, UnderlineIcon } from "../component/Icons";
10
+ import { EditorAlignSelect, EditorFontBgColor, EditorFontColor, EditorFontSize, EditorHeading, EditorInsert, EditorListSelect, EditorMore, EditorVerticalAlignSelect, ToolbarItem } from "../component/Toolbar";
12
11
  var EditorToolbar = function EditorToolbar(_ref) {
13
12
  var editor = _ref.editor,
14
13
  menuInToolbarMore = _ref.menuInToolbarMore;
15
14
  var _useState = useState({
16
15
  undo: false,
17
16
  redo: false,
17
+ format: false,
18
18
  quote: false,
19
19
  bold: false,
20
20
  italic: false,
@@ -26,15 +26,18 @@ var EditorToolbar = function EditorToolbar(_ref) {
26
26
  table: false,
27
27
  link: false,
28
28
  alert: false,
29
- iframe: false
29
+ iframe: false,
30
+ aiWriting: false
30
31
  }),
31
32
  _useState2 = _slicedToArray(_useState, 2),
32
33
  active = _useState2[0],
33
34
  setActive = _useState2[1];
34
35
  var updateSelection = function updateSelection() {
36
+ var _editor$can$chain$und, _editor$can$chain$red, _editor$can$chain$uns;
35
37
  setActive({
36
- undo: editor.can().undo(),
37
- 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,
38
41
  quote: editor.isActive('blockquote'),
39
42
  bold: editor.isActive('bold'),
40
43
  italic: editor.isActive('italic'),
@@ -46,7 +49,8 @@ var EditorToolbar = function EditorToolbar(_ref) {
46
49
  table: editor.isActive('table'),
47
50
  link: editor.isActive('link'),
48
51
  alert: editor.isActive('alert'),
49
- iframe: editor.isActive('iframe')
52
+ iframe: editor.isActive('iframe'),
53
+ aiWriting: editor.storage.aiWriting.enabled
50
54
  });
51
55
  };
52
56
  useEffect(function () {
@@ -90,7 +94,30 @@ var EditorToolbar = function EditorToolbar(_ref) {
90
94
  }
91
95
  }
92
96
  }
93
- }, /*#__PURE__*/React.createElement(ToolbarItem, {
97
+ }, /*#__PURE__*/React.createElement(EditorInsert, {
98
+ editor: editor
99
+ }), editor.options.extensions.find(function (it) {
100
+ return it.name === 'aiWriting';
101
+ }) && /*#__PURE__*/React.createElement(ToolbarItem, {
102
+ text: 'AI 伴写',
103
+ icon: /*#__PURE__*/React.createElement(AiGenerate2Icon, {
104
+ sx: {
105
+ fontSize: '1rem'
106
+ }
107
+ }),
108
+ onClick: function onClick() {
109
+ return editor.chain().focus().setAiWriting(!active.aiWriting).run();
110
+ },
111
+ className: active.aiWriting ? 'tool-active' : ''
112
+ }), /*#__PURE__*/React.createElement(Divider, {
113
+ orientation: "vertical",
114
+ flexItem: true,
115
+ sx: {
116
+ mx: 0.5,
117
+ height: 20,
118
+ alignSelf: 'center'
119
+ }
120
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
94
121
  tip: '撤销',
95
122
  shortcutKey: ['ctrl', 'Z'],
96
123
  icon: /*#__PURE__*/React.createElement(ArrowGoBackLineIcon, {
@@ -114,6 +141,17 @@ var EditorToolbar = function EditorToolbar(_ref) {
114
141
  return editor.chain().focus().redo().run();
115
142
  },
116
143
  disabled: !active.redo
144
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
145
+ tip: '清除格式',
146
+ icon: /*#__PURE__*/React.createElement(EraserLineIcon, {
147
+ sx: {
148
+ fontSize: '1rem'
149
+ }
150
+ }),
151
+ disabled: !active.format,
152
+ onClick: function onClick() {
153
+ return editor.chain().focus().unsetAllMarks().run();
154
+ }
117
155
  }), /*#__PURE__*/React.createElement(Divider, {
118
156
  orientation: "vertical",
119
157
  flexItem: true,
@@ -126,38 +164,6 @@ var EditorToolbar = function EditorToolbar(_ref) {
126
164
  editor: editor
127
165
  }), /*#__PURE__*/React.createElement(EditorFontSize, {
128
166
  editor: editor
129
- }), /*#__PURE__*/React.createElement(EditorListSelect, {
130
- editor: editor
131
- }), /*#__PURE__*/React.createElement(EditorAlignSelect, {
132
- editor: editor
133
- }), /*#__PURE__*/React.createElement(EditorVerticalAlignSelect, {
134
- editor: editor
135
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
136
- tip: '引用块',
137
- shortcutKey: ['ctrl', 'shift', 'B'],
138
- icon: /*#__PURE__*/React.createElement(DoubleQuotesLIcon, {
139
- sx: {
140
- fontSize: '1rem'
141
- }
142
- }),
143
- onClick: function onClick() {
144
- return editor.chain().focus().toggleBlockquote().run();
145
- },
146
- className: active.quote ? 'tool-active' : ''
147
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
148
- tip: '警告提示',
149
- icon: /*#__PURE__*/React.createElement(Information2LineIcon, {
150
- sx: {
151
- fontSize: '1rem'
152
- }
153
- }),
154
- onClick: function onClick() {
155
- return editor.chain().focus().toggleAlert({
156
- type: 'icon',
157
- variant: 'info'
158
- }).run();
159
- },
160
- className: active.alert ? 'tool-active' : ''
161
167
  }), /*#__PURE__*/React.createElement(Divider, {
162
168
  orientation: "vertical",
163
169
  flexItem: true,
@@ -214,16 +220,30 @@ var EditorToolbar = function EditorToolbar(_ref) {
214
220
  return editor.chain().focus().toggleUnderline().run();
215
221
  },
216
222
  className: active.underline ? 'tool-active' : ''
217
- }), /*#__PURE__*/React.createElement(Divider, {
218
- orientation: "vertical",
219
- flexItem: true,
220
- sx: {
221
- mx: 0.5,
222
- height: 20,
223
- alignSelf: 'center'
224
- }
225
- }), /*#__PURE__*/React.createElement(EditorScript, {
226
- editor: editor
223
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
224
+ tip: '上标',
225
+ shortcutKey: ['ctrl', '.'],
226
+ icon: /*#__PURE__*/React.createElement(SuperscriptIcon, {
227
+ sx: {
228
+ fontSize: '1rem'
229
+ }
230
+ }),
231
+ onClick: function onClick() {
232
+ return editor.chain().focus().toggleSuperscript().run();
233
+ },
234
+ className: active.superscript ? 'tool-active' : ''
235
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
236
+ tip: '下标',
237
+ shortcutKey: ['ctrl', ','],
238
+ icon: /*#__PURE__*/React.createElement(SubscriptIcon, {
239
+ sx: {
240
+ fontSize: '1rem'
241
+ }
242
+ }),
243
+ onClick: function onClick() {
244
+ return editor.chain().focus().toggleSubscript().run();
245
+ },
246
+ className: active.subscript ? 'tool-active' : ''
227
247
  }), /*#__PURE__*/React.createElement(EditorFontColor, {
228
248
  editor: editor
229
249
  }), /*#__PURE__*/React.createElement(EditorFontBgColor, {
@@ -236,6 +256,8 @@ var EditorToolbar = function EditorToolbar(_ref) {
236
256
  height: 20,
237
257
  alignSelf: 'center'
238
258
  }
259
+ }), /*#__PURE__*/React.createElement(EditorListSelect, {
260
+ editor: editor
239
261
  }), /*#__PURE__*/React.createElement(ToolbarItem, {
240
262
  tip: '链接',
241
263
  shortcutKey: ['ctrl', '1'],
@@ -255,59 +277,10 @@ var EditorToolbar = function EditorToolbar(_ref) {
255
277
  }).run();
256
278
  },
257
279
  className: active.link ? 'tool-active' : ''
258
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
259
- tip: '折叠块',
260
- shortcutKey: ['ctrl', '8'],
261
- icon: /*#__PURE__*/React.createElement(MenuFold2FillIcon, {
262
- sx: {
263
- fontSize: '1rem'
264
- }
265
- }),
266
- onClick: function onClick() {
267
- if (!active.details) {
268
- editor.chain().focus().setDetails().run();
269
- } else {
270
- editor.chain().focus().unsetDetails().run();
271
- }
272
- },
273
- className: active.details ? 'tool-active' : ''
274
- }), /*#__PURE__*/React.createElement(EditorCode, {
280
+ }), /*#__PURE__*/React.createElement(EditorAlignSelect, {
275
281
  editor: editor
276
- }), /*#__PURE__*/React.createElement(EditorMath, {
282
+ }), /*#__PURE__*/React.createElement(EditorVerticalAlignSelect, {
277
283
  editor: editor
278
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
279
- tip: '表格',
280
- shortcutKey: ['ctrl', '9'],
281
- icon: /*#__PURE__*/React.createElement(Table2Icon, {
282
- sx: {
283
- fontSize: '1rem'
284
- }
285
- }),
286
- className: active.table ? 'tool-active' : '',
287
- customComponent: /*#__PURE__*/React.createElement(TableSizePicker, {
288
- onConfirm: function onConfirm(cols, rows) {
289
- editor.chain().focus().insertTable({
290
- rows: rows,
291
- cols: cols,
292
- withHeaderRow: true
293
- }).run();
294
- }
295
- })
296
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
297
- tip: 'iframe',
298
- icon: /*#__PURE__*/React.createElement(WindowFillIcon, {
299
- sx: {
300
- fontSize: '1rem'
301
- }
302
- }),
303
- onClick: function onClick() {
304
- return editor.commands.setIframe({
305
- src: '',
306
- width: 760,
307
- height: 400
308
- });
309
- },
310
- className: active.iframe ? 'tool-active' : ''
311
284
  }), /*#__PURE__*/React.createElement(Divider, {
312
285
  orientation: "vertical",
313
286
  flexItem: true,
@@ -316,8 +289,6 @@ var EditorToolbar = function EditorToolbar(_ref) {
316
289
  height: 20,
317
290
  alignSelf: 'center'
318
291
  }
319
- }), /*#__PURE__*/React.createElement(EditorInsert, {
320
- editor: editor
321
292
  }), /*#__PURE__*/React.createElement(EditorMore, {
322
293
  more: menuInToolbarMore
323
294
  })));
@@ -17,15 +17,14 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
17
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; }
18
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; } }
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
- import { AddLineIcon, AlignBottomIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, AlignTopIcon, ArrowDownSLineIcon, AttachmentLineIcon, BrushLineIcon, DeleteLineIcon, DownloadLineIcon, DraggableIcon, FontSizeIcon, FormatClearIcon, H1Icon, H2Icon, H3Icon, ImageLineIcon, IndentDecreaseIcon, IndentIncreaseIcon, Information2LineIcon, ListCheck3Icon, ListOrdered2Icon, ListUnorderedIcon, MovieLineIcon, Music2LineIcon, QuoteTextIcon, Repeat2LineIcon, ScissorsCutLineIcon, SeparatorIcon, TextIcon, TextWrapIcon } from "../Icons";
20
+ import { AddLineIcon, AlignBottomIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, AlignTopIcon, ArrowDownSLineIcon, AttachmentLineIcon, BrushLineIcon, DeleteLineIcon, DownloadLineIcon, DraggableIcon, EraserLineIcon, FileCopyLineIcon, FontSizeIcon, H1Icon, H2Icon, H3Icon, ImageLineIcon, IndentDecreaseIcon, IndentIncreaseIcon, Information2LineIcon, ListCheck3Icon, ListOrdered2Icon, ListUnorderedIcon, MovieLineIcon, Music2LineIcon, QuoteTextIcon, Repeat2LineIcon, ScissorsCutLineIcon, SeparatorIcon, TextIcon, TextWrapIcon } from "../Icons";
21
21
  import { NODE_TYPE_LABEL, NodeTypeEnum } from "../../contants/enums";
22
22
  import { Box, Divider, Stack, Typography, useTheme } from '@mui/material';
23
23
  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";
28
- import { FileCopyLineIcon } from "../Icons/file-copy-line-icon";
27
+ import { convertNodeAt, downloadFiles, filterResourcesByType, getAllResources, getShortcutKeyText } from "../../util";
29
28
  import Menu from "../Menu";
30
29
  import { ToolbarItem } from "../Toolbar";
31
30
  var DragIcon = function DragIcon(_ref) {
@@ -259,7 +258,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
259
258
  var updateNodeChange = useCallback(function (data) {
260
259
  var _data$node, _current$node2;
261
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) {
262
- var _data$node2;
261
+ var _data$node2, _editor$can$chain$uns;
263
262
  var allResources = data.node ? getAllResources(data.node) : [];
264
263
  var videos = filterResourcesByType(allResources, [NodeTypeEnum.Video]);
265
264
  var audios = filterResourcesByType(allResources, [NodeTypeEnum.Audio]);
@@ -273,10 +272,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
273
272
  images: images,
274
273
  attachments: attachments
275
274
  });
276
- setShowFormat(shouldShowButton({
277
- editor: editor,
278
- data: data
279
- }));
275
+ setShowFormat((_editor$can$chain$uns = editor.can().chain().unsetAllMarks().run()) !== null && _editor$can$chain$uns !== void 0 ? _editor$can$chain$uns : false);
280
276
  }
281
277
  }, [current.pos, current.node]);
282
278
  return /*#__PURE__*/React.createElement(DragHandle, {
@@ -314,6 +310,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
314
310
  }
315
311
  }
316
312
  }), currentNode ? /*#__PURE__*/React.createElement(Menu, {
313
+ width: 224,
317
314
  context: /*#__PURE__*/React.createElement(DragIcon, null),
318
315
  anchorOrigin: {
319
316
  vertical: 'bottom',
@@ -569,6 +566,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
569
566
  key: 'color',
570
567
  label: '颜色',
571
568
  maxHeight: 400,
569
+ width: 160,
572
570
  icon: /*#__PURE__*/React.createElement(BrushLineIcon, {
573
571
  sx: {
574
572
  fontSize: '1rem'
@@ -654,6 +652,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
654
652
  fontSize: '1rem'
655
653
  }
656
654
  }),
655
+ width: 100,
657
656
  minWidth: 100,
658
657
  maxHeight: 200,
659
658
  children: _toConsumableArray([10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60].map(function (it) {
@@ -695,6 +694,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
695
694
  key: 'align-horizontal'
696
695
  }, {
697
696
  label: '左侧对齐',
697
+ extra: /*#__PURE__*/React.createElement(Typography, {
698
+ sx: {
699
+ fontSize: '12px',
700
+ color: 'text.disabled'
701
+ }
702
+ }, getShortcutKeyText(['ctrl', 'shift', 'L'], '+')),
698
703
  key: 'align-horizontal-left',
699
704
  icon: /*#__PURE__*/React.createElement(AlignLeftIcon, {
700
705
  sx: {
@@ -713,6 +718,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
713
718
  }
714
719
  }, {
715
720
  label: '居中对齐',
721
+ extra: /*#__PURE__*/React.createElement(Typography, {
722
+ sx: {
723
+ fontSize: '12px',
724
+ color: 'text.disabled'
725
+ }
726
+ }, getShortcutKeyText(['ctrl', 'shift', 'E'], '+')),
716
727
  key: 'align-horizontal-center',
717
728
  icon: /*#__PURE__*/React.createElement(AlignCenterIcon, {
718
729
  sx: {
@@ -731,6 +742,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
731
742
  }
732
743
  }, {
733
744
  label: '右侧对齐',
745
+ extra: /*#__PURE__*/React.createElement(Typography, {
746
+ sx: {
747
+ fontSize: '12px',
748
+ color: 'text.disabled'
749
+ }
750
+ }, getShortcutKeyText(['ctrl', 'shift', 'R'], '+')),
734
751
  key: 'align-horizontal-right',
735
752
  icon: /*#__PURE__*/React.createElement(AlignRightIcon, {
736
753
  sx: {
@@ -749,6 +766,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
749
766
  }
750
767
  }, {
751
768
  label: '两端对齐',
769
+ extra: /*#__PURE__*/React.createElement(Typography, {
770
+ sx: {
771
+ fontSize: '12px',
772
+ color: 'text.disabled'
773
+ }
774
+ }, getShortcutKeyText(['ctrl', 'shift', 'J'], '+')),
752
775
  key: 'align-horizontal-justify',
753
776
  icon: /*#__PURE__*/React.createElement(AlignJustifyIcon, {
754
777
  sx: {
@@ -777,6 +800,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
777
800
  key: 'align-vertical'
778
801
  }, {
779
802
  label: '顶部对齐',
803
+ extra: /*#__PURE__*/React.createElement(Typography, {
804
+ sx: {
805
+ fontSize: '12px',
806
+ color: 'text.disabled'
807
+ }
808
+ }, getShortcutKeyText(['ctrl', 'alt', 'T'], '+')),
780
809
  key: 'align-vertical-top',
781
810
  icon: /*#__PURE__*/React.createElement(AlignTopIcon, {
782
811
  sx: {
@@ -795,6 +824,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
795
824
  }
796
825
  }, {
797
826
  label: '居中对齐',
827
+ extra: /*#__PURE__*/React.createElement(Typography, {
828
+ sx: {
829
+ fontSize: '12px',
830
+ color: 'text.disabled'
831
+ }
832
+ }, getShortcutKeyText(['ctrl', 'alt', 'M'], '+')),
798
833
  key: 'align-vertical-center',
799
834
  icon: /*#__PURE__*/React.createElement(AlignCenterIcon, {
800
835
  sx: {
@@ -813,6 +848,12 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
813
848
  }
814
849
  }, {
815
850
  label: '底部对齐',
851
+ extra: /*#__PURE__*/React.createElement(Typography, {
852
+ sx: {
853
+ fontSize: '12px',
854
+ color: 'text.disabled'
855
+ }
856
+ }, getShortcutKeyText(['ctrl', 'alt', 'B'], '+')),
816
857
  key: 'align-vertical-bottom',
817
858
  icon: /*#__PURE__*/React.createElement(AlignBottomIcon, {
818
859
  sx: {
@@ -833,6 +874,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
833
874
  }] : []), _toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.convert ? [{
834
875
  label: '转换',
835
876
  key: 'convert',
877
+ width: 160,
836
878
  maxHeight: 400,
837
879
  icon: /*#__PURE__*/React.createElement(Repeat2LineIcon, {
838
880
  sx: {
@@ -863,7 +905,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
863
905
  }
864
906
  }
865
907
  }, {
866
- label: '一级标题',
908
+ label: '标题1',
867
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,
868
910
  key: 'convert-to-heading-1',
869
911
  icon: /*#__PURE__*/React.createElement(H1Icon, {
@@ -889,7 +931,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
889
931
  }
890
932
  }
891
933
  }, {
892
- label: '二级标题',
934
+ label: '标题2',
893
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,
894
936
  key: 'convert-to-heading-2',
895
937
  icon: /*#__PURE__*/React.createElement(H2Icon, {
@@ -915,7 +957,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
915
957
  }
916
958
  }
917
959
  }, {
918
- label: '三级标题',
960
+ label: '标题3',
919
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,
920
962
  key: 'convert-to-heading-3',
921
963
  icon: /*#__PURE__*/React.createElement(H3Icon, {
@@ -1361,46 +1403,14 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
1361
1403
  }] : []))), _toConsumableArray(more ? more : []), _toConsumableArray(showFormat ? [{
1362
1404
  label: '文本格式化',
1363
1405
  key: 'format',
1364
- icon: /*#__PURE__*/React.createElement(FormatClearIcon, {
1406
+ icon: /*#__PURE__*/React.createElement(EraserLineIcon, {
1365
1407
  sx: {
1366
1408
  fontSize: '1rem'
1367
1409
  }
1368
1410
  }),
1369
- onClick: function () {
1370
- var _onClick6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1371
- var tr, _currentNode, empty, content;
1372
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1373
- while (1) switch (_context8.prev = _context8.next) {
1374
- case 0:
1375
- if (current.node && current.pos !== undefined) {
1376
- tr = current.editor.state.tr;
1377
- _currentNode = current.node;
1378
- empty = (_currentNode === null || _currentNode === void 0 ? void 0 : _currentNode.textContent) === '';
1379
- if (!empty) {
1380
- content = _currentNode === null || _currentNode === void 0 ? void 0 : _currentNode.content.content;
1381
- if (content && content.length > 0) {
1382
- tr.doc.nodesBetween(current.pos, current.pos + current.node.nodeSize, function (node, pos) {
1383
- if (!node.isInline) return true;
1384
- node.marks.forEach(function (mark) {
1385
- tr.removeMark(pos, pos + node.nodeSize, mark.type);
1386
- });
1387
- return true;
1388
- });
1389
- }
1390
- }
1391
- editor.view.dispatch(tr);
1392
- }
1393
- case 1:
1394
- case "end":
1395
- return _context8.stop();
1396
- }
1397
- }, _callee8);
1398
- }));
1399
- function onClick() {
1400
- return _onClick6.apply(this, arguments);
1401
- }
1402
- return onClick;
1403
- }()
1411
+ onClick: function onClick() {
1412
+ current.editor.chain().focus().unsetAllMarks().run();
1413
+ }
1404
1414
  }] : []))
1405
1415
  }) : /*#__PURE__*/React.createElement(DragIcon, null)));
1406
1416
  };
@@ -0,0 +1,6 @@
1
+ import { SvgIconProps } from "@mui/material";
2
+ import * as React from "react";
3
+ export declare const AddCircleFillIcon: {
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 AddCircleFillIcon = function AddCircleFillIcon(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: "M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM11 11H7V13H11V17H13V13H17V11H13V7H11V11Z"
11
+ }));
12
+ };
13
+ AddCircleFillIcon.displayName = 'icon-add-circle-fill';
@@ -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';
@@ -0,0 +1,6 @@
1
+ import { SvgIconProps } from "@mui/material";
2
+ import * as React from "react";
3
+ export declare const EraserLineIcon: {
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 EraserLineIcon = function EraserLineIcon(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: "M8.58564 8.85449L3.63589 13.8042L8.83021 18.9985L9.99985 18.9978V18.9966H11.1714L14.9496 15.2184L8.58564 8.85449ZM9.99985 7.44027L16.3638 13.8042L19.1922 10.9758L12.8283 4.61185L9.99985 7.44027ZM13.9999 18.9966H20.9999V20.9966H11.9999L8.00229 20.9991L1.51457 14.5113C1.12405 14.1208 1.12405 13.4877 1.51457 13.0971L12.1212 2.49053C12.5117 2.1 13.1449 2.1 13.5354 2.49053L21.3136 10.2687C21.7041 10.6592 21.7041 11.2924 21.3136 11.6829L13.9999 18.9966Z"
11
+ }));
12
+ };
13
+ EraserLineIcon.displayName = 'icon-eraser-line';
@@ -0,0 +1,6 @@
1
+ import { SvgIconProps } from "@mui/material";
2
+ import * as React from "react";
3
+ export declare const Folder2LineIcon: {
4
+ (props: SvgIconProps): React.JSX.Element;
5
+ displayName: string;
6
+ };