@ctzhian/tiptap 0.5.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Editor/demo.js +1 -1
- package/dist/EditorDiff/demo.d.ts +4 -0
- package/dist/EditorDiff/demo.js +12 -0
- package/dist/EditorDiff/index.d.ts +7 -0
- package/dist/EditorDiff/index.js +24 -0
- package/dist/EditorToolbar/index.js +19 -3
- package/dist/component/CustomBubbleMenu/SelectionText.js +1 -1
- package/dist/component/CustomDragHandle/index.js +237 -191
- package/dist/component/Icons/index.d.ts +1 -0
- package/dist/component/Icons/index.js +1 -0
- package/dist/component/Icons/information-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/information-2-line-icon.js +13 -0
- package/dist/component/Menu/NestedList.d.ts +14 -0
- package/dist/component/Menu/NestedList.js +149 -0
- package/dist/component/Menu/index.js +12 -117
- package/dist/component/Toolbar/EditorCode.js +1 -1
- package/dist/component/Toolbar/EditorMore/NotificationDialog.js +2 -1
- package/dist/component/index.d.ts +2 -0
- package/dist/component/index.js +3 -1
- package/dist/contants/enums.d.ts +1 -0
- package/dist/contants/enums.js +10 -3
- package/dist/contants/shortcut-key.js +1 -1
- package/dist/contants/slash-commands.d.ts +2 -1
- package/dist/contants/slash-commands.js +98 -42
- package/dist/extension/component/Alert/index.d.ts +7 -9
- package/dist/extension/component/Alert/index.js +186 -109
- package/dist/extension/component/Attachment/Readonly.js +0 -1
- package/dist/extension/component/Image/Readonly.js +0 -1
- package/dist/extension/component/Link/Readonly.js +2 -2
- package/dist/extension/component/Mathematics/block/Readonly.js +0 -1
- package/dist/extension/component/Mathematics/inline/Readonly.js +0 -1
- package/dist/extension/component/SlashCommandsList/index.js +235 -100
- package/dist/extension/component/Video/Readonly.js +0 -1
- package/dist/extension/extension/StructuredDiff.d.ts +18 -0
- package/dist/extension/extension/StructuredDiff.js +131 -0
- package/dist/extension/extension/index.d.ts +1 -0
- package/dist/extension/extension/index.js +2 -1
- package/dist/extension/index.js +38 -82
- package/dist/extension/node/Alert.d.ts +19 -8
- package/dist/extension/node/Alert.js +210 -131
- package/dist/extension/node/Table.js +7 -7
- package/dist/extension/suggestion/slash.d.ts +2 -1
- package/dist/extension/suggestion/slash.js +3 -1
- package/dist/index.css +14 -26
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/type/index.d.ts +11 -2
- package/dist/util/decorations.d.ts +22 -0
- package/dist/util/decorations.js +302 -0
- package/dist/util/structuredDiff.d.ts +59 -0
- package/dist/util/structuredDiff.js +550 -0
- package/package.json +3 -1
|
@@ -12,15 +12,17 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
12
12
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
13
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
-
import { AlignBottomIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, AlignTopIcon, ArrowDownSLineIcon, AttachmentLineIcon, BrushLineIcon, CodeBoxLineIcon, DeleteLineIcon, DownloadLineIcon, DraggableIcon, FontSizeIcon, FormatClearIcon, H1Icon, H2Icon, H3Icon, ImageLineIcon,
|
|
15
|
+
import { AlignBottomIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, AlignTopIcon, ArrowDownSLineIcon, AttachmentLineIcon, BrushLineIcon, CodeBoxLineIcon, DeleteLineIcon, DownloadLineIcon, DraggableIcon, FontSizeIcon, FormatClearIcon, H1Icon, H2Icon, H3Icon, ImageLineIcon, Information2LineIcon, ListCheck3Icon, ListOrdered2Icon, ListUnorderedIcon, MovieLineIcon, Music2LineIcon, QuoteTextIcon, Repeat2LineIcon, ScissorsCutLineIcon, SeparatorIcon, TextIcon, TextWrapIcon } from "../Icons";
|
|
16
16
|
import { NODE_TYPE_LABEL, NodeTypeEnum } from "../../contants/enums";
|
|
17
|
-
import { Box, Divider, Typography, useTheme } from '@mui/material';
|
|
17
|
+
import { Box, Divider, Stack, Typography, useTheme } from '@mui/material';
|
|
18
18
|
import DragHandle from '@tiptap/extension-drag-handle-react';
|
|
19
19
|
import { Fragment, Slice } from '@tiptap/pm/model';
|
|
20
|
+
import { TextSelection } from '@tiptap/pm/state';
|
|
20
21
|
import React, { useCallback, useState } from 'react';
|
|
21
22
|
import { downloadFiles, filterResourcesByType, getAllResources } from "../../util";
|
|
22
23
|
import { FileCopyLineIcon } from "../Icons/file-copy-line-icon";
|
|
23
24
|
import Menu from "../Menu";
|
|
25
|
+
import { ToolbarItem } from "../Toolbar";
|
|
24
26
|
var DragIcon = function DragIcon(_ref) {
|
|
25
27
|
var onClick = _ref.onClick;
|
|
26
28
|
return /*#__PURE__*/React.createElement(Box, {
|
|
@@ -55,7 +57,7 @@ var DragIcon = function DragIcon(_ref) {
|
|
|
55
57
|
}));
|
|
56
58
|
};
|
|
57
59
|
var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
58
|
-
var _current$node3, _current$node4;
|
|
60
|
+
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, _current$node17;
|
|
59
61
|
var editor = _ref2.editor,
|
|
60
62
|
more = _ref2.more,
|
|
61
63
|
onTip = _ref2.onTip;
|
|
@@ -146,28 +148,41 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
146
148
|
var type = (_current$node = current.node) === null || _current$node === void 0 ? void 0 : _current$node.type.name;
|
|
147
149
|
switch (type) {
|
|
148
150
|
case NodeTypeEnum.Paragraph:
|
|
149
|
-
current.editor.
|
|
151
|
+
current.editor.commands.setParagraph();
|
|
150
152
|
break;
|
|
151
153
|
case NodeTypeEnum.Heading:
|
|
152
|
-
current.editor.
|
|
154
|
+
current.editor.commands.setParagraph();
|
|
153
155
|
break;
|
|
154
156
|
case NodeTypeEnum.BulletList:
|
|
155
|
-
current.editor.
|
|
157
|
+
current.editor.commands.toggleBulletList();
|
|
156
158
|
break;
|
|
157
159
|
case NodeTypeEnum.OrderedList:
|
|
158
|
-
current.editor.
|
|
160
|
+
current.editor.commands.toggleOrderedList();
|
|
159
161
|
break;
|
|
160
162
|
case NodeTypeEnum.TaskList:
|
|
161
|
-
current.editor.
|
|
163
|
+
current.editor.commands.toggleTaskList();
|
|
162
164
|
break;
|
|
163
165
|
case NodeTypeEnum.Blockquote:
|
|
164
|
-
current.editor.
|
|
166
|
+
current.editor.commands.toggleBlockquote();
|
|
165
167
|
break;
|
|
166
168
|
case NodeTypeEnum.CodeBlock:
|
|
167
|
-
current.editor.
|
|
169
|
+
current.editor.commands.toggleCodeBlock();
|
|
170
|
+
break;
|
|
171
|
+
case NodeTypeEnum.Alert:
|
|
172
|
+
current.editor.commands.setParagraph();
|
|
168
173
|
break;
|
|
169
174
|
}
|
|
170
175
|
};
|
|
176
|
+
var selectCurrentNode = function selectCurrentNode() {
|
|
177
|
+
var _current$editor = current.editor,
|
|
178
|
+
state = _current$editor.state,
|
|
179
|
+
view = _current$editor.view;
|
|
180
|
+
var tr = state.tr;
|
|
181
|
+
var resolved = tr.doc.resolve(Math.min(current.pos + 1, tr.doc.content.size));
|
|
182
|
+
tr.setSelection(TextSelection.near(resolved));
|
|
183
|
+
view.dispatch(tr);
|
|
184
|
+
view.focus();
|
|
185
|
+
};
|
|
171
186
|
var hasMarksDeep = function hasMarksDeep(node) {
|
|
172
187
|
var _content;
|
|
173
188
|
if (!node) return false;
|
|
@@ -257,7 +272,7 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
257
272
|
}].concat(_toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.color ? [{
|
|
258
273
|
key: 'color',
|
|
259
274
|
label: '颜色',
|
|
260
|
-
maxHeight:
|
|
275
|
+
maxHeight: 480,
|
|
261
276
|
icon: /*#__PURE__*/React.createElement(BrushLineIcon, {
|
|
262
277
|
sx: {
|
|
263
278
|
fontSize: '1rem'
|
|
@@ -307,8 +322,8 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
307
322
|
color: 'text.secondary',
|
|
308
323
|
fontWeight: 'bold'
|
|
309
324
|
}
|
|
310
|
-
}, "\
|
|
311
|
-
key: '
|
|
325
|
+
}, "\u80CC\u666F\u989C\u8272"),
|
|
326
|
+
key: 'background-color'
|
|
312
327
|
}], _toConsumableArray(THEME_TEXT_BG_COLOR.map(function (it) {
|
|
313
328
|
return {
|
|
314
329
|
label: it.label,
|
|
@@ -522,6 +537,7 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
522
537
|
}] : []), _toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.convert ? [{
|
|
523
538
|
label: '转换',
|
|
524
539
|
key: 'convert',
|
|
540
|
+
maxHeight: 400,
|
|
525
541
|
icon: /*#__PURE__*/React.createElement(Repeat2LineIcon, {
|
|
526
542
|
sx: {
|
|
527
543
|
fontSize: '1rem'
|
|
@@ -529,7 +545,7 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
529
545
|
}),
|
|
530
546
|
children: [{
|
|
531
547
|
label: '文本',
|
|
532
|
-
selected:
|
|
548
|
+
selected: ((_current$node3 = current.node) === null || _current$node3 === void 0 ? void 0 : _current$node3.type.name) === 'paragraph',
|
|
533
549
|
key: 'convert-to-paragraph',
|
|
534
550
|
icon: /*#__PURE__*/React.createElement(TextIcon, {
|
|
535
551
|
sx: {
|
|
@@ -538,15 +554,14 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
538
554
|
}),
|
|
539
555
|
onClick: function onClick() {
|
|
540
556
|
if (current.node && current.pos !== undefined) {
|
|
557
|
+
selectCurrentNode();
|
|
541
558
|
cancelNodeType();
|
|
542
|
-
current.editor.
|
|
559
|
+
current.editor.commands.setParagraph();
|
|
543
560
|
}
|
|
544
561
|
}
|
|
545
562
|
}, {
|
|
546
563
|
label: '一级标题',
|
|
547
|
-
selected:
|
|
548
|
-
level: 1
|
|
549
|
-
}),
|
|
564
|
+
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,
|
|
550
565
|
key: 'convert-to-heading-1',
|
|
551
566
|
icon: /*#__PURE__*/React.createElement(H1Icon, {
|
|
552
567
|
sx: {
|
|
@@ -555,17 +570,16 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
555
570
|
}),
|
|
556
571
|
onClick: function onClick() {
|
|
557
572
|
if (current.node && current.pos !== undefined) {
|
|
573
|
+
selectCurrentNode();
|
|
558
574
|
cancelNodeType();
|
|
559
|
-
current.editor.
|
|
575
|
+
current.editor.commands.setHeading({
|
|
560
576
|
level: 1
|
|
561
|
-
})
|
|
577
|
+
});
|
|
562
578
|
}
|
|
563
579
|
}
|
|
564
580
|
}, {
|
|
565
581
|
label: '二级标题',
|
|
566
|
-
selected:
|
|
567
|
-
level: 2
|
|
568
|
-
}),
|
|
582
|
+
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,
|
|
569
583
|
key: 'convert-to-heading-2',
|
|
570
584
|
icon: /*#__PURE__*/React.createElement(H2Icon, {
|
|
571
585
|
sx: {
|
|
@@ -574,17 +588,16 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
574
588
|
}),
|
|
575
589
|
onClick: function onClick() {
|
|
576
590
|
if (current.node && current.pos !== undefined) {
|
|
591
|
+
selectCurrentNode();
|
|
577
592
|
cancelNodeType();
|
|
578
|
-
current.editor.
|
|
593
|
+
current.editor.commands.setHeading({
|
|
579
594
|
level: 2
|
|
580
|
-
})
|
|
595
|
+
});
|
|
581
596
|
}
|
|
582
597
|
}
|
|
583
598
|
}, {
|
|
584
599
|
label: '三级标题',
|
|
585
|
-
selected:
|
|
586
|
-
level: 3
|
|
587
|
-
}),
|
|
600
|
+
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,
|
|
588
601
|
key: 'convert-to-heading-3',
|
|
589
602
|
icon: /*#__PURE__*/React.createElement(H3Icon, {
|
|
590
603
|
sx: {
|
|
@@ -593,10 +606,11 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
593
606
|
}),
|
|
594
607
|
onClick: function onClick() {
|
|
595
608
|
if (current.node && current.pos !== undefined) {
|
|
609
|
+
selectCurrentNode();
|
|
596
610
|
cancelNodeType();
|
|
597
|
-
current.editor.
|
|
611
|
+
current.editor.commands.setHeading({
|
|
598
612
|
level: 3
|
|
599
|
-
})
|
|
613
|
+
});
|
|
600
614
|
}
|
|
601
615
|
}
|
|
602
616
|
}, {
|
|
@@ -608,7 +622,7 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
608
622
|
key: 'divider2'
|
|
609
623
|
}, {
|
|
610
624
|
label: '有序列表',
|
|
611
|
-
selected:
|
|
625
|
+
selected: ((_current$node10 = current.node) === null || _current$node10 === void 0 ? void 0 : _current$node10.type.name) === 'orderedList',
|
|
612
626
|
key: 'convert-to-ordered-list',
|
|
613
627
|
icon: /*#__PURE__*/React.createElement(ListOrdered2Icon, {
|
|
614
628
|
sx: {
|
|
@@ -617,13 +631,14 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
617
631
|
}),
|
|
618
632
|
onClick: function onClick() {
|
|
619
633
|
if (current.node && current.pos !== undefined) {
|
|
634
|
+
selectCurrentNode();
|
|
620
635
|
cancelNodeType();
|
|
621
|
-
current.editor.
|
|
636
|
+
current.editor.commands.toggleOrderedList();
|
|
622
637
|
}
|
|
623
638
|
}
|
|
624
639
|
}, {
|
|
625
640
|
label: '无序列表',
|
|
626
|
-
selected:
|
|
641
|
+
selected: ((_current$node11 = current.node) === null || _current$node11 === void 0 ? void 0 : _current$node11.type.name) === 'bulletList',
|
|
627
642
|
key: 'convert-to-bullet-list',
|
|
628
643
|
icon: /*#__PURE__*/React.createElement(ListUnorderedIcon, {
|
|
629
644
|
sx: {
|
|
@@ -632,13 +647,14 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
632
647
|
}),
|
|
633
648
|
onClick: function onClick() {
|
|
634
649
|
if (current.node && current.pos !== undefined) {
|
|
650
|
+
selectCurrentNode();
|
|
635
651
|
cancelNodeType();
|
|
636
|
-
current.editor.
|
|
652
|
+
current.editor.commands.toggleBulletList();
|
|
637
653
|
}
|
|
638
654
|
}
|
|
639
655
|
}, {
|
|
640
656
|
label: '任务列表',
|
|
641
|
-
selected:
|
|
657
|
+
selected: ((_current$node12 = current.node) === null || _current$node12 === void 0 ? void 0 : _current$node12.type.name) === 'taskList',
|
|
642
658
|
key: 'convert-to-task-list',
|
|
643
659
|
icon: /*#__PURE__*/React.createElement(ListCheck3Icon, {
|
|
644
660
|
sx: {
|
|
@@ -647,8 +663,9 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
647
663
|
}),
|
|
648
664
|
onClick: function onClick() {
|
|
649
665
|
if (current.node && current.pos !== undefined) {
|
|
666
|
+
selectCurrentNode();
|
|
650
667
|
cancelNodeType();
|
|
651
|
-
current.editor.
|
|
668
|
+
current.editor.commands.toggleTaskList();
|
|
652
669
|
}
|
|
653
670
|
}
|
|
654
671
|
}, {
|
|
@@ -660,7 +677,7 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
660
677
|
key: 'divider3'
|
|
661
678
|
}, {
|
|
662
679
|
label: '引用块',
|
|
663
|
-
selected:
|
|
680
|
+
selected: ((_current$node13 = current.node) === null || _current$node13 === void 0 ? void 0 : _current$node13.type.name) === 'blockquote',
|
|
664
681
|
key: 'convert-to-blockquote',
|
|
665
682
|
icon: /*#__PURE__*/React.createElement(QuoteTextIcon, {
|
|
666
683
|
sx: {
|
|
@@ -669,13 +686,14 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
669
686
|
}),
|
|
670
687
|
onClick: function onClick() {
|
|
671
688
|
if (current.node && current.pos !== undefined) {
|
|
689
|
+
selectCurrentNode();
|
|
672
690
|
cancelNodeType();
|
|
673
|
-
current.editor.
|
|
691
|
+
current.editor.commands.toggleBlockquote();
|
|
674
692
|
}
|
|
675
693
|
}
|
|
676
694
|
}, {
|
|
677
695
|
label: '代码块',
|
|
678
|
-
selected:
|
|
696
|
+
selected: ((_current$node14 = current.node) === null || _current$node14 === void 0 ? void 0 : _current$node14.type.name) === 'codeBlock',
|
|
679
697
|
key: 'convert-to-code-block',
|
|
680
698
|
icon: /*#__PURE__*/React.createElement(CodeBoxLineIcon, {
|
|
681
699
|
sx: {
|
|
@@ -684,12 +702,32 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
684
702
|
}),
|
|
685
703
|
onClick: function onClick() {
|
|
686
704
|
if (current.node && current.pos !== undefined) {
|
|
705
|
+
selectCurrentNode();
|
|
706
|
+
cancelNodeType();
|
|
707
|
+
current.editor.commands.toggleCodeBlock();
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}, {
|
|
711
|
+
label: '警告提示',
|
|
712
|
+
selected: ((_current$node15 = current.node) === null || _current$node15 === void 0 ? void 0 : _current$node15.type.name) === 'alert',
|
|
713
|
+
key: 'convert-to-alert',
|
|
714
|
+
icon: /*#__PURE__*/React.createElement(Information2LineIcon, {
|
|
715
|
+
sx: {
|
|
716
|
+
fontSize: '1rem'
|
|
717
|
+
}
|
|
718
|
+
}),
|
|
719
|
+
onClick: function onClick() {
|
|
720
|
+
if (current.node && current.pos !== undefined) {
|
|
721
|
+
selectCurrentNode();
|
|
687
722
|
cancelNodeType();
|
|
688
|
-
current.editor.
|
|
723
|
+
current.editor.commands.toggleAlert({
|
|
724
|
+
type: 'icon',
|
|
725
|
+
variant: 'info'
|
|
726
|
+
});
|
|
689
727
|
}
|
|
690
728
|
}
|
|
691
729
|
}]
|
|
692
|
-
}] : []), _toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.download && ((_current$
|
|
730
|
+
}] : []), _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) ? [{
|
|
693
731
|
label: "\u4E0B\u8F7D".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label),
|
|
694
732
|
key: 'download',
|
|
695
733
|
icon: /*#__PURE__*/React.createElement(DownloadLineIcon, {
|
|
@@ -699,7 +737,7 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
699
737
|
}),
|
|
700
738
|
onClick: function () {
|
|
701
739
|
var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
702
|
-
var _current$
|
|
740
|
+
var _current$node18, node, nodeFile, nodeBlob, nodeUrl, nodeName, a;
|
|
703
741
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
704
742
|
while (1) switch (_context.prev = _context.next) {
|
|
705
743
|
case 0:
|
|
@@ -707,7 +745,7 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
707
745
|
_context.next = 16;
|
|
708
746
|
break;
|
|
709
747
|
}
|
|
710
|
-
if (![NodeTypeEnum.Video, NodeTypeEnum.Audio, NodeTypeEnum.BlockAttachment].includes((_current$
|
|
748
|
+
if (![NodeTypeEnum.Video, NodeTypeEnum.Audio, NodeTypeEnum.BlockAttachment].includes((_current$node18 = current.node) === null || _current$node18 === void 0 ? void 0 : _current$node18.type.name)) {
|
|
711
749
|
_context.next = 16;
|
|
712
750
|
break;
|
|
713
751
|
}
|
|
@@ -1013,174 +1051,172 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
1013
1051
|
}
|
|
1014
1052
|
return onClick;
|
|
1015
1053
|
}()
|
|
1016
|
-
}] : []),
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1054
|
+
}] : [])),
|
|
1055
|
+
header: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Stack, {
|
|
1056
|
+
direction: 'row',
|
|
1057
|
+
flexWrap: 'wrap'
|
|
1058
|
+
}, /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
1059
|
+
key: 'insert-line-break-top',
|
|
1060
|
+
onClick: function onClick() {
|
|
1061
|
+
if (current.node && current.pos !== undefined) {
|
|
1062
|
+
var afterPos = current.pos;
|
|
1063
|
+
current.editor.chain().focus().insertContentAt(afterPos, {
|
|
1064
|
+
type: 'paragraph'
|
|
1065
|
+
}, {
|
|
1066
|
+
updateSelection: true
|
|
1067
|
+
}).run();
|
|
1068
|
+
}
|
|
1069
|
+
},
|
|
1070
|
+
icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
|
|
1071
|
+
sx: {
|
|
1072
|
+
fontSize: '1rem',
|
|
1073
|
+
transform: 'rotate(180deg)'
|
|
1074
|
+
}
|
|
1075
|
+
}),
|
|
1076
|
+
tip: '上方插入行'
|
|
1077
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
1078
|
+
key: 'insert-line-break',
|
|
1079
|
+
onClick: function onClick() {
|
|
1080
|
+
if (current.node && current.pos !== undefined) {
|
|
1081
|
+
var afterPos = current.pos + current.node.nodeSize;
|
|
1082
|
+
current.editor.chain().focus().insertContentAt(afterPos, {
|
|
1083
|
+
type: 'paragraph'
|
|
1084
|
+
}, {
|
|
1085
|
+
updateSelection: true
|
|
1086
|
+
}).run();
|
|
1087
|
+
}
|
|
1088
|
+
},
|
|
1089
|
+
icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
|
|
1020
1090
|
sx: {
|
|
1021
1091
|
fontSize: '1rem'
|
|
1022
1092
|
}
|
|
1023
1093
|
}),
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
onClick: function onClick() {
|
|
1033
|
-
if (current.node && current.pos !== undefined) {
|
|
1034
|
-
current.editor.chain().focus().setAlert({
|
|
1035
|
-
type: 'info'
|
|
1036
|
-
}).run();
|
|
1037
|
-
}
|
|
1094
|
+
tip: '下方插入行'
|
|
1095
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
1096
|
+
key: 'insert-divider',
|
|
1097
|
+
onClick: function onClick() {
|
|
1098
|
+
if (current.node && current.pos !== undefined) {
|
|
1099
|
+
current.editor.chain().focus().insertContent({
|
|
1100
|
+
type: 'horizontalRule'
|
|
1101
|
+
}).run();
|
|
1038
1102
|
}
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
label: "\u590D\u5236".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label),
|
|
1042
|
-
key: 'copy',
|
|
1043
|
-
icon: /*#__PURE__*/React.createElement(FileCopyLineIcon, {
|
|
1103
|
+
},
|
|
1104
|
+
icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
|
|
1044
1105
|
sx: {
|
|
1045
1106
|
fontSize: '1rem'
|
|
1046
1107
|
}
|
|
1047
1108
|
}),
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
}
|
|
1058
|
-
content = new Slice(Fragment.from(current.node), 0, 0);
|
|
1059
|
-
textContent = current.node.textContent;
|
|
1060
|
-
htmlContent = editor.view.serializeForClipboard(content).dom.innerHTML;
|
|
1061
|
-
_context7.prev = 4;
|
|
1062
|
-
if (!(htmlContent && navigator.clipboard && "write" in navigator.clipboard)) {
|
|
1063
|
-
_context7.next = 11;
|
|
1064
|
-
break;
|
|
1065
|
-
}
|
|
1066
|
-
blob = new Blob([htmlContent], {
|
|
1067
|
-
type: "text/html"
|
|
1068
|
-
});
|
|
1069
|
-
clipboardItem = new ClipboardItem({
|
|
1070
|
-
"text/html": blob
|
|
1071
|
-
});
|
|
1072
|
-
_context7.next = 10;
|
|
1073
|
-
return navigator.clipboard.write([clipboardItem]);
|
|
1074
|
-
case 10:
|
|
1075
|
-
onTip === null || onTip === void 0 || onTip('success', '复制成功');
|
|
1076
|
-
case 11:
|
|
1109
|
+
tip: '分割线'
|
|
1110
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
1111
|
+
key: 'copy',
|
|
1112
|
+
onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1113
|
+
var content, textContent, htmlContent, blob, clipboardItem;
|
|
1114
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1115
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1116
|
+
case 0:
|
|
1117
|
+
if (!(current.node && current.pos !== undefined)) {
|
|
1077
1118
|
_context7.next = 17;
|
|
1078
1119
|
break;
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1120
|
+
}
|
|
1121
|
+
content = new Slice(Fragment.from(current.node), 0, 0);
|
|
1122
|
+
textContent = current.node.textContent;
|
|
1123
|
+
htmlContent = editor.view.serializeForClipboard(content).dom.innerHTML;
|
|
1124
|
+
_context7.prev = 4;
|
|
1125
|
+
if (!(htmlContent && navigator.clipboard && "write" in navigator.clipboard)) {
|
|
1126
|
+
_context7.next = 11;
|
|
1127
|
+
break;
|
|
1128
|
+
}
|
|
1129
|
+
blob = new Blob([htmlContent], {
|
|
1130
|
+
type: "text/html"
|
|
1131
|
+
});
|
|
1132
|
+
clipboardItem = new ClipboardItem({
|
|
1133
|
+
"text/html": blob
|
|
1134
|
+
});
|
|
1135
|
+
_context7.next = 10;
|
|
1136
|
+
return navigator.clipboard.write([clipboardItem]);
|
|
1137
|
+
case 10:
|
|
1138
|
+
onTip === null || onTip === void 0 || onTip('success', '复制成功');
|
|
1139
|
+
case 11:
|
|
1140
|
+
_context7.next = 17;
|
|
1141
|
+
break;
|
|
1142
|
+
case 13:
|
|
1143
|
+
_context7.prev = 13;
|
|
1144
|
+
_context7.t0 = _context7["catch"](4);
|
|
1145
|
+
_context7.next = 17;
|
|
1146
|
+
return navigator.clipboard.writeText(textContent);
|
|
1147
|
+
case 17:
|
|
1148
|
+
case "end":
|
|
1149
|
+
return _context7.stop();
|
|
1150
|
+
}
|
|
1151
|
+
}, _callee7, null, [[4, 13]]);
|
|
1152
|
+
})),
|
|
1153
|
+
icon: /*#__PURE__*/React.createElement(FileCopyLineIcon, {
|
|
1099
1154
|
sx: {
|
|
1100
1155
|
fontSize: '1rem'
|
|
1101
1156
|
}
|
|
1102
1157
|
}),
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
}
|
|
1113
|
-
_context8.prev = 1;
|
|
1114
|
-
content = new Slice(Fragment.from(current.node), 0, 0);
|
|
1115
|
-
textContent = current.node.textContent;
|
|
1116
|
-
htmlContent = editor.view.serializeForClipboard(content).dom.innerHTML;
|
|
1117
|
-
_context8.prev = 5;
|
|
1118
|
-
if (!(htmlContent && navigator.clipboard && "write" in navigator.clipboard)) {
|
|
1119
|
-
_context8.next = 11;
|
|
1120
|
-
break;
|
|
1121
|
-
}
|
|
1122
|
-
blob = new Blob([htmlContent], {
|
|
1123
|
-
type: "text/html"
|
|
1124
|
-
});
|
|
1125
|
-
clipboardItem = new ClipboardItem({
|
|
1126
|
-
"text/html": blob
|
|
1127
|
-
});
|
|
1128
|
-
_context8.next = 11;
|
|
1129
|
-
return navigator.clipboard.write([clipboardItem]);
|
|
1130
|
-
case 11:
|
|
1131
|
-
_context8.next = 17;
|
|
1132
|
-
break;
|
|
1133
|
-
case 13:
|
|
1134
|
-
_context8.prev = 13;
|
|
1135
|
-
_context8.t0 = _context8["catch"](5);
|
|
1136
|
-
_context8.next = 17;
|
|
1137
|
-
return navigator.clipboard.writeText(textContent);
|
|
1138
|
-
case 17:
|
|
1139
|
-
current.editor.chain().focus().deleteRange({
|
|
1140
|
-
from: current.pos,
|
|
1141
|
-
to: current.pos + current.node.nodeSize
|
|
1142
|
-
}).run();
|
|
1158
|
+
tip: "\u590D\u5236".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
|
|
1159
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
1160
|
+
key: 'cut',
|
|
1161
|
+
onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1162
|
+
var content, textContent, htmlContent, blob, clipboardItem;
|
|
1163
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1164
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1165
|
+
case 0:
|
|
1166
|
+
if (!(current.node && current.pos !== undefined)) {
|
|
1143
1167
|
_context8.next = 23;
|
|
1144
1168
|
break;
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1169
|
+
}
|
|
1170
|
+
_context8.prev = 1;
|
|
1171
|
+
content = new Slice(Fragment.from(current.node), 0, 0);
|
|
1172
|
+
textContent = current.node.textContent;
|
|
1173
|
+
htmlContent = editor.view.serializeForClipboard(content).dom.innerHTML;
|
|
1174
|
+
_context8.prev = 5;
|
|
1175
|
+
if (!(htmlContent && navigator.clipboard && "write" in navigator.clipboard)) {
|
|
1176
|
+
_context8.next = 11;
|
|
1177
|
+
break;
|
|
1178
|
+
}
|
|
1179
|
+
blob = new Blob([htmlContent], {
|
|
1180
|
+
type: "text/html"
|
|
1181
|
+
});
|
|
1182
|
+
clipboardItem = new ClipboardItem({
|
|
1183
|
+
"text/html": blob
|
|
1184
|
+
});
|
|
1185
|
+
_context8.next = 11;
|
|
1186
|
+
return navigator.clipboard.write([clipboardItem]);
|
|
1187
|
+
case 11:
|
|
1188
|
+
_context8.next = 17;
|
|
1189
|
+
break;
|
|
1190
|
+
case 13:
|
|
1191
|
+
_context8.prev = 13;
|
|
1192
|
+
_context8.t0 = _context8["catch"](5);
|
|
1193
|
+
_context8.next = 17;
|
|
1194
|
+
return navigator.clipboard.writeText(textContent);
|
|
1195
|
+
case 17:
|
|
1196
|
+
current.editor.chain().focus().deleteRange({
|
|
1197
|
+
from: current.pos,
|
|
1198
|
+
to: current.pos + current.node.nodeSize
|
|
1199
|
+
}).run();
|
|
1200
|
+
_context8.next = 23;
|
|
1201
|
+
break;
|
|
1202
|
+
case 20:
|
|
1203
|
+
_context8.prev = 20;
|
|
1204
|
+
_context8.t1 = _context8["catch"](1);
|
|
1205
|
+
onTip === null || onTip === void 0 || onTip('error', '剪切失败');
|
|
1206
|
+
case 23:
|
|
1207
|
+
case "end":
|
|
1208
|
+
return _context8.stop();
|
|
1209
|
+
}
|
|
1210
|
+
}, _callee8, null, [[1, 20], [5, 13]]);
|
|
1211
|
+
})),
|
|
1212
|
+
icon: /*#__PURE__*/React.createElement(ScissorsCutLineIcon, {
|
|
1180
1213
|
sx: {
|
|
1181
1214
|
fontSize: '1rem'
|
|
1182
1215
|
}
|
|
1183
1216
|
}),
|
|
1217
|
+
tip: "\u526A\u5207".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
|
|
1218
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
1219
|
+
key: 'delete',
|
|
1184
1220
|
onClick: function onClick() {
|
|
1185
1221
|
if (current.node && current.pos !== undefined) {
|
|
1186
1222
|
current.editor.chain().focus().deleteRange({
|
|
@@ -1188,8 +1224,18 @@ var CustomDragHandle = function CustomDragHandle(_ref2) {
|
|
|
1188
1224
|
to: current.pos + current.node.nodeSize
|
|
1189
1225
|
}).run();
|
|
1190
1226
|
}
|
|
1227
|
+
},
|
|
1228
|
+
icon: /*#__PURE__*/React.createElement(DeleteLineIcon, {
|
|
1229
|
+
sx: {
|
|
1230
|
+
fontSize: '1rem'
|
|
1231
|
+
}
|
|
1232
|
+
}),
|
|
1233
|
+
tip: "\u5220\u9664".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
|
|
1234
|
+
})), /*#__PURE__*/React.createElement(Divider, {
|
|
1235
|
+
sx: {
|
|
1236
|
+
my: 0.5
|
|
1191
1237
|
}
|
|
1192
|
-
}
|
|
1238
|
+
})),
|
|
1193
1239
|
context: /*#__PURE__*/React.createElement(DragIcon, null)
|
|
1194
1240
|
}) : /*#__PURE__*/React.createElement(DragIcon, null));
|
|
1195
1241
|
};
|