@ctzhian/tiptap 1.12.20 → 1.12.23

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.
@@ -97,10 +97,7 @@ var CustomBubbleMenu = function CustomBubbleMenu(_ref) {
97
97
  }, /*#__PURE__*/React.createElement(Stack, {
98
98
  direction: 'row',
99
99
  alignItems: 'center'
100
- }, /*#__PURE__*/React.createElement(ToolbarItem
101
- // tip='加粗'
102
- // shortcutKey={['ctrl', 'B']}
103
- , {
100
+ }, /*#__PURE__*/React.createElement(ToolbarItem, {
104
101
  icon: /*#__PURE__*/React.createElement(BoldIcon, {
105
102
  sx: {
106
103
  fontSize: '1rem'
@@ -110,10 +107,7 @@ var CustomBubbleMenu = function CustomBubbleMenu(_ref) {
110
107
  return editor.chain().focus().toggleBold().run();
111
108
  },
112
109
  className: isBold ? "tool-active" : ""
113
- }), /*#__PURE__*/React.createElement(ToolbarItem
114
- // tip='斜体'
115
- // shortcutKey={['ctrl', 'I']}
116
- , {
110
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
117
111
  icon: /*#__PURE__*/React.createElement(ItalicIcon, {
118
112
  sx: {
119
113
  fontSize: '1rem'
@@ -123,10 +117,7 @@ var CustomBubbleMenu = function CustomBubbleMenu(_ref) {
123
117
  return editor.chain().focus().toggleItalic().run();
124
118
  },
125
119
  className: isItalic ? "tool-active" : ""
126
- }), /*#__PURE__*/React.createElement(ToolbarItem
127
- // tip='删除线'
128
- // shortcutKey={['ctrl', 'shift', 'S']}
129
- , {
120
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
130
121
  icon: /*#__PURE__*/React.createElement(StrikethroughIcon, {
131
122
  sx: {
132
123
  fontSize: '1rem'
@@ -136,10 +127,7 @@ var CustomBubbleMenu = function CustomBubbleMenu(_ref) {
136
127
  return editor.chain().focus().toggleStrike().run();
137
128
  },
138
129
  className: isStrike ? "tool-active" : ""
139
- }), /*#__PURE__*/React.createElement(ToolbarItem
140
- // tip='下划线'
141
- // shortcutKey={['ctrl', 'U']}
142
- , {
130
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
143
131
  icon: /*#__PURE__*/React.createElement(UnderlineIcon, {
144
132
  sx: {
145
133
  fontSize: '1rem'
@@ -149,10 +137,7 @@ var CustomBubbleMenu = function CustomBubbleMenu(_ref) {
149
137
  return editor.chain().focus().toggleUnderline().run();
150
138
  },
151
139
  className: isUnderline ? "tool-active" : ""
152
- }), /*#__PURE__*/React.createElement(ToolbarItem
153
- // tip='高亮'
154
- // shortcutKey={['ctrl', 'shift', 'H']}
155
- , {
140
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
156
141
  icon: /*#__PURE__*/React.createElement(MarkPenLineIcon, {
157
142
  sx: {
158
143
  fontSize: '1rem'
@@ -162,10 +147,7 @@ var CustomBubbleMenu = function CustomBubbleMenu(_ref) {
162
147
  return editor.chain().focus().toggleHighlight().run();
163
148
  },
164
149
  className: isHighlight ? "tool-active" : ""
165
- }), /*#__PURE__*/React.createElement(ToolbarItem
166
- // tip='行内代码'
167
- // shortcutKey={['ctrl', 'E']}
168
- , {
150
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
169
151
  icon: /*#__PURE__*/React.createElement(CodeLineIcon, {
170
152
  sx: {
171
153
  fontSize: '1rem'
@@ -183,14 +165,13 @@ var CustomBubbleMenu = function CustomBubbleMenu(_ref) {
183
165
  height: 20,
184
166
  alignSelf: 'center'
185
167
  }
186
- }), /*#__PURE__*/React.createElement(ToolbarItem
187
- // tip='文本格式化'
188
- , {
168
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
189
169
  icon: /*#__PURE__*/React.createElement(EraserLineIcon, {
190
170
  sx: {
191
171
  fontSize: '1rem'
192
172
  }
193
173
  }),
174
+ text: "\u6E05\u9664\u683C\u5F0F",
194
175
  onClick: function onClick() {
195
176
  return editor.chain().focus().unsetAllMarks().run();
196
177
  },
@@ -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, EraserLineIcon, FileCopyLineIcon, FontSizeIcon, 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, 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
- import { useEditorState } from '@tiptap/react';
27
26
  import React, { useCallback, useState } from 'react';
28
- import { convertNodeAt, downloadFiles, filterResourcesByType, getAllResources, getShortcutKeyText, hasMarksInSelection } from "../../util";
27
+ import { convertNodeAt, downloadFiles, filterResourcesByType, getAllResources, getShortcutKeyText, hasMarksInBlock } from "../../util";
29
28
  import Menu from "../Menu";
30
29
  import { ToolbarItem } from "../Toolbar";
31
30
  var DragIcon = function DragIcon(_ref) {
@@ -93,7 +92,7 @@ var AddIcon = function AddIcon(_ref2) {
93
92
  }));
94
93
  };
95
94
  var CustomDragHandle = function CustomDragHandle(_ref3) {
96
- var _current$node3, _current$node4, _current$node5, _current$node6, _current$node7, _current$node8, _current$node9, _current$node10, _current$node11, _current$node12, _current$node13, _current$node14, _current$node15, _current$node16;
95
+ var _current$node4, _current$node5, _current$node6, _current$node7, _current$node8, _current$node9, _current$node10, _current$node11, _current$node12, _current$node13, _current$node14, _current$node15, _current$node16, _current$node17;
97
96
  var editor = _ref3.editor,
98
97
  more = _ref3.more,
99
98
  onTip = _ref3.onTip;
@@ -119,6 +118,10 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
119
118
  _useState6 = _slicedToArray(_useState5, 2),
120
119
  currentNode = _useState6[0],
121
120
  setCurrentNode = _useState6[1];
121
+ var _useState7 = useState(false),
122
+ _useState8 = _slicedToArray(_useState7, 2),
123
+ hasMarks = _useState8[0],
124
+ setHasMarks = _useState8[1];
122
125
  var THEME_TEXT_COLOR = [{
123
126
  label: '默认色',
124
127
  value: theme.palette.text.primary
@@ -218,16 +221,6 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
218
221
  view.focus();
219
222
  }
220
223
  };
221
- var hasMarksDeep = function hasMarksDeep(node) {
222
- var _content;
223
- if (!node) return false;
224
- if (node.marks && node.marks.length > 0) return true;
225
- var children = (_content = node.content) === null || _content === void 0 ? void 0 : _content.content;
226
- if (!children || children.length === 0) return false;
227
- return children.some(function (child) {
228
- return hasMarksDeep(child);
229
- });
230
- };
231
224
  var canCurrentNodeIndent = function canCurrentNodeIndent() {
232
225
  return !!(current.node && current.node.type);
233
226
  };
@@ -254,17 +247,11 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
254
247
  images: images,
255
248
  attachments: attachments
256
249
  });
250
+ if (data.node) {
251
+ setHasMarks(hasMarksInBlock(data.node));
252
+ }
257
253
  }
258
254
  }, [current.pos, current.node]);
259
- var _useEditorState = useEditorState({
260
- editor: editor,
261
- selector: function selector(ctx) {
262
- return {
263
- hasMarks: hasMarksInSelection(ctx.editor.state)
264
- };
265
- }
266
- }),
267
- hasMarks = _useEditorState.hasMarks;
268
255
  return /*#__PURE__*/React.createElement(DragHandle, {
269
256
  editor: editor,
270
257
  onNodeChange: updateNodeChange
@@ -353,7 +340,14 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
353
340
  transform: 'rotate(-90deg)'
354
341
  }
355
342
  }),
356
- header: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Stack, {
343
+ header: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
344
+ sx: {
345
+ p: 1,
346
+ fontSize: '0.75rem',
347
+ color: 'text.secondary',
348
+ fontWeight: 'bold'
349
+ }
350
+ }, currentNode === null || currentNode === void 0 ? void 0 : currentNode.label), /*#__PURE__*/React.createElement(Stack, {
357
351
  direction: 'row',
358
352
  flexWrap: 'wrap',
359
353
  sx: {
@@ -394,18 +388,26 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
394
388
  tip: '增加缩进',
395
389
  disabled: !canCurrentNodeIndent()
396
390
  }), /*#__PURE__*/React.createElement(ToolbarItem, {
397
- key: 'insert-divider',
391
+ key: 'format',
392
+ disabled: !hasMarks,
398
393
  onClick: function onClick() {
399
394
  if (current.node && current.pos !== undefined) {
400
- current.editor.chain().focus().setHorizontalRule().run();
395
+ var _current$node3;
396
+ var selection = current.editor.commands.setTextSelection({
397
+ from: current.pos,
398
+ to: current.pos + ((_current$node3 = current.node) === null || _current$node3 === void 0 ? void 0 : _current$node3.nodeSize)
399
+ });
400
+ if (selection) {
401
+ current.editor.chain().unsetAllMarks().focus(current.pos - 1).run();
402
+ }
401
403
  }
402
404
  },
403
- icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
405
+ icon: /*#__PURE__*/React.createElement(EraserLineIcon, {
404
406
  sx: {
405
407
  fontSize: '1rem'
406
408
  }
407
409
  }),
408
- tip: '分割线'
410
+ tip: '清除格式'
409
411
  }), /*#__PURE__*/React.createElement(ToolbarItem, {
410
412
  key: 'copy',
411
413
  onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -535,17 +537,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
535
537
  my: 0.5
536
538
  }
537
539
  })),
538
- list: [{
539
- customLabel: /*#__PURE__*/React.createElement(Typography, {
540
- sx: {
541
- p: 1,
542
- fontSize: '0.75rem',
543
- color: 'text.secondary',
544
- fontWeight: 'bold'
545
- }
546
- }, currentNode === null || currentNode === void 0 ? void 0 : currentNode.label),
547
- key: 'current-node'
548
- }].concat(_toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.color ? [{
540
+ list: [].concat(_toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.color ? [{
549
541
  key: 'color',
550
542
  label: '颜色',
551
543
  maxHeight: 400,
@@ -866,7 +858,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
866
858
  }),
867
859
  children: [{
868
860
  label: '文本',
869
- selected: ((_current$node3 = current.node) === null || _current$node3 === void 0 ? void 0 : _current$node3.type.name) === 'paragraph',
861
+ selected: ((_current$node4 = current.node) === null || _current$node4 === void 0 ? void 0 : _current$node4.type.name) === 'paragraph',
870
862
  key: 'convert-to-paragraph',
871
863
  icon: /*#__PURE__*/React.createElement(TextIcon, {
872
864
  sx: {
@@ -889,7 +881,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
889
881
  }
890
882
  }, {
891
883
  label: '标题1',
892
- 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,
884
+ selected: ((_current$node5 = current.node) === null || _current$node5 === void 0 ? void 0 : _current$node5.type.name) === 'heading' && ((_current$node6 = current.node) === null || _current$node6 === void 0 ? void 0 : _current$node6.attrs.level) === 1,
893
885
  key: 'convert-to-heading-1',
894
886
  icon: /*#__PURE__*/React.createElement(H1Icon, {
895
887
  sx: {
@@ -915,7 +907,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
915
907
  }
916
908
  }, {
917
909
  label: '标题2',
918
- 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,
910
+ selected: ((_current$node7 = current.node) === null || _current$node7 === void 0 ? void 0 : _current$node7.type.name) === 'heading' && ((_current$node8 = current.node) === null || _current$node8 === void 0 ? void 0 : _current$node8.attrs.level) === 2,
919
911
  key: 'convert-to-heading-2',
920
912
  icon: /*#__PURE__*/React.createElement(H2Icon, {
921
913
  sx: {
@@ -941,7 +933,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
941
933
  }
942
934
  }, {
943
935
  label: '标题3',
944
- 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,
936
+ selected: ((_current$node9 = current.node) === null || _current$node9 === void 0 ? void 0 : _current$node9.type.name) === 'heading' && ((_current$node10 = current.node) === null || _current$node10 === void 0 ? void 0 : _current$node10.attrs.level) === 3,
945
937
  key: 'convert-to-heading-3',
946
938
  icon: /*#__PURE__*/React.createElement(H3Icon, {
947
939
  sx: {
@@ -974,7 +966,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
974
966
  key: 'divider2'
975
967
  }, {
976
968
  label: '有序列表',
977
- selected: ((_current$node10 = current.node) === null || _current$node10 === void 0 ? void 0 : _current$node10.type.name) === 'orderedList',
969
+ selected: ((_current$node11 = current.node) === null || _current$node11 === void 0 ? void 0 : _current$node11.type.name) === 'orderedList',
978
970
  key: 'convert-to-ordered-list',
979
971
  icon: /*#__PURE__*/React.createElement(ListOrdered2Icon, {
980
972
  sx: {
@@ -997,7 +989,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
997
989
  }
998
990
  }, {
999
991
  label: '无序列表',
1000
- selected: ((_current$node11 = current.node) === null || _current$node11 === void 0 ? void 0 : _current$node11.type.name) === 'bulletList',
992
+ selected: ((_current$node12 = current.node) === null || _current$node12 === void 0 ? void 0 : _current$node12.type.name) === 'bulletList',
1001
993
  key: 'convert-to-bullet-list',
1002
994
  icon: /*#__PURE__*/React.createElement(ListUnorderedIcon, {
1003
995
  sx: {
@@ -1020,7 +1012,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
1020
1012
  }
1021
1013
  }, {
1022
1014
  label: '任务列表',
1023
- selected: ((_current$node12 = current.node) === null || _current$node12 === void 0 ? void 0 : _current$node12.type.name) === 'taskList',
1015
+ selected: ((_current$node13 = current.node) === null || _current$node13 === void 0 ? void 0 : _current$node13.type.name) === 'taskList',
1024
1016
  key: 'convert-to-task-list',
1025
1017
  icon: /*#__PURE__*/React.createElement(ListCheck3Icon, {
1026
1018
  sx: {
@@ -1050,7 +1042,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
1050
1042
  key: 'divider3'
1051
1043
  }, {
1052
1044
  label: '引用',
1053
- selected: ((_current$node13 = current.node) === null || _current$node13 === void 0 ? void 0 : _current$node13.type.name) === 'blockquote',
1045
+ selected: ((_current$node14 = current.node) === null || _current$node14 === void 0 ? void 0 : _current$node14.type.name) === 'blockquote',
1054
1046
  key: 'convert-to-blockquote',
1055
1047
  icon: /*#__PURE__*/React.createElement(QuoteTextIcon, {
1056
1048
  sx: {
@@ -1073,7 +1065,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
1073
1065
  }
1074
1066
  }, {
1075
1067
  label: '警告块',
1076
- selected: ((_current$node14 = current.node) === null || _current$node14 === void 0 ? void 0 : _current$node14.type.name) === 'alert',
1068
+ selected: ((_current$node15 = current.node) === null || _current$node15 === void 0 ? void 0 : _current$node15.type.name) === 'alert',
1077
1069
  key: 'convert-to-alert',
1078
1070
  icon: /*#__PURE__*/React.createElement(Information2LineIcon, {
1079
1071
  sx: {
@@ -1102,7 +1094,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
1102
1094
  }
1103
1095
  }
1104
1096
  }]
1105
- }] : []), _toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.download && ((_current$node15 = current.node) !== null && _current$node15 !== void 0 && _current$node15.attrs.src || (_current$node16 = current.node) !== null && _current$node16 !== void 0 && _current$node16.attrs.src) ? [{
1097
+ }] : []), _toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.download && ((_current$node16 = current.node) !== null && _current$node16 !== void 0 && _current$node16.attrs.src || (_current$node17 = current.node) !== null && _current$node17 !== void 0 && _current$node17.attrs.src) ? [{
1106
1098
  label: "\u4E0B\u8F7D".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label),
1107
1099
  key: 'download',
1108
1100
  icon: /*#__PURE__*/React.createElement(DownloadLineIcon, {
@@ -1112,7 +1104,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
1112
1104
  }),
1113
1105
  onClick: function () {
1114
1106
  var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1115
- var _current$node17, node, nodeFile, nodeBlob, nodeUrl, nodeName, a;
1107
+ var _current$node18, node, nodeFile, nodeBlob, nodeUrl, nodeName, a;
1116
1108
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1117
1109
  while (1) switch (_context3.prev = _context3.next) {
1118
1110
  case 0:
@@ -1120,7 +1112,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
1120
1112
  _context3.next = 16;
1121
1113
  break;
1122
1114
  }
1123
- if (![NodeTypeEnum.Video, NodeTypeEnum.Audio, NodeTypeEnum.BlockAttachment].includes((_current$node17 = current.node) === null || _current$node17 === void 0 ? void 0 : _current$node17.type.name)) {
1115
+ if (![NodeTypeEnum.Video, NodeTypeEnum.Audio, NodeTypeEnum.BlockAttachment].includes((_current$node18 = current.node) === null || _current$node18 === void 0 ? void 0 : _current$node18.type.name)) {
1124
1116
  _context3.next = 16;
1125
1117
  break;
1126
1118
  }
@@ -1383,27 +1375,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
1383
1375
  }
1384
1376
  return onClick;
1385
1377
  }()
1386
- }] : []))), _toConsumableArray(more ? more : []), _toConsumableArray(hasMarks ? [{
1387
- label: '文本格式化',
1388
- key: 'format',
1389
- icon: /*#__PURE__*/React.createElement(EraserLineIcon, {
1390
- sx: {
1391
- fontSize: '1rem'
1392
- }
1393
- }),
1394
- onClick: function onClick() {
1395
- if (current.node && current.pos !== undefined) {
1396
- var _current$node18;
1397
- var selection = current.editor.commands.setTextSelection({
1398
- from: current.pos,
1399
- to: current.pos + ((_current$node18 = current.node) === null || _current$node18 === void 0 ? void 0 : _current$node18.nodeSize)
1400
- });
1401
- if (selection) {
1402
- current.editor.chain().unsetAllMarks().focus(current.pos - 1).run();
1403
- }
1404
- }
1405
- }
1406
- }] : []))
1378
+ }] : []))), _toConsumableArray(more ? more : []))
1407
1379
  }) : /*#__PURE__*/React.createElement(DragIcon, null)));
1408
1380
  };
1409
1381
  export default CustomDragHandle;
@@ -0,0 +1,6 @@
1
+ import { SvgIconProps } from "@mui/material";
2
+ import * as React from "react";
3
+ export declare const EmotionLineIcon: {
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 EmotionLineIcon = function EmotionLineIcon(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 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM8 13H16C16 15.2091 14.2091 17 12 17C9.79086 17 8 15.2091 8 13ZM8 11C7.17157 11 6.5 10.3284 6.5 9.5C6.5 8.67157 7.17157 8 8 8C8.82843 8 9.5 8.67157 9.5 9.5C9.5 10.3284 8.82843 11 8 11ZM16 11C15.1716 11 14.5 10.3284 14.5 9.5C14.5 8.67157 15.1716 8 16 8C16.8284 8 17.5 8.67157 17.5 9.5C17.5 10.3284 16.8284 11 16 11Z"
11
+ }));
12
+ };
13
+ EmotionLineIcon.displayName = 'icon-emotion-line';
@@ -42,6 +42,7 @@ export { DownloadLineIcon } from './download-line-icon';
42
42
  export { DraggableIcon } from './draggable-icon';
43
43
  export { EditBoxLineIcon } from './edit-box-line-icon';
44
44
  export { EditLineIcon } from './edit-line-icon';
45
+ export { EmotionLineIcon } from './emotion-line-icon';
45
46
  export { EraserLineIcon } from './eraser-line-icon';
46
47
  export { ErrorWarningFillIcon } from './error-warning-fill-icon';
47
48
  export { ExpendIcon } from './expend-icon';
@@ -45,6 +45,7 @@ export { DownloadLineIcon } from "./download-line-icon";
45
45
  export { DraggableIcon } from "./draggable-icon";
46
46
  export { EditBoxLineIcon } from "./edit-box-line-icon";
47
47
  export { EditLineIcon } from "./edit-line-icon";
48
+ export { EmotionLineIcon } from "./emotion-line-icon";
48
49
  export { EraserLineIcon } from "./eraser-line-icon";
49
50
  export { ErrorWarningFillIcon } from "./error-warning-fill-icon";
50
51
  export { ExpendIcon } from "./expend-icon";
@@ -3,7 +3,7 @@ import { PopoverOrigin } from '@mui/material';
3
3
  import React from 'react';
4
4
  export interface NestedMenuListProps {
5
5
  list: MenuItem[];
6
- width?: number;
6
+ width?: React.CSSProperties['width'];
7
7
  arrowIcon?: React.ReactNode;
8
8
  childrenProps?: {
9
9
  anchorOrigin?: PopoverOrigin;
@@ -11,6 +11,7 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11
11
  var _ref$id = _ref.id,
12
12
  id = _ref$id === void 0 ? 'menu-select' : _ref$id,
13
13
  width = _ref.width,
14
+ maxHeight = _ref.maxHeight,
14
15
  arrowIcon = _ref.arrowIcon,
15
16
  list = _ref.list,
16
17
  _ref$header = _ref.header,
@@ -84,7 +85,9 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
84
85
  } : undefined
85
86
  }, /*#__PURE__*/React.createElement(Box, {
86
87
  sx: {
87
- p: 0.5
88
+ p: 0.5,
89
+ maxHeight: maxHeight,
90
+ overflowY: 'auto'
88
91
  }
89
92
  }, /*#__PURE__*/React.createElement(Box, {
90
93
  onClick: handleClose
@@ -1,7 +1,7 @@
1
1
  import { getShortcutKeyText } from "../../../util";
2
2
  import { Typography } from '@mui/material';
3
3
  import React from 'react';
4
- import { AddCircleFillIcon, ArrowDownSLineIcon, AttachmentLineIcon, CheckboxCircleFillIcon, CloseCircleFillIcon, CodeBoxLineIcon, CodeLineIcon, CodeSSlashLineIcon, DoubleQuotesLIcon, ErrorWarningFillIcon, Folder2LineIcon, FormulaIcon, FunctionsIcon, ImageLineIcon, Information2FillIcon, Information2LineIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, Table2Icon, UserSmileFillIcon, WindowFillIcon } from "../../Icons";
4
+ import { AddCircleFillIcon, ArrowDownSLineIcon, AttachmentLineIcon, CheckboxCircleFillIcon, CloseCircleFillIcon, CodeBoxLineIcon, CodeLineIcon, CodeSSlashLineIcon, DoubleQuotesLIcon, EmotionLineIcon, ErrorWarningFillIcon, FormulaIcon, FunctionsIcon, ImageLineIcon, Information2FillIcon, Information2LineIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, Table2Icon, UserSmileFillIcon, WindowFillIcon } from "../../Icons";
5
5
  import Menu from "../../Menu";
6
6
  import ToolbarItem from "../Item";
7
7
  import TableSizePicker from "../TableSizePicker";
@@ -9,6 +9,7 @@ var EditorInsert = function EditorInsert(_ref) {
9
9
  var editor = _ref.editor;
10
10
  return /*#__PURE__*/React.createElement(Menu, {
11
11
  width: 224,
12
+ maxHeight: 'calc(100vh - 312px)',
12
13
  context: /*#__PURE__*/React.createElement(ToolbarItem, {
13
14
  tip: '插入',
14
15
  text: '插入',
@@ -36,12 +37,30 @@ var EditorInsert = function EditorInsert(_ref) {
36
37
  customLabel: /*#__PURE__*/React.createElement(Typography, {
37
38
  sx: {
38
39
  px: 1,
39
- pt: 2,
40
+ pt: 1,
40
41
  fontSize: '12px',
41
42
  color: 'text.disabled'
42
43
  }
43
44
  }, "\u901A\u7528"),
44
45
  key: 'current-node'
46
+ }, {
47
+ label: '表情',
48
+ key: 'emotion',
49
+ icon: /*#__PURE__*/React.createElement(EmotionLineIcon, {
50
+ sx: {
51
+ fontSize: '1rem'
52
+ }
53
+ }),
54
+ extra: /*#__PURE__*/React.createElement(Typography, {
55
+ sx: {
56
+ fontSize: '12px',
57
+ color: 'text.disabled'
58
+ }
59
+ }, ":"),
60
+ onClick: function onClick() {
61
+ var pos = editor.state.selection.from;
62
+ editor.chain().insertContentAt(pos, ' : ').focus(pos + 2).run();
63
+ }
45
64
  }, {
46
65
  label: '图片',
47
66
  key: 'image',
@@ -62,6 +81,70 @@ var EditorInsert = function EditorInsert(_ref) {
62
81
  width: 760
63
82
  });
64
83
  }
84
+ }, {
85
+ label: '视频',
86
+ key: 'video',
87
+ extra: /*#__PURE__*/React.createElement(Typography, {
88
+ sx: {
89
+ fontSize: '12px',
90
+ color: 'text.disabled'
91
+ }
92
+ }, getShortcutKeyText(['ctrl', '3'], '+')),
93
+ icon: /*#__PURE__*/React.createElement(MovieLineIcon, {
94
+ sx: {
95
+ fontSize: '1rem'
96
+ }
97
+ }),
98
+ onClick: function onClick() {
99
+ return editor.commands.setVideo({
100
+ src: '',
101
+ width: 760,
102
+ controls: true,
103
+ autoplay: false
104
+ });
105
+ }
106
+ }, {
107
+ label: '音频',
108
+ key: 'audio',
109
+ extra: /*#__PURE__*/React.createElement(Typography, {
110
+ sx: {
111
+ fontSize: '12px',
112
+ color: 'text.disabled'
113
+ }
114
+ }, getShortcutKeyText(['ctrl', '4'], '+')),
115
+ icon: /*#__PURE__*/React.createElement(Music2LineIcon, {
116
+ sx: {
117
+ fontSize: '1rem'
118
+ }
119
+ }),
120
+ onClick: function onClick() {
121
+ return editor.commands.setAudio({
122
+ src: '',
123
+ controls: true,
124
+ autoplay: false
125
+ });
126
+ }
127
+ }, {
128
+ label: '附件',
129
+ key: 'attachment',
130
+ extra: /*#__PURE__*/React.createElement(Typography, {
131
+ sx: {
132
+ fontSize: '12px',
133
+ color: 'text.disabled'
134
+ }
135
+ }, getShortcutKeyText(['ctrl', '5'], '+')),
136
+ icon: /*#__PURE__*/React.createElement(AttachmentLineIcon, {
137
+ sx: {
138
+ fontSize: '1rem'
139
+ }
140
+ }),
141
+ onClick: function onClick() {
142
+ return editor.commands.setInlineAttachment({
143
+ url: '',
144
+ title: '',
145
+ size: '0'
146
+ });
147
+ }
65
148
  }, {
66
149
  label: '表格',
67
150
  key: 'table',
@@ -88,88 +171,15 @@ var EditorInsert = function EditorInsert(_ref) {
88
171
  }
89
172
  })
90
173
  }]
91
- }, {
92
- label: '文件',
93
- key: 'file',
94
- icon: /*#__PURE__*/React.createElement(Folder2LineIcon, {
95
- sx: {
96
- fontSize: '1rem'
97
- }
98
- }),
99
- children: [{
100
- label: '附件',
101
- key: 'attachment',
102
- extra: /*#__PURE__*/React.createElement(Typography, {
103
- sx: {
104
- fontSize: '12px',
105
- color: 'text.disabled'
106
- }
107
- }, getShortcutKeyText(['ctrl', '5'], '+')),
108
- icon: /*#__PURE__*/React.createElement(AttachmentLineIcon, {
109
- sx: {
110
- fontSize: '1rem'
111
- }
112
- }),
113
- onClick: function onClick() {
114
- return editor.commands.setInlineAttachment({
115
- url: '',
116
- title: '',
117
- size: '0'
118
- });
119
- }
120
- }, {
121
- label: '音频',
122
- key: 'audio',
123
- extra: /*#__PURE__*/React.createElement(Typography, {
124
- sx: {
125
- fontSize: '12px',
126
- color: 'text.disabled'
127
- }
128
- }, getShortcutKeyText(['ctrl', '4'], '+')),
129
- icon: /*#__PURE__*/React.createElement(Music2LineIcon, {
130
- sx: {
131
- fontSize: '1rem'
132
- }
133
- }),
134
- onClick: function onClick() {
135
- return editor.commands.setAudio({
136
- src: '',
137
- controls: true,
138
- autoplay: false
139
- });
140
- }
141
- }, {
142
- label: '视频',
143
- key: 'video',
144
- extra: /*#__PURE__*/React.createElement(Typography, {
145
- sx: {
146
- fontSize: '12px',
147
- color: 'text.disabled'
148
- }
149
- }, getShortcutKeyText(['ctrl', '3'], '+')),
150
- icon: /*#__PURE__*/React.createElement(MovieLineIcon, {
151
- sx: {
152
- fontSize: '1rem'
153
- }
154
- }),
155
- onClick: function onClick() {
156
- return editor.commands.setVideo({
157
- src: '',
158
- width: 760,
159
- controls: true,
160
- autoplay: false
161
- });
162
- }
163
- }]
164
174
  }, {
165
175
  customLabel: /*#__PURE__*/React.createElement(Typography, {
166
176
  sx: {
167
177
  px: 1,
168
- pt: 2,
178
+ pt: 1,
169
179
  fontSize: '12px',
170
180
  color: 'text.disabled'
171
181
  }
172
- }, "\u6837\u5F0F\u5E03\u5C40"),
182
+ }, "\u6A21\u5757"),
173
183
  key: 'style'
174
184
  }, {
175
185
  label: '分割线',
@@ -304,11 +314,11 @@ var EditorInsert = function EditorInsert(_ref) {
304
314
  customLabel: /*#__PURE__*/React.createElement(Typography, {
305
315
  sx: {
306
316
  px: 1,
307
- pt: 2,
317
+ pt: 1,
308
318
  fontSize: '12px',
309
319
  color: 'text.disabled'
310
320
  }
311
- }, "\u7A0B\u5E8F\u5458\u4E13\u7528"),
321
+ }, "\u4E13\u4E1A"),
312
322
  key: 'programmer'
313
323
  }, {
314
324
  label: '代码',
@@ -404,7 +414,7 @@ var EditorInsert = function EditorInsert(_ref) {
404
414
  customLabel: /*#__PURE__*/React.createElement(Typography, {
405
415
  sx: {
406
416
  px: 1,
407
- pt: 2,
417
+ pt: 1,
408
418
  fontSize: '12px',
409
419
  color: 'text.disabled'
410
420
  }