@ctzhian/tiptap 1.6.22 → 1.6.24
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/Editor/index.js +44 -1
- package/dist/EditorDiff/index.js +45 -2
- package/dist/component/CustomBubbleMenu/SelectionText.js +2 -3
- package/dist/component/CustomDragHandle/index.js +47 -66
- package/dist/extension/component/Alert/index.js +4 -1
- package/dist/extension/component/Image/Readonly.d.ts +1 -1
- package/dist/extension/component/Image/Readonly.js +5 -20
- package/dist/extension/component/Table/ContextMenu.js +4 -4
- package/dist/extension/component/Table/TableContextMenuPlugin.js +0 -9
- package/dist/extension/node/FileHandler.d.ts +1 -1
- package/dist/extension/node/Table.d.ts +1 -1
- package/dist/extension/node/Table.js +0 -31
- package/dist/index.css +7 -43
- package/package.json +1 -1
package/dist/Editor/demo.js
CHANGED
package/dist/Editor/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EditorContent } from '@tiptap/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { PhotoProvider } from 'react-photo-view';
|
|
3
4
|
import SelectionText from "../component/CustomBubbleMenu/SelectionText";
|
|
4
5
|
import CustomDragHandle from "../component/CustomDragHandle";
|
|
5
6
|
var Editor = function Editor(_ref) {
|
|
@@ -7,7 +8,49 @@ var Editor = function Editor(_ref) {
|
|
|
7
8
|
menuInDragHandle = _ref.menuInDragHandle,
|
|
8
9
|
menuInBubbleMenu = _ref.menuInBubbleMenu,
|
|
9
10
|
onTip = _ref.onTip;
|
|
10
|
-
return /*#__PURE__*/React.createElement(
|
|
11
|
+
return /*#__PURE__*/React.createElement(PhotoProvider, {
|
|
12
|
+
speed: function speed() {
|
|
13
|
+
return 500;
|
|
14
|
+
},
|
|
15
|
+
maskOpacity: 0.3,
|
|
16
|
+
toolbarRender: function toolbarRender(_ref2) {
|
|
17
|
+
var onScale = _ref2.onScale,
|
|
18
|
+
scale = _ref2.scale,
|
|
19
|
+
rotate = _ref2.rotate,
|
|
20
|
+
onRotate = _ref2.onRotate;
|
|
21
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("svg", {
|
|
22
|
+
width: "44",
|
|
23
|
+
height: "44",
|
|
24
|
+
viewBox: "0 0 768 768",
|
|
25
|
+
className: "PhotoView-Slider__toolbarIcon",
|
|
26
|
+
onClick: function onClick() {
|
|
27
|
+
return onScale(scale + 1);
|
|
28
|
+
}
|
|
29
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
30
|
+
d: "M384 640.5q105 0 180.75-75.75t75.75-180.75-75.75-180.75-180.75-75.75-180.75 75.75-75.75 180.75 75.75 180.75 180.75 75.75zM384 64.5q132 0 225.75 93.75t93.75 225.75-93.75 225.75-225.75 93.75-225.75-93.75-93.75-225.75 93.75-225.75 225.75-93.75zM415.5 223.5v129h129v63h-129v129h-63v-129h-129v-63h129v-129h63z"
|
|
31
|
+
})), /*#__PURE__*/React.createElement("svg", {
|
|
32
|
+
width: "44",
|
|
33
|
+
height: "44",
|
|
34
|
+
viewBox: "0 0 768 768",
|
|
35
|
+
className: "PhotoView-Slider__toolbarIcon",
|
|
36
|
+
onClick: function onClick() {
|
|
37
|
+
return onScale(scale - 1);
|
|
38
|
+
}
|
|
39
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
40
|
+
d: "M384 640.5q105 0 180.75-75.75t75.75-180.75-75.75-180.75-180.75-75.75-180.75 75.75-75.75 180.75 75.75 180.75 180.75 75.75zM384 64.5q132 0 225.75 93.75t93.75 225.75-93.75 225.75-225.75 93.75-225.75-93.75-93.75-225.75 93.75-225.75 225.75-93.75zM223.5 352.5h321v63h-321v-63z"
|
|
41
|
+
})), /*#__PURE__*/React.createElement("svg", {
|
|
42
|
+
width: "44",
|
|
43
|
+
height: "44",
|
|
44
|
+
viewBox: "0 0 768 768",
|
|
45
|
+
className: "PhotoView-Slider__toolbarIcon",
|
|
46
|
+
onClick: function onClick() {
|
|
47
|
+
return onRotate(rotate + 90);
|
|
48
|
+
}
|
|
49
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
50
|
+
d: "M565.5 202.5l75-75v225h-225l103.5-103.5c-34.5-34.5-82.5-57-135-57-106.5 0-192 85.5-192 192s85.5 192 192 192c84 0 156-52.5 181.5-127.5h66c-28.5 111-127.5 192-247.5 192-141 0-255-115.5-255-256.5s114-256.5 255-256.5c70.5 0 135 28.5 181.5 75z"
|
|
51
|
+
})));
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/React.createElement(SelectionText, {
|
|
11
54
|
editor: editor,
|
|
12
55
|
more: menuInBubbleMenu
|
|
13
56
|
}), /*#__PURE__*/React.createElement(CustomDragHandle, {
|
package/dist/EditorDiff/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EditorContent } from "@tiptap/react";
|
|
2
2
|
import React, { useEffect } from "react";
|
|
3
|
+
import { PhotoProvider } from "react-photo-view";
|
|
3
4
|
import useTiptap from "../hook";
|
|
4
5
|
var EditorDiff = function EditorDiff(_ref) {
|
|
5
6
|
var oldHtml = _ref.oldHtml,
|
|
@@ -17,8 +18,50 @@ var EditorDiff = function EditorDiff(_ref) {
|
|
|
17
18
|
(_editorRef$editor = editorRef.editor) === null || _editorRef$editor === void 0 || (_editorRef$editor$com = (_editorRef$editor$com2 = _editorRef$editor.commands).hideStructuredDiff) === null || _editorRef$editor$com === void 0 || _editorRef$editor$com.call(_editorRef$editor$com2);
|
|
18
19
|
};
|
|
19
20
|
}, [oldHtml, newHtml, editorRef.editor]);
|
|
20
|
-
return /*#__PURE__*/React.createElement(
|
|
21
|
+
return /*#__PURE__*/React.createElement(PhotoProvider, {
|
|
22
|
+
speed: function speed() {
|
|
23
|
+
return 500;
|
|
24
|
+
},
|
|
25
|
+
maskOpacity: 0.3,
|
|
26
|
+
toolbarRender: function toolbarRender(_ref2) {
|
|
27
|
+
var onScale = _ref2.onScale,
|
|
28
|
+
scale = _ref2.scale,
|
|
29
|
+
rotate = _ref2.rotate,
|
|
30
|
+
onRotate = _ref2.onRotate;
|
|
31
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("svg", {
|
|
32
|
+
width: "44",
|
|
33
|
+
height: "44",
|
|
34
|
+
viewBox: "0 0 768 768",
|
|
35
|
+
className: "PhotoView-Slider__toolbarIcon",
|
|
36
|
+
onClick: function onClick() {
|
|
37
|
+
return onScale(scale + 1);
|
|
38
|
+
}
|
|
39
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
40
|
+
d: "M384 640.5q105 0 180.75-75.75t75.75-180.75-75.75-180.75-180.75-75.75-180.75 75.75-75.75 180.75 75.75 180.75 180.75 75.75zM384 64.5q132 0 225.75 93.75t93.75 225.75-93.75 225.75-225.75 93.75-225.75-93.75-93.75-225.75 93.75-225.75 225.75-93.75zM415.5 223.5v129h129v63h-129v129h-63v-129h-129v-63h129v-129h63z"
|
|
41
|
+
})), /*#__PURE__*/React.createElement("svg", {
|
|
42
|
+
width: "44",
|
|
43
|
+
height: "44",
|
|
44
|
+
viewBox: "0 0 768 768",
|
|
45
|
+
className: "PhotoView-Slider__toolbarIcon",
|
|
46
|
+
onClick: function onClick() {
|
|
47
|
+
return onScale(scale - 1);
|
|
48
|
+
}
|
|
49
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
50
|
+
d: "M384 640.5q105 0 180.75-75.75t75.75-180.75-75.75-180.75-180.75-75.75-180.75 75.75-75.75 180.75 75.75 180.75 180.75 75.75zM384 64.5q132 0 225.75 93.75t93.75 225.75-93.75 225.75-225.75 93.75-225.75-93.75-93.75-225.75 93.75-225.75 225.75-93.75zM223.5 352.5h321v63h-321v-63z"
|
|
51
|
+
})), /*#__PURE__*/React.createElement("svg", {
|
|
52
|
+
width: "44",
|
|
53
|
+
height: "44",
|
|
54
|
+
viewBox: "0 0 768 768",
|
|
55
|
+
className: "PhotoView-Slider__toolbarIcon",
|
|
56
|
+
onClick: function onClick() {
|
|
57
|
+
return onRotate(rotate + 90);
|
|
58
|
+
}
|
|
59
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
60
|
+
d: "M565.5 202.5l75-75v225h-225l103.5-103.5c-34.5-34.5-82.5-57-135-57-106.5 0-192 85.5-192 192s85.5 192 192 192c84 0 156-52.5 181.5-127.5h66c-28.5 111-127.5 192-247.5 192-141 0-255-115.5-255-256.5s114-256.5 255-256.5c70.5 0 135 28.5 181.5 75z"
|
|
61
|
+
})));
|
|
62
|
+
}
|
|
63
|
+
}, /*#__PURE__*/React.createElement(EditorContent, {
|
|
21
64
|
editor: editorRef.editor
|
|
22
|
-
});
|
|
65
|
+
}));
|
|
23
66
|
};
|
|
24
67
|
export default EditorDiff;
|
|
@@ -54,14 +54,13 @@ var SelectionText = function SelectionText(_ref) {
|
|
|
54
54
|
return /*#__PURE__*/React.createElement(BubbleMenu, {
|
|
55
55
|
editor: editor,
|
|
56
56
|
pluginKey: 'bubble-menu',
|
|
57
|
+
updateDelay: 750,
|
|
57
58
|
options: {
|
|
58
59
|
placement: 'bottom',
|
|
59
60
|
offset: 8
|
|
60
61
|
},
|
|
61
62
|
shouldShow: function shouldShow(_ref2) {
|
|
62
|
-
var editorProps = _ref2.editor
|
|
63
|
-
from = _ref2.from,
|
|
64
|
-
to = _ref2.to;
|
|
63
|
+
var editorProps = _ref2.editor;
|
|
65
64
|
if (editorProps.state.selection.empty || editorProps.isActive('image') || editorProps.isActive('video') || editorProps.isActive('audio') || editorProps.isActive('emoji') || editorProps.isActive('codeBlock') || editorProps.isActive('blockMath') || editorProps.isActive('inlineMath') || editorProps.isActive('blockLink') || editorProps.isActive('inlineLink') || editorProps.isActive('blockAttachment') || editorProps.isActive('inlineAttachment') || editorProps.isActive('horizontalRule') || editorProps.isActive('iframe')) {
|
|
66
65
|
return false;
|
|
67
66
|
}
|
|
@@ -240,21 +240,6 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
|
|
|
240
240
|
var attrs = current.editor.getAttributes(node.type.name);
|
|
241
241
|
return Number(attrs.indent) || 0;
|
|
242
242
|
};
|
|
243
|
-
var shouldShowButton = function shouldShowButton(_ref4) {
|
|
244
|
-
var editor = _ref4.editor,
|
|
245
|
-
data = _ref4.data;
|
|
246
|
-
if (!editor || !editor.isEditable) return false;
|
|
247
|
-
var currentNode = data.node;
|
|
248
|
-
var empty = (currentNode === null || currentNode === void 0 ? void 0 : currentNode.textContent) === '';
|
|
249
|
-
if (empty) return false;
|
|
250
|
-
var content = currentNode === null || currentNode === void 0 ? void 0 : currentNode.content.content;
|
|
251
|
-
if (content && content.length > 0) {
|
|
252
|
-
return content.some(function (item) {
|
|
253
|
-
return hasMarksDeep(item);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
return false;
|
|
257
|
-
};
|
|
258
243
|
var updateNodeChange = useCallback(function (data) {
|
|
259
244
|
var _data$node, _current$node2;
|
|
260
245
|
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) {
|
|
@@ -286,20 +271,57 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
|
|
|
286
271
|
mr: 1,
|
|
287
272
|
height: '1.625rem'
|
|
288
273
|
}
|
|
289
|
-
}, /*#__PURE__*/React.createElement(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
274
|
+
}, /*#__PURE__*/React.createElement(Menu, {
|
|
275
|
+
context: /*#__PURE__*/React.createElement(AddIcon, null),
|
|
276
|
+
anchorOrigin: {
|
|
277
|
+
vertical: 'bottom',
|
|
278
|
+
horizontal: 'left'
|
|
279
|
+
},
|
|
280
|
+
transformOrigin: {
|
|
281
|
+
vertical: 'top',
|
|
282
|
+
horizontal: 'left'
|
|
283
|
+
},
|
|
284
|
+
arrowIcon: /*#__PURE__*/React.createElement(ArrowDownSLineIcon, {
|
|
285
|
+
sx: {
|
|
286
|
+
fontSize: '1rem',
|
|
287
|
+
transform: 'rotate(-90deg)'
|
|
288
|
+
}
|
|
289
|
+
}),
|
|
290
|
+
list: [{
|
|
291
|
+
label: '上方插入行',
|
|
292
|
+
key: 'insert-line-break-top',
|
|
293
|
+
icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
|
|
294
|
+
sx: {
|
|
295
|
+
fontSize: '1rem',
|
|
296
|
+
transform: 'rotate(180deg)'
|
|
297
|
+
}
|
|
298
|
+
}),
|
|
299
|
+
onClick: function onClick() {
|
|
300
|
+
if (current.node && current.pos !== undefined) {
|
|
301
|
+
var afterPos = current.pos;
|
|
302
|
+
current.editor.chain().focus().insertContentAt(afterPos, {
|
|
295
303
|
type: 'paragraph',
|
|
296
304
|
content: [{
|
|
297
305
|
type: 'text',
|
|
298
306
|
text: '/'
|
|
299
307
|
}]
|
|
308
|
+
}, {
|
|
309
|
+
updateSelection: true
|
|
300
310
|
}).run();
|
|
301
|
-
}
|
|
302
|
-
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}, {
|
|
314
|
+
label: '下方插入行',
|
|
315
|
+
key: 'insert-line-break',
|
|
316
|
+
icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
|
|
317
|
+
sx: {
|
|
318
|
+
fontSize: '1rem'
|
|
319
|
+
}
|
|
320
|
+
}),
|
|
321
|
+
onClick: function onClick() {
|
|
322
|
+
if (current.node && current.pos !== undefined) {
|
|
323
|
+
var afterPos = current.pos + current.node.nodeSize;
|
|
324
|
+
current.editor.chain().focus().insertContentAt(afterPos, {
|
|
303
325
|
type: 'paragraph',
|
|
304
326
|
content: [{
|
|
305
327
|
type: 'text',
|
|
@@ -308,9 +330,9 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
|
|
|
308
330
|
}).run();
|
|
309
331
|
}
|
|
310
332
|
}
|
|
311
|
-
}
|
|
333
|
+
}]
|
|
312
334
|
}), currentNode ? /*#__PURE__*/React.createElement(Menu, {
|
|
313
|
-
width:
|
|
335
|
+
width: 216,
|
|
314
336
|
context: /*#__PURE__*/React.createElement(DragIcon, null),
|
|
315
337
|
anchorOrigin: {
|
|
316
338
|
vertical: 'bottom',
|
|
@@ -503,47 +525,6 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
|
|
|
503
525
|
}
|
|
504
526
|
}),
|
|
505
527
|
tip: "\u5220\u9664".concat(currentNode === null || currentNode === void 0 ? void 0 : currentNode.label)
|
|
506
|
-
})), /*#__PURE__*/React.createElement(Stack, {
|
|
507
|
-
direction: 'row',
|
|
508
|
-
flexWrap: 'wrap',
|
|
509
|
-
sx: {
|
|
510
|
-
fontSize: 14
|
|
511
|
-
}
|
|
512
|
-
}, /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
513
|
-
key: 'insert-line-break-top',
|
|
514
|
-
onClick: function onClick() {
|
|
515
|
-
if (current.node && current.pos !== undefined) {
|
|
516
|
-
var afterPos = current.pos;
|
|
517
|
-
current.editor.chain().focus().insertContentAt(afterPos, {
|
|
518
|
-
type: 'paragraph'
|
|
519
|
-
}, {
|
|
520
|
-
updateSelection: true
|
|
521
|
-
}).run();
|
|
522
|
-
}
|
|
523
|
-
},
|
|
524
|
-
icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
|
|
525
|
-
sx: {
|
|
526
|
-
fontSize: '1rem',
|
|
527
|
-
transform: 'rotate(180deg)'
|
|
528
|
-
}
|
|
529
|
-
}),
|
|
530
|
-
text: '上方插入行'
|
|
531
|
-
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
532
|
-
key: 'insert-line-break',
|
|
533
|
-
onClick: function onClick() {
|
|
534
|
-
if (current.node && current.pos !== undefined) {
|
|
535
|
-
var afterPos = current.pos + current.node.nodeSize;
|
|
536
|
-
current.editor.chain().focus().insertContentAt(afterPos, {
|
|
537
|
-
type: 'paragraph'
|
|
538
|
-
}).run();
|
|
539
|
-
}
|
|
540
|
-
},
|
|
541
|
-
icon: /*#__PURE__*/React.createElement(TextWrapIcon, {
|
|
542
|
-
sx: {
|
|
543
|
-
fontSize: '1rem'
|
|
544
|
-
}
|
|
545
|
-
}),
|
|
546
|
-
text: '下方插入行'
|
|
547
528
|
})), /*#__PURE__*/React.createElement(Divider, {
|
|
548
529
|
sx: {
|
|
549
530
|
my: 0.5
|
|
@@ -101,7 +101,10 @@ var AlertView = function AlertView(_ref) {
|
|
|
101
101
|
}
|
|
102
102
|
}, variantData.icon), /*#__PURE__*/React.createElement(Box, {
|
|
103
103
|
sx: {
|
|
104
|
-
flex: 1
|
|
104
|
+
flex: 1,
|
|
105
|
+
'code': {
|
|
106
|
+
bgcolor: attrs.variant === 'default' ? '' : "color-mix(in srgb, ".concat(variantData.color, " 20%, transparent) !important")
|
|
107
|
+
}
|
|
105
108
|
}
|
|
106
109
|
}, /*#__PURE__*/React.createElement(NodeViewContent, {
|
|
107
110
|
as: 'div'
|
|
@@ -1,8 +1,7 @@
|
|
|
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
1
|
import { Box } from "@mui/material";
|
|
3
2
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
4
3
|
import React from "react";
|
|
5
|
-
import {
|
|
4
|
+
import { PhotoView } from "react-photo-view";
|
|
6
5
|
import 'react-photo-view/dist/react-photo-view.css';
|
|
7
6
|
var ReadonlyImage = function ReadonlyImage(_ref) {
|
|
8
7
|
var attrs = _ref.attrs;
|
|
@@ -16,24 +15,10 @@ var ReadonlyImage = function ReadonlyImage(_ref) {
|
|
|
16
15
|
border: '1px solid',
|
|
17
16
|
borderColor: 'divider',
|
|
18
17
|
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
19
|
-
p: '0.25rem'
|
|
20
|
-
'&:hover .image-controls': {
|
|
21
|
-
opacity: 1
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}, /*#__PURE__*/React.createElement(PhotoProvider, null, /*#__PURE__*/React.createElement(PhotoView, {
|
|
25
|
-
render: function render(props) {
|
|
26
|
-
return /*#__PURE__*/React.createElement("img", _extends({}, props.attrs, {
|
|
27
|
-
src: attrs.src,
|
|
28
|
-
style: {
|
|
29
|
-
transformOrigin: '0 0',
|
|
30
|
-
transform: 'translate(-50%, -50%)',
|
|
31
|
-
backgroundColor: 'hsl(0, 0%, 90%)',
|
|
32
|
-
maxWidth: '100%',
|
|
33
|
-
maxHeight: '90%'
|
|
34
|
-
}
|
|
35
|
-
}));
|
|
18
|
+
p: '0.25rem'
|
|
36
19
|
}
|
|
20
|
+
}, /*#__PURE__*/React.createElement(PhotoView, {
|
|
21
|
+
src: attrs.src
|
|
37
22
|
}, /*#__PURE__*/React.createElement("img", {
|
|
38
23
|
src: attrs.src,
|
|
39
24
|
width: attrs.width,
|
|
@@ -45,6 +30,6 @@ var ReadonlyImage = function ReadonlyImage(_ref) {
|
|
|
45
30
|
onError: function onError(e) {
|
|
46
31
|
console.error('Image load error:', e);
|
|
47
32
|
}
|
|
48
|
-
}))))
|
|
33
|
+
}))));
|
|
49
34
|
};
|
|
50
35
|
export default ReadonlyImage;
|
|
@@ -185,18 +185,18 @@ var TableContextMenu = function TableContextMenu(_ref) {
|
|
|
185
185
|
})
|
|
186
186
|
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
187
187
|
onClick: function onClick() {
|
|
188
|
-
return editor.chain().focus().
|
|
188
|
+
return editor.chain().focus().toggleStrike().run();
|
|
189
189
|
},
|
|
190
|
-
icon: /*#__PURE__*/React.createElement(
|
|
190
|
+
icon: /*#__PURE__*/React.createElement(StrikethroughIcon, {
|
|
191
191
|
sx: {
|
|
192
192
|
fontSize: '1rem'
|
|
193
193
|
}
|
|
194
194
|
})
|
|
195
195
|
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
196
196
|
onClick: function onClick() {
|
|
197
|
-
return editor.chain().focus().
|
|
197
|
+
return editor.chain().focus().toggleUnderline().run();
|
|
198
198
|
},
|
|
199
|
-
icon: /*#__PURE__*/React.createElement(
|
|
199
|
+
icon: /*#__PURE__*/React.createElement(UnderlineIcon, {
|
|
200
200
|
sx: {
|
|
201
201
|
fontSize: '1rem'
|
|
202
202
|
}
|
|
@@ -51,19 +51,10 @@ var isClickedCellInSelection = function isClickedCellInSelection(editor, clicked
|
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
53
|
var cellSelection = selection;
|
|
54
|
-
// 使用范围判断不精确,直接使用ranges判断
|
|
55
54
|
var ranges = cellSelection.ranges.map(function (it) {
|
|
56
55
|
return it.$from.pos;
|
|
57
56
|
});
|
|
58
57
|
return ranges.includes(domPosition);
|
|
59
|
-
// if (cellSelection.$anchorCell && cellSelection.$headCell) {
|
|
60
|
-
// const anchorPos = cellSelection.$anchorCell.pos;
|
|
61
|
-
// const headPos = cellSelection.$headCell.pos;
|
|
62
|
-
// const minPos = Math.min(anchorPos, headPos);
|
|
63
|
-
// const maxPos = Math.max(anchorPos, headPos);
|
|
64
|
-
// return domPosition >= minPos && domPosition <= maxPos;
|
|
65
|
-
// }
|
|
66
|
-
// return domPosition >= selection.from && domPosition <= selection.to;
|
|
67
58
|
} catch (error) {
|
|
68
59
|
console.warn('Error checking if clicked cell is in selection:', error);
|
|
69
60
|
return false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UploadFunction } from "../../type";
|
|
2
2
|
export declare const FileHandlerExtension: (props: {
|
|
3
3
|
onUpload?: UploadFunction;
|
|
4
|
-
}) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "
|
|
4
|
+
}) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "editor" | "key">, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/core';
|
|
2
2
|
export declare const TableExtension: ({ editable }: {
|
|
3
3
|
editable: boolean;
|
|
4
|
-
}) => (
|
|
4
|
+
}) => (import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableHeaderOptions, any> | Extension<any, any>)[];
|
|
5
5
|
export default TableExtension;
|
|
@@ -12,7 +12,6 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
12
12
|
import { Extension } from '@tiptap/core';
|
|
13
13
|
import { Table, TableCell, TableHeader, TableRow } from '@tiptap/extension-table';
|
|
14
14
|
import { Plugin, TextSelection } from '@tiptap/pm/state';
|
|
15
|
-
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
|
16
15
|
import { createTableContextMenuPlugin } from "../component/Table";
|
|
17
16
|
export var TableExtension = function TableExtension(_ref) {
|
|
18
17
|
var editable = _ref.editable;
|
|
@@ -174,36 +173,6 @@ export var TableExtension = function TableExtension(_ref) {
|
|
|
174
173
|
return editable ? [createTableContextMenuPlugin(this.editor)] : [];
|
|
175
174
|
}
|
|
176
175
|
}),
|
|
177
|
-
// 选中表格时为 table 添加聚焦样式类名
|
|
178
|
-
Extension.create({
|
|
179
|
-
name: 'tableActiveClass',
|
|
180
|
-
addProseMirrorPlugins: function addProseMirrorPlugins() {
|
|
181
|
-
if (!editable) return [];
|
|
182
|
-
return [new Plugin({
|
|
183
|
-
props: {
|
|
184
|
-
decorations: function decorations(state) {
|
|
185
|
-
var selection = state.selection,
|
|
186
|
-
doc = state.doc;
|
|
187
|
-
var $from = selection.$from;
|
|
188
|
-
// 如果当前不在表格内,移除装饰
|
|
189
|
-
// 通过向上寻找最近的 table 节点
|
|
190
|
-
for (var depth = $from.depth; depth > 0; depth--) {
|
|
191
|
-
var node = $from.node(depth);
|
|
192
|
-
if (node.type.name === 'table') {
|
|
193
|
-
var from = $from.before(depth);
|
|
194
|
-
var to = $from.after(depth);
|
|
195
|
-
var deco = Decoration.node(from, to, {
|
|
196
|
-
class: 'table-focus'
|
|
197
|
-
});
|
|
198
|
-
return DecorationSet.create(doc, [deco]);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
})];
|
|
205
|
-
}
|
|
206
|
-
}),
|
|
207
176
|
// Safari 中文输入 deleteCompositionText 修复
|
|
208
177
|
Extension.create({
|
|
209
178
|
name: 'safariCompositionDeleteFix',
|
package/dist/index.css
CHANGED
|
@@ -392,42 +392,28 @@
|
|
|
392
392
|
text-align: left;
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
-
/* 表格数据单元格样式 */
|
|
396
395
|
.tiptap.ProseMirror table td {
|
|
397
396
|
background-color: var(--mui-palette-background-default);
|
|
398
397
|
}
|
|
399
398
|
|
|
400
|
-
|
|
401
|
-
.tiptap.ProseMirror[contenteditable="true"] table {
|
|
399
|
+
.tiptap.ProseMirror table {
|
|
402
400
|
border-left: 1px dotted var(--mui-palette-divider);
|
|
403
401
|
border-right: 1px dotted var(--mui-palette-divider);
|
|
404
402
|
}
|
|
405
403
|
|
|
406
|
-
.tiptap.ProseMirror
|
|
407
|
-
.tiptap.ProseMirror
|
|
404
|
+
.tiptap.ProseMirror table td,
|
|
405
|
+
.tiptap.ProseMirror table th {
|
|
408
406
|
border-right-color: var(--mui-palette-divider);
|
|
409
407
|
border-right-style: dotted;
|
|
410
408
|
}
|
|
411
409
|
|
|
412
|
-
.tiptap.ProseMirror
|
|
413
|
-
.tiptap.ProseMirror
|
|
410
|
+
.tiptap.ProseMirror table td:last-child,
|
|
411
|
+
.tiptap.ProseMirror table th:last-child {
|
|
414
412
|
border-right-color: transparent;
|
|
415
413
|
}
|
|
416
414
|
|
|
417
|
-
.tiptap.ProseMirror[contenteditable="
|
|
418
|
-
|
|
419
|
-
border-right: 1px dotted var(--mui-palette-divider);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
.tiptap.ProseMirror[contenteditable="false"] table td,
|
|
423
|
-
.tiptap.ProseMirror[contenteditable="false"] table th {
|
|
424
|
-
border-right-color: var(--mui-palette-divider);
|
|
425
|
-
border-right-style: dotted;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
.tiptap.ProseMirror[contenteditable="false"] table td:last-child,
|
|
429
|
-
.tiptap.ProseMirror[contenteditable="false"] table th:last-child {
|
|
430
|
-
border-right-color: transparent;
|
|
415
|
+
.tiptap.ProseMirror[contenteditable="true"] table .selectedCell * {
|
|
416
|
+
pointer-events: none;
|
|
431
417
|
}
|
|
432
418
|
|
|
433
419
|
/* 表格选择状态 */
|
|
@@ -441,19 +427,8 @@
|
|
|
441
427
|
pointer-events: none;
|
|
442
428
|
position: absolute;
|
|
443
429
|
z-index: 2;
|
|
444
|
-
/* border-radius: 4px; */
|
|
445
|
-
/* border: 2px solid var(--mui-palette-primary-main); */
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
.tiptap.ProseMirror[contenteditable="true"] table .selectedCell {
|
|
449
|
-
background-color: color-mix(in srgb, var(--mui-palette-primary-main) 5%, transparent) !important;
|
|
450
430
|
}
|
|
451
431
|
|
|
452
|
-
/* 选中单元格的边框样式 - 只改变最外圈边框颜色 */
|
|
453
|
-
/* .tiptap.ProseMirror[contenteditable="true"] table .selectedCell {
|
|
454
|
-
border-color: var(--mui-palette-primary-main) !important;
|
|
455
|
-
} */
|
|
456
|
-
|
|
457
432
|
/* 表格列调整手柄 */
|
|
458
433
|
.tiptap.ProseMirror[contenteditable="true"] table .column-resize-handle {
|
|
459
434
|
background-color: transparent;
|
|
@@ -521,17 +496,6 @@
|
|
|
521
496
|
}
|
|
522
497
|
}
|
|
523
498
|
|
|
524
|
-
.PhotoView-Slider__Backdrop {
|
|
525
|
-
background: rgba(33, 34, 45, 0.3) !important;
|
|
526
|
-
backdrop-filter: blur(5px);
|
|
527
|
-
transition: none !important;
|
|
528
|
-
animation-duration: none !important;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
.PhotoView-Slider__BannerWrap {
|
|
532
|
-
background-color: rgba(33, 34, 45, 0.2) !important;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
499
|
.slash-decoration[data-decoration-content].is-empty {
|
|
536
500
|
padding: 4px 8px;
|
|
537
501
|
background-color: var(--mui-palette-background-paper2);
|