@ctzhian/tiptap 1.6.19 → 1.6.20
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/EditorToolbar/index.js +2 -2
- package/dist/extension/component/UploadProgress/Inline.d.ts +10 -0
- package/dist/extension/component/UploadProgress/Inline.js +80 -0
- package/dist/extension/component/UploadProgress/index.d.ts +3 -1
- package/dist/extension/component/UploadProgress/index.js +41 -33
- package/dist/extension/index.js +2 -2
- package/dist/extension/node/FileHandler.js +237 -206
- package/dist/extension/node/Image.js +144 -1
- package/dist/extension/node/InlineUploadProgress.d.ts +12 -0
- package/dist/extension/node/InlineUploadProgress.js +136 -0
- package/dist/extension/node/index.d.ts +1 -0
- package/dist/extension/node/index.js +1 -0
- package/dist/util/fileHandler.d.ts +1 -1
- package/dist/util/fileHandler.js +3 -0
- package/package.json +31 -31
|
@@ -33,7 +33,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
33
33
|
active = _useState2[0],
|
|
34
34
|
setActive = _useState2[1];
|
|
35
35
|
var updateSelection = function updateSelection() {
|
|
36
|
-
var _editor$can$chain$und, _editor$can$chain$red, _editor$can$chain$uns;
|
|
36
|
+
var _editor$can$chain$und, _editor$can$chain$red, _editor$can$chain$uns, _editor$storage;
|
|
37
37
|
setActive({
|
|
38
38
|
undo: (_editor$can$chain$und = editor.can().chain().undo().run()) !== null && _editor$can$chain$und !== void 0 ? _editor$can$chain$und : false,
|
|
39
39
|
redo: (_editor$can$chain$red = editor.can().chain().redo().run()) !== null && _editor$can$chain$red !== void 0 ? _editor$can$chain$red : false,
|
|
@@ -50,7 +50,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
50
50
|
link: editor.isActive('link'),
|
|
51
51
|
alert: editor.isActive('alert'),
|
|
52
52
|
iframe: editor.isActive('iframe'),
|
|
53
|
-
aiWriting: editor.storage.aiWriting.enabled
|
|
53
|
+
aiWriting: !!((_editor$storage = editor.storage) !== null && _editor$storage !== void 0 && (_editor$storage = _editor$storage.aiWriting) !== null && _editor$storage !== void 0 && _editor$storage.enabled)
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
56
|
useEffect(function () {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NodeViewProps } from '@tiptap/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface InlineUploadProgressAttributes {
|
|
4
|
+
fileName: string;
|
|
5
|
+
fileType: 'image';
|
|
6
|
+
progress: number;
|
|
7
|
+
tempId: string;
|
|
8
|
+
}
|
|
9
|
+
declare const InlineUploadProgressView: React.FC<NodeViewProps>;
|
|
10
|
+
export default InlineUploadProgressView;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { Box, CircularProgress, Stack } from '@mui/material';
|
|
8
|
+
import { NodeViewWrapper } from '@tiptap/react';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { getFileIcon, getFileTypeText } from '.';
|
|
11
|
+
var InlineUploadProgressView = function InlineUploadProgressView(_ref) {
|
|
12
|
+
var node = _ref.node;
|
|
13
|
+
var attrs = node.attrs;
|
|
14
|
+
return /*#__PURE__*/React.createElement(NodeViewWrapper, {
|
|
15
|
+
className: "inline-upload-progress-wrapper",
|
|
16
|
+
style: {
|
|
17
|
+
display: 'inline-flex'
|
|
18
|
+
}
|
|
19
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
20
|
+
component: "span",
|
|
21
|
+
direction: "row",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
gap: 1,
|
|
24
|
+
sx: _objectSpread({
|
|
25
|
+
position: 'relative',
|
|
26
|
+
border: '1px dashed',
|
|
27
|
+
borderColor: 'divider',
|
|
28
|
+
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
29
|
+
p: 2,
|
|
30
|
+
maxWidth: '100%'
|
|
31
|
+
}, !attrs.progress ? {
|
|
32
|
+
cursor: 'pointer',
|
|
33
|
+
'&:hover': {
|
|
34
|
+
bgcolor: 'action.hover'
|
|
35
|
+
},
|
|
36
|
+
'&:active': {
|
|
37
|
+
bgcolor: 'action.selected'
|
|
38
|
+
}
|
|
39
|
+
} : {
|
|
40
|
+
"&::before": {
|
|
41
|
+
content: '""',
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
top: 0,
|
|
44
|
+
left: 0,
|
|
45
|
+
height: '100%',
|
|
46
|
+
width: "".concat(attrs.progress * 100, "%"),
|
|
47
|
+
bgcolor: 'primary.main',
|
|
48
|
+
opacity: 0.1,
|
|
49
|
+
transition: 'width 0.3s ease'
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
"data-temp-id": attrs.tempId
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
54
|
+
direction: "row",
|
|
55
|
+
alignItems: "center",
|
|
56
|
+
justifyContent: "space-between",
|
|
57
|
+
gap: 2
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
59
|
+
direction: "row",
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
gap: 2
|
|
62
|
+
}, getFileIcon(attrs.fileType), /*#__PURE__*/React.createElement(Box, {
|
|
63
|
+
sx: {
|
|
64
|
+
fontSize: '0.875rem',
|
|
65
|
+
color: 'text.primary'
|
|
66
|
+
}
|
|
67
|
+
}, "\u6B63\u5728\u4E0A\u4F20", getFileTypeText(attrs.fileType), "\uFF1A", attrs.fileName)), /*#__PURE__*/React.createElement(Stack, {
|
|
68
|
+
direction: "row",
|
|
69
|
+
alignItems: "center",
|
|
70
|
+
gap: 1
|
|
71
|
+
}, attrs.progress < 1 && /*#__PURE__*/React.createElement(CircularProgress, {
|
|
72
|
+
size: 14
|
|
73
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
74
|
+
sx: {
|
|
75
|
+
fontSize: '0.75rem',
|
|
76
|
+
color: 'text.secondary'
|
|
77
|
+
}
|
|
78
|
+
}, Math.round(attrs.progress * 100), "%")))));
|
|
79
|
+
};
|
|
80
|
+
export default InlineUploadProgressView;
|
|
@@ -2,9 +2,11 @@ import { NodeViewProps } from '@tiptap/react';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export interface UploadProgressAttributes {
|
|
4
4
|
fileName: string;
|
|
5
|
-
fileType: 'image' | 'video' | 'other';
|
|
5
|
+
fileType: 'image' | 'video' | 'audio' | 'other';
|
|
6
6
|
progress: number;
|
|
7
7
|
tempId: string;
|
|
8
8
|
}
|
|
9
|
+
export declare const getFileIcon: (fileType: string) => React.JSX.Element;
|
|
10
|
+
export declare const getFileTypeText: (fileType: string) => "图片" | "视频" | "音频" | "文件";
|
|
9
11
|
declare const UploadProgressView: React.FC<NodeViewProps>;
|
|
10
12
|
export default UploadProgressView;
|
|
@@ -4,45 +4,53 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
import { AttachmentLineIcon, ImageLineIcon, MovieLineIcon } from "../../../component/Icons";
|
|
7
|
+
import { AttachmentLineIcon, ImageLineIcon, MovieLineIcon, Music2LineIcon } from "../../../component/Icons";
|
|
8
8
|
import { Box, CircularProgress, Stack } from '@mui/material';
|
|
9
9
|
import { NodeViewWrapper } from '@tiptap/react';
|
|
10
10
|
import React from 'react';
|
|
11
|
+
export var getFileIcon = function getFileIcon(fileType) {
|
|
12
|
+
switch (fileType) {
|
|
13
|
+
case 'image':
|
|
14
|
+
return /*#__PURE__*/React.createElement(ImageLineIcon, {
|
|
15
|
+
sx: {
|
|
16
|
+
fontSize: '1rem'
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
case 'video':
|
|
20
|
+
return /*#__PURE__*/React.createElement(MovieLineIcon, {
|
|
21
|
+
sx: {
|
|
22
|
+
fontSize: '1rem'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
case 'audio':
|
|
26
|
+
return /*#__PURE__*/React.createElement(Music2LineIcon, {
|
|
27
|
+
sx: {
|
|
28
|
+
fontSize: '1rem'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
default:
|
|
32
|
+
return /*#__PURE__*/React.createElement(AttachmentLineIcon, {
|
|
33
|
+
sx: {
|
|
34
|
+
fontSize: '1rem'
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export var getFileTypeText = function getFileTypeText(fileType) {
|
|
40
|
+
switch (fileType) {
|
|
41
|
+
case 'image':
|
|
42
|
+
return '图片';
|
|
43
|
+
case 'video':
|
|
44
|
+
return '视频';
|
|
45
|
+
case 'audio':
|
|
46
|
+
return '音频';
|
|
47
|
+
default:
|
|
48
|
+
return '文件';
|
|
49
|
+
}
|
|
50
|
+
};
|
|
11
51
|
var UploadProgressView = function UploadProgressView(_ref) {
|
|
12
52
|
var node = _ref.node;
|
|
13
53
|
var attrs = node.attrs;
|
|
14
|
-
var getFileIcon = function getFileIcon(fileType) {
|
|
15
|
-
switch (fileType) {
|
|
16
|
-
case 'image':
|
|
17
|
-
return /*#__PURE__*/React.createElement(ImageLineIcon, {
|
|
18
|
-
sx: {
|
|
19
|
-
fontSize: '1rem'
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
case 'video':
|
|
23
|
-
return /*#__PURE__*/React.createElement(MovieLineIcon, {
|
|
24
|
-
sx: {
|
|
25
|
-
fontSize: '1rem'
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
default:
|
|
29
|
-
return /*#__PURE__*/React.createElement(AttachmentLineIcon, {
|
|
30
|
-
sx: {
|
|
31
|
-
fontSize: '1rem'
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var getFileTypeText = function getFileTypeText(fileType) {
|
|
37
|
-
switch (fileType) {
|
|
38
|
-
case 'image':
|
|
39
|
-
return '图片';
|
|
40
|
-
case 'video':
|
|
41
|
-
return '视频';
|
|
42
|
-
default:
|
|
43
|
-
return '文件';
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
54
|
return /*#__PURE__*/React.createElement(NodeViewWrapper, {
|
|
47
55
|
className: "upload-progress-wrapper"
|
|
48
56
|
}, /*#__PURE__*/React.createElement(Box, {
|
package/dist/extension/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import StarterKit from '@tiptap/starter-kit';
|
|
|
15
15
|
import { PLACEHOLDER } from "../contants/placeholder";
|
|
16
16
|
import { AiWritingExtension, SlashCommands, StructuredDiffExtension } from "./extension";
|
|
17
17
|
import { CodeExtension } from "./mark/Code";
|
|
18
|
-
import { AlertExtension, AudioExtension, BlockAttachmentExtension, BlockLinkExtension, CodeBlockLowlightExtension, CustomBlockMathExtension, CustomInlineMathExtension, DetailsContentExtension, DetailsExtension, DetailsSummaryExtension, EmojiExtension, FileHandlerExtension, IframeExtension, ImageExtension, Indent, InlineAttachmentExtension, InlineLinkExtension, ListExtension, MentionExtension, TableExtension, TableOfContents, UploadProgressExtension, VerticalAlign, VideoExtension, YoutubeExtension } from "./node";
|
|
18
|
+
import { AlertExtension, AudioExtension, BlockAttachmentExtension, BlockLinkExtension, CodeBlockLowlightExtension, CustomBlockMathExtension, CustomInlineMathExtension, DetailsContentExtension, DetailsExtension, DetailsSummaryExtension, EmojiExtension, FileHandlerExtension, IframeExtension, ImageExtension, Indent, InlineAttachmentExtension, InlineLinkExtension, InlineUploadProgressExtension, ListExtension, MentionExtension, TableExtension, TableOfContents, UploadProgressExtension, VerticalAlign, VideoExtension, YoutubeExtension } from "./node";
|
|
19
19
|
export var getExtensions = function getExtensions(_ref) {
|
|
20
20
|
var limit = _ref.limit,
|
|
21
21
|
exclude = _ref.exclude,
|
|
@@ -105,7 +105,7 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
105
105
|
}), ImageExtension({
|
|
106
106
|
onUpload: onUpload,
|
|
107
107
|
onError: onError
|
|
108
|
-
}), InlineAttachmentExtension({
|
|
108
|
+
}), InlineUploadProgressExtension, InlineAttachmentExtension({
|
|
109
109
|
onUpload: onUpload,
|
|
110
110
|
onError: onError
|
|
111
111
|
}), BlockAttachmentExtension({
|
|
@@ -9,7 +9,7 @@ export var FileHandlerExtension = function FileHandlerExtension(props) {
|
|
|
9
9
|
return FileHandler.configure({
|
|
10
10
|
onDrop: function () {
|
|
11
11
|
var _onDrop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(editor, files, pos) {
|
|
12
|
-
var _loop, i;
|
|
12
|
+
var findNodePosition, _loop, i;
|
|
13
13
|
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
14
14
|
while (1) switch (_context2.prev = _context2.next) {
|
|
15
15
|
case 0:
|
|
@@ -19,122 +19,162 @@ export var FileHandlerExtension = function FileHandlerExtension(props) {
|
|
|
19
19
|
}
|
|
20
20
|
return _context2.abrupt("return");
|
|
21
21
|
case 2:
|
|
22
|
+
findNodePosition = function findNodePosition(typeName, tempId) {
|
|
23
|
+
var targetPos = null;
|
|
24
|
+
editor.state.doc.descendants(function (node, position) {
|
|
25
|
+
if (node.type.name === typeName && node.attrs.tempId === tempId) {
|
|
26
|
+
targetPos = position;
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
});
|
|
31
|
+
return targetPos;
|
|
32
|
+
};
|
|
22
33
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
23
|
-
var file, fileType, tempId, url, dimensions,
|
|
34
|
+
var file, fileType, tempId, insertPosition, isImage, progressNodeType, progressPos, url, chain, dimensions, fallbackChain, _progressPos, _chain;
|
|
24
35
|
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
25
36
|
while (1) switch (_context.prev = _context.next) {
|
|
26
37
|
case 0:
|
|
27
38
|
file = files[i];
|
|
28
39
|
fileType = getFileType(file);
|
|
29
|
-
_context.prev = 2;
|
|
30
40
|
tempId = "upload-".concat(Date.now(), "-").concat(i);
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
insertPosition = pos + i;
|
|
42
|
+
isImage = fileType === 'image';
|
|
43
|
+
progressNodeType = isImage ? 'inlineUploadProgress' : 'uploadProgress';
|
|
44
|
+
_context.prev = 6;
|
|
45
|
+
editor.chain().insertContentAt(insertPosition, {
|
|
46
|
+
type: progressNodeType,
|
|
33
47
|
attrs: {
|
|
34
48
|
fileName: file.name,
|
|
35
49
|
fileType: fileType,
|
|
36
50
|
progress: 0,
|
|
37
51
|
tempId: tempId
|
|
38
52
|
}
|
|
39
|
-
}).run();
|
|
40
|
-
|
|
53
|
+
}).focus().run();
|
|
54
|
+
progressPos = findNodePosition(progressNodeType, tempId);
|
|
55
|
+
_context.next = 11;
|
|
41
56
|
return props.onUpload(file, function (progressEvent) {
|
|
42
|
-
|
|
57
|
+
var progressValue = progressEvent.progress;
|
|
58
|
+
if (isImage) {
|
|
59
|
+
editor.chain().updateInlineUploadProgress(tempId, progressValue).focus().run();
|
|
60
|
+
} else {
|
|
61
|
+
editor.chain().updateUploadProgress(tempId, progressValue).focus().run();
|
|
62
|
+
}
|
|
43
63
|
});
|
|
44
|
-
case
|
|
64
|
+
case 11:
|
|
45
65
|
url = _context.sent;
|
|
46
|
-
|
|
66
|
+
if (isImage) {
|
|
67
|
+
editor.chain().removeInlineUploadProgress(tempId).focus().run();
|
|
68
|
+
} else {
|
|
69
|
+
editor.chain().removeUploadProgress(tempId).focus().run();
|
|
70
|
+
}
|
|
71
|
+
chain = editor.chain().focus();
|
|
72
|
+
if (progressPos !== null) {
|
|
73
|
+
chain.setTextSelection(progressPos);
|
|
74
|
+
}
|
|
47
75
|
_context.t0 = fileType;
|
|
48
|
-
_context.next = _context.t0 === 'image' ?
|
|
76
|
+
_context.next = _context.t0 === 'image' ? 18 : _context.t0 === 'video' ? 32 : 34;
|
|
49
77
|
break;
|
|
50
|
-
case
|
|
51
|
-
_context.prev =
|
|
52
|
-
_context.next =
|
|
78
|
+
case 18:
|
|
79
|
+
_context.prev = 18;
|
|
80
|
+
_context.next = 21;
|
|
53
81
|
return getImageDimensionsFromFile(file);
|
|
54
|
-
case
|
|
82
|
+
case 21:
|
|
55
83
|
dimensions = _context.sent;
|
|
56
|
-
|
|
84
|
+
chain.setImage({
|
|
57
85
|
src: url,
|
|
58
86
|
width: Math.min(dimensions.width, 760) // 使用原始宽度,但不超过760px
|
|
59
|
-
});
|
|
60
|
-
_context.next =
|
|
87
|
+
}).run();
|
|
88
|
+
_context.next = 31;
|
|
61
89
|
break;
|
|
62
|
-
case
|
|
63
|
-
_context.prev =
|
|
64
|
-
_context.t1 = _context["catch"](
|
|
90
|
+
case 25:
|
|
91
|
+
_context.prev = 25;
|
|
92
|
+
_context.t1 = _context["catch"](18);
|
|
65
93
|
console.warn('无法获取图片尺寸,使用默认宽度:', _context.t1);
|
|
66
|
-
editor.
|
|
94
|
+
fallbackChain = editor.chain().focus();
|
|
95
|
+
if (progressPos !== null) {
|
|
96
|
+
fallbackChain.setTextSelection(progressPos);
|
|
97
|
+
}
|
|
98
|
+
fallbackChain.setImage({
|
|
67
99
|
src: url,
|
|
68
100
|
width: 760
|
|
69
|
-
});
|
|
70
|
-
case
|
|
71
|
-
return _context.abrupt("break",
|
|
72
|
-
case
|
|
73
|
-
|
|
101
|
+
}).run();
|
|
102
|
+
case 31:
|
|
103
|
+
return _context.abrupt("break", 36);
|
|
104
|
+
case 32:
|
|
105
|
+
chain.setVideo({
|
|
74
106
|
src: url,
|
|
75
107
|
width: 760,
|
|
76
108
|
controls: true,
|
|
77
109
|
autoplay: false
|
|
78
|
-
});
|
|
79
|
-
return _context.abrupt("break",
|
|
80
|
-
case
|
|
81
|
-
|
|
110
|
+
}).run();
|
|
111
|
+
return _context.abrupt("break", 36);
|
|
112
|
+
case 34:
|
|
113
|
+
chain.setBlockAttachment({
|
|
82
114
|
url: url,
|
|
83
115
|
title: file.name,
|
|
84
116
|
size: formatFileSize(file.size)
|
|
85
|
-
});
|
|
86
|
-
return _context.abrupt("break",
|
|
87
|
-
case
|
|
88
|
-
_context.next =
|
|
117
|
+
}).run();
|
|
118
|
+
return _context.abrupt("break", 36);
|
|
119
|
+
case 36:
|
|
120
|
+
_context.next = 54;
|
|
89
121
|
break;
|
|
90
|
-
case
|
|
91
|
-
_context.prev =
|
|
92
|
-
_context.t2 = _context["catch"](
|
|
122
|
+
case 38:
|
|
123
|
+
_context.prev = 38;
|
|
124
|
+
_context.t2 = _context["catch"](6);
|
|
93
125
|
console.error('文件上传失败:', _context.t2);
|
|
94
|
-
|
|
95
|
-
|
|
126
|
+
if (isImage) {
|
|
127
|
+
editor.chain().removeInlineUploadProgress(tempId).focus().run();
|
|
128
|
+
} else {
|
|
129
|
+
editor.chain().removeUploadProgress(tempId).focus().run();
|
|
130
|
+
}
|
|
131
|
+
_progressPos = findNodePosition(progressNodeType, tempId);
|
|
132
|
+
_chain = editor.chain().focus();
|
|
133
|
+
if (_progressPos !== null) {
|
|
134
|
+
_chain.setTextSelection(_progressPos);
|
|
135
|
+
}
|
|
96
136
|
_context.t3 = fileType;
|
|
97
|
-
_context.next = _context.t3 === 'image' ?
|
|
137
|
+
_context.next = _context.t3 === 'image' ? 48 : _context.t3 === 'video' ? 50 : 52;
|
|
98
138
|
break;
|
|
99
|
-
case
|
|
100
|
-
|
|
139
|
+
case 48:
|
|
140
|
+
_chain.setImage({
|
|
101
141
|
src: '',
|
|
102
142
|
width: 760
|
|
103
|
-
});
|
|
104
|
-
return _context.abrupt("break",
|
|
105
|
-
case
|
|
106
|
-
|
|
143
|
+
}).run();
|
|
144
|
+
return _context.abrupt("break", 54);
|
|
145
|
+
case 50:
|
|
146
|
+
_chain.setVideo({
|
|
107
147
|
src: '',
|
|
108
148
|
width: 760,
|
|
109
149
|
controls: true,
|
|
110
150
|
autoplay: false
|
|
111
|
-
});
|
|
112
|
-
return _context.abrupt("break",
|
|
113
|
-
case
|
|
114
|
-
|
|
151
|
+
}).run();
|
|
152
|
+
return _context.abrupt("break", 54);
|
|
153
|
+
case 52:
|
|
154
|
+
_chain.setBlockAttachment({
|
|
115
155
|
url: 'error',
|
|
116
156
|
title: "\u4E0A\u4F20\u5931\u8D25: ".concat(file.name),
|
|
117
157
|
size: formatFileSize(file.size)
|
|
118
|
-
});
|
|
119
|
-
return _context.abrupt("break",
|
|
120
|
-
case
|
|
158
|
+
}).run();
|
|
159
|
+
return _context.abrupt("break", 54);
|
|
160
|
+
case 54:
|
|
121
161
|
case "end":
|
|
122
162
|
return _context.stop();
|
|
123
163
|
}
|
|
124
|
-
}, _loop, null, [[
|
|
164
|
+
}, _loop, null, [[6, 38], [18, 25]]);
|
|
125
165
|
});
|
|
126
166
|
i = 0;
|
|
127
|
-
case
|
|
167
|
+
case 5:
|
|
128
168
|
if (!(i < files.length)) {
|
|
129
|
-
_context2.next =
|
|
169
|
+
_context2.next = 10;
|
|
130
170
|
break;
|
|
131
171
|
}
|
|
132
|
-
return _context2.delegateYield(_loop(), "t0",
|
|
133
|
-
case
|
|
172
|
+
return _context2.delegateYield(_loop(), "t0", 7);
|
|
173
|
+
case 7:
|
|
134
174
|
i++;
|
|
135
|
-
_context2.next =
|
|
175
|
+
_context2.next = 5;
|
|
136
176
|
break;
|
|
137
|
-
case
|
|
177
|
+
case 10:
|
|
138
178
|
case "end":
|
|
139
179
|
return _context2.stop();
|
|
140
180
|
}
|
|
@@ -144,151 +184,142 @@ export var FileHandlerExtension = function FileHandlerExtension(props) {
|
|
|
144
184
|
return _onDrop.apply(this, arguments);
|
|
145
185
|
}
|
|
146
186
|
return onDrop;
|
|
147
|
-
}(),
|
|
148
|
-
onPaste: function () {
|
|
149
|
-
var _onPaste = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(editor, files, pasteContent) {
|
|
150
|
-
var from, _loop2, i;
|
|
151
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context4) {
|
|
152
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
153
|
-
case 0:
|
|
154
|
-
if (!(!props.onUpload || files.length === 0 || !!pasteContent)) {
|
|
155
|
-
_context4.next = 2;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
return _context4.abrupt("return", false);
|
|
159
|
-
case 2:
|
|
160
|
-
from = editor.state.selection.from;
|
|
161
|
-
if (!(files.length > 0)) {
|
|
162
|
-
_context4.next = 11;
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
166
|
-
var file, fileType, tempId, url, dimensions, _tempId2;
|
|
167
|
-
return _regeneratorRuntime().wrap(function _loop2$(_context3) {
|
|
168
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
169
|
-
case 0:
|
|
170
|
-
file = files[i];
|
|
171
|
-
fileType = getFileType(file);
|
|
172
|
-
_context3.prev = 2;
|
|
173
|
-
tempId = "upload-".concat(Date.now(), "-").concat(i);
|
|
174
|
-
editor.chain().focus().insertContentAt(from + i, {
|
|
175
|
-
type: 'uploadProgress',
|
|
176
|
-
attrs: {
|
|
177
|
-
fileName: file.name,
|
|
178
|
-
fileType: fileType,
|
|
179
|
-
progress: 0,
|
|
180
|
-
tempId: tempId
|
|
181
|
-
}
|
|
182
|
-
}).run();
|
|
183
|
-
_context3.next = 7;
|
|
184
|
-
return props.onUpload(file, function (progressEvent) {
|
|
185
|
-
editor.commands.updateUploadProgress(tempId, progressEvent.progress);
|
|
186
|
-
});
|
|
187
|
-
case 7:
|
|
188
|
-
url = _context3.sent;
|
|
189
|
-
editor.commands.removeUploadProgress(tempId);
|
|
190
|
-
_context3.t0 = fileType;
|
|
191
|
-
_context3.next = _context3.t0 === 'image' ? 12 : _context3.t0 === 'video' ? 24 : 26;
|
|
192
|
-
break;
|
|
193
|
-
case 12:
|
|
194
|
-
_context3.prev = 12;
|
|
195
|
-
_context3.next = 15;
|
|
196
|
-
return getImageDimensionsFromFile(file);
|
|
197
|
-
case 15:
|
|
198
|
-
dimensions = _context3.sent;
|
|
199
|
-
editor.commands.setImage({
|
|
200
|
-
src: url,
|
|
201
|
-
width: Math.min(dimensions.width, 760) // 使用原始宽度,但不超过760px
|
|
202
|
-
});
|
|
203
|
-
_context3.next = 23;
|
|
204
|
-
break;
|
|
205
|
-
case 19:
|
|
206
|
-
_context3.prev = 19;
|
|
207
|
-
_context3.t1 = _context3["catch"](12);
|
|
208
|
-
console.warn('无法获取图片尺寸,使用默认宽度:', _context3.t1);
|
|
209
|
-
editor.commands.setImage({
|
|
210
|
-
src: url,
|
|
211
|
-
width: 760
|
|
212
|
-
});
|
|
213
|
-
case 23:
|
|
214
|
-
return _context3.abrupt("break", 28);
|
|
215
|
-
case 24:
|
|
216
|
-
editor.commands.setVideo({
|
|
217
|
-
src: url,
|
|
218
|
-
width: 760,
|
|
219
|
-
controls: true,
|
|
220
|
-
autoplay: false
|
|
221
|
-
});
|
|
222
|
-
return _context3.abrupt("break", 28);
|
|
223
|
-
case 26:
|
|
224
|
-
editor.commands.setInlineAttachment({
|
|
225
|
-
url: url,
|
|
226
|
-
title: file.name,
|
|
227
|
-
size: formatFileSize(file.size)
|
|
228
|
-
});
|
|
229
|
-
return _context3.abrupt("break", 28);
|
|
230
|
-
case 28:
|
|
231
|
-
_context3.next = 44;
|
|
232
|
-
break;
|
|
233
|
-
case 30:
|
|
234
|
-
_context3.prev = 30;
|
|
235
|
-
_context3.t2 = _context3["catch"](2);
|
|
236
|
-
console.error('文件上传失败:', _context3.t2);
|
|
237
|
-
_tempId2 = "upload-".concat(Date.now(), "-").concat(i);
|
|
238
|
-
editor.commands.removeUploadProgress(_tempId2);
|
|
239
|
-
_context3.t3 = fileType;
|
|
240
|
-
_context3.next = _context3.t3 === 'image' ? 38 : _context3.t3 === 'video' ? 40 : 42;
|
|
241
|
-
break;
|
|
242
|
-
case 38:
|
|
243
|
-
editor.commands.setImage({
|
|
244
|
-
src: '',
|
|
245
|
-
width: 760
|
|
246
|
-
});
|
|
247
|
-
return _context3.abrupt("break", 44);
|
|
248
|
-
case 40:
|
|
249
|
-
editor.commands.setVideo({
|
|
250
|
-
src: '',
|
|
251
|
-
width: 760,
|
|
252
|
-
controls: true,
|
|
253
|
-
autoplay: false
|
|
254
|
-
});
|
|
255
|
-
return _context3.abrupt("break", 44);
|
|
256
|
-
case 42:
|
|
257
|
-
editor.commands.setInlineAttachment({
|
|
258
|
-
url: 'error',
|
|
259
|
-
title: "\u4E0A\u4F20\u5931\u8D25: ".concat(file.name),
|
|
260
|
-
size: formatFileSize(file.size)
|
|
261
|
-
});
|
|
262
|
-
return _context3.abrupt("break", 44);
|
|
263
|
-
case 44:
|
|
264
|
-
case "end":
|
|
265
|
-
return _context3.stop();
|
|
266
|
-
}
|
|
267
|
-
}, _loop2, null, [[2, 30], [12, 19]]);
|
|
268
|
-
});
|
|
269
|
-
i = 0;
|
|
270
|
-
case 6:
|
|
271
|
-
if (!(i < files.length)) {
|
|
272
|
-
_context4.next = 11;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
return _context4.delegateYield(_loop2(), "t0", 8);
|
|
276
|
-
case 8:
|
|
277
|
-
i++;
|
|
278
|
-
_context4.next = 6;
|
|
279
|
-
break;
|
|
280
|
-
case 11:
|
|
281
|
-
return _context4.abrupt("return", true);
|
|
282
|
-
case 12:
|
|
283
|
-
case "end":
|
|
284
|
-
return _context4.stop();
|
|
285
|
-
}
|
|
286
|
-
}, _callee2);
|
|
287
|
-
}));
|
|
288
|
-
function onPaste(_x4, _x5, _x6) {
|
|
289
|
-
return _onPaste.apply(this, arguments);
|
|
290
|
-
}
|
|
291
|
-
return onPaste;
|
|
292
187
|
}()
|
|
188
|
+
// onPaste: async (editor, files, pasteContent) => {
|
|
189
|
+
// if (!props.onUpload || files.length === 0 || !!pasteContent) return false;
|
|
190
|
+
// const { from } = editor.state.selection;
|
|
191
|
+
// if (files.length > 0) {
|
|
192
|
+
// const findNodePosition = (typeName: string, tempId: string) => {
|
|
193
|
+
// let targetPos: number | null = null;
|
|
194
|
+
// editor.state.doc.descendants((node, position) => {
|
|
195
|
+
// if (node.type.name === typeName && node.attrs.tempId === tempId) {
|
|
196
|
+
// targetPos = position;
|
|
197
|
+
// return false;
|
|
198
|
+
// }
|
|
199
|
+
// return undefined;
|
|
200
|
+
// });
|
|
201
|
+
// return targetPos;
|
|
202
|
+
// };
|
|
203
|
+
// for (let i = 0; i < files.length; i++) {
|
|
204
|
+
// const file = files[i];
|
|
205
|
+
// const fileType = getFileType(file);
|
|
206
|
+
// const tempId = `upload-${Date.now()}-${i}`;
|
|
207
|
+
// const insertPosition = from + i;
|
|
208
|
+
// const isImage = fileType === 'image';
|
|
209
|
+
// const progressNodeType = isImage ? 'inlineUploadProgress' : 'uploadProgress';
|
|
210
|
+
// try {
|
|
211
|
+
// editor.chain().insertContentAt(insertPosition, {
|
|
212
|
+
// type: progressNodeType,
|
|
213
|
+
// attrs: {
|
|
214
|
+
// fileName: file.name,
|
|
215
|
+
// fileType,
|
|
216
|
+
// progress: 0,
|
|
217
|
+
// tempId,
|
|
218
|
+
// },
|
|
219
|
+
// }).focus().run();
|
|
220
|
+
|
|
221
|
+
// const progressPos = findNodePosition(progressNodeType, tempId);
|
|
222
|
+
|
|
223
|
+
// const url = await props.onUpload(file, (progressEvent) => {
|
|
224
|
+
// const progressValue = progressEvent.progress;
|
|
225
|
+
// if (isImage) {
|
|
226
|
+
// editor.chain().updateInlineUploadProgress(tempId, progressValue).focus().run();
|
|
227
|
+
// } else {
|
|
228
|
+
// editor.chain().updateUploadProgress(tempId, progressValue).focus().run();
|
|
229
|
+
// }
|
|
230
|
+
// });
|
|
231
|
+
|
|
232
|
+
// if (isImage) {
|
|
233
|
+
// editor.chain().removeInlineUploadProgress(tempId).focus().run();
|
|
234
|
+
// } else {
|
|
235
|
+
// editor.chain().removeUploadProgress(tempId).focus().run();
|
|
236
|
+
// }
|
|
237
|
+
|
|
238
|
+
// const chain = editor.chain().focus();
|
|
239
|
+
// if (progressPos !== null) {
|
|
240
|
+
// chain.setTextSelection(progressPos);
|
|
241
|
+
// }
|
|
242
|
+
|
|
243
|
+
// switch (fileType) {
|
|
244
|
+
// case 'image':
|
|
245
|
+
// try {
|
|
246
|
+
// const dimensions = await getImageDimensionsFromFile(file);
|
|
247
|
+
// chain.setImage({
|
|
248
|
+
// src: url,
|
|
249
|
+
// width: Math.min(dimensions.width, 760) // 使用原始宽度,但不超过760px
|
|
250
|
+
// }).run();
|
|
251
|
+
// } catch (error) {
|
|
252
|
+
// console.warn('无法获取图片尺寸,使用默认宽度:', error);
|
|
253
|
+
// const fallbackChain = editor.chain().focus();
|
|
254
|
+
// if (progressPos !== null) {
|
|
255
|
+
// fallbackChain.setTextSelection(progressPos);
|
|
256
|
+
// }
|
|
257
|
+
// fallbackChain.setImage({
|
|
258
|
+
// src: url,
|
|
259
|
+
// width: 760
|
|
260
|
+
// }).run();
|
|
261
|
+
// }
|
|
262
|
+
// break;
|
|
263
|
+
// case 'video':
|
|
264
|
+
// chain.setVideo({
|
|
265
|
+
// src: url,
|
|
266
|
+
// width: 760,
|
|
267
|
+
// controls: true,
|
|
268
|
+
// autoplay: false
|
|
269
|
+
// }).run();
|
|
270
|
+
// break;
|
|
271
|
+
// default:
|
|
272
|
+
// chain.setBlockAttachment({
|
|
273
|
+
// url: url,
|
|
274
|
+
// title: file.name,
|
|
275
|
+
// size: formatFileSize(file.size)
|
|
276
|
+
// }).run();
|
|
277
|
+
// break;
|
|
278
|
+
// }
|
|
279
|
+
// } catch (error) {
|
|
280
|
+
// console.error('文件上传失败:', error);
|
|
281
|
+
// const tempId = `upload-${Date.now()}-${i}`;
|
|
282
|
+
// const isImage = fileType === 'image';
|
|
283
|
+
// const progressNodeType = isImage ? 'inlineUploadProgress' : 'uploadProgress';
|
|
284
|
+
// const progressPos = findNodePosition(progressNodeType, tempId);
|
|
285
|
+
|
|
286
|
+
// if (isImage) {
|
|
287
|
+
// editor.chain().removeInlineUploadProgress(tempId).focus().run();
|
|
288
|
+
// } else {
|
|
289
|
+
// editor.chain().removeUploadProgress(tempId).focus().run();
|
|
290
|
+
// }
|
|
291
|
+
|
|
292
|
+
// const chain = editor.chain().focus();
|
|
293
|
+
// if (progressPos !== null) {
|
|
294
|
+
// chain.setTextSelection(progressPos);
|
|
295
|
+
// }
|
|
296
|
+
// switch (fileType) {
|
|
297
|
+
// case 'image':
|
|
298
|
+
// chain.setImage({
|
|
299
|
+
// src: '',
|
|
300
|
+
// width: 760
|
|
301
|
+
// }).run();
|
|
302
|
+
// break;
|
|
303
|
+
// case 'video':
|
|
304
|
+
// chain.setVideo({
|
|
305
|
+
// src: '',
|
|
306
|
+
// width: 760,
|
|
307
|
+
// controls: true,
|
|
308
|
+
// autoplay: false
|
|
309
|
+
// }).run();
|
|
310
|
+
// break;
|
|
311
|
+
// default:
|
|
312
|
+
// chain.setBlockAttachment({
|
|
313
|
+
// url: 'error',
|
|
314
|
+
// title: `上传失败: ${file.name}`,
|
|
315
|
+
// size: formatFileSize(file.size)
|
|
316
|
+
// }).run();
|
|
317
|
+
// break;
|
|
318
|
+
// }
|
|
319
|
+
// }
|
|
320
|
+
// }
|
|
321
|
+
// }
|
|
322
|
+
// return true;
|
|
323
|
+
// },
|
|
293
324
|
});
|
|
294
325
|
};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
2
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
9
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
import { getFileType } from "../../util";
|
|
7
11
|
import Image from "@tiptap/extension-image";
|
|
12
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
8
13
|
import { ReactNodeViewRenderer } from "@tiptap/react";
|
|
9
|
-
import ImageViewWrapper from "../component/Image";
|
|
14
|
+
import ImageViewWrapper, { getImageDimensionsFromFile } from "../component/Image";
|
|
10
15
|
var customImage = function customImage(props) {
|
|
11
16
|
return Image.extend({
|
|
12
17
|
addKeyboardShortcuts: function addKeyboardShortcuts() {
|
|
@@ -27,6 +32,144 @@ var customImage = function customImage(props) {
|
|
|
27
32
|
onError: props.onError
|
|
28
33
|
}));
|
|
29
34
|
});
|
|
35
|
+
},
|
|
36
|
+
addProseMirrorPlugins: function addProseMirrorPlugins() {
|
|
37
|
+
var _this2 = this;
|
|
38
|
+
return [new Plugin({
|
|
39
|
+
key: new PluginKey('imagePasteHandler'),
|
|
40
|
+
props: {
|
|
41
|
+
handlePaste: function handlePaste(view, event) {
|
|
42
|
+
var _event$clipboardData;
|
|
43
|
+
if (!props.onUpload) return false;
|
|
44
|
+
var items = Array.from(((_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.items) || []);
|
|
45
|
+
var imageFiles = items.map(function (item) {
|
|
46
|
+
return item.getAsFile();
|
|
47
|
+
}).filter(function (file) {
|
|
48
|
+
return file !== null && getFileType(file) === 'image';
|
|
49
|
+
});
|
|
50
|
+
if (imageFiles.length === 0) return false;
|
|
51
|
+
var from = view.state.selection.from;
|
|
52
|
+
var editor = _this2.editor;
|
|
53
|
+
var findNodePosition = function findNodePosition(typeName, tempId) {
|
|
54
|
+
var targetPos = null;
|
|
55
|
+
editor.state.doc.descendants(function (node, position) {
|
|
56
|
+
if (node.type.name === typeName && node.attrs.tempId === tempId) {
|
|
57
|
+
targetPos = position;
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
});
|
|
62
|
+
return targetPos;
|
|
63
|
+
};
|
|
64
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
65
|
+
var _loop, i;
|
|
66
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
67
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
if (props.onUpload) {
|
|
70
|
+
_context2.next = 2;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
return _context2.abrupt("return");
|
|
74
|
+
case 2:
|
|
75
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
76
|
+
var file, tempId, insertPosition, progressPos, url, chain, dimensions, fallbackChain, _progressPos, _chain;
|
|
77
|
+
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
78
|
+
while (1) switch (_context.prev = _context.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
file = imageFiles[i];
|
|
81
|
+
tempId = "upload-".concat(Date.now(), "-").concat(i);
|
|
82
|
+
insertPosition = from + i;
|
|
83
|
+
_context.prev = 3;
|
|
84
|
+
editor.chain().insertContentAt(insertPosition, {
|
|
85
|
+
type: 'inlineUploadProgress',
|
|
86
|
+
attrs: {
|
|
87
|
+
fileName: file.name,
|
|
88
|
+
fileType: 'image',
|
|
89
|
+
progress: 0,
|
|
90
|
+
tempId: tempId
|
|
91
|
+
}
|
|
92
|
+
}).focus().run();
|
|
93
|
+
progressPos = findNodePosition('inlineUploadProgress', tempId);
|
|
94
|
+
_context.next = 8;
|
|
95
|
+
return props.onUpload(file, function (progressEvent) {
|
|
96
|
+
var progressValue = progressEvent.progress;
|
|
97
|
+
editor.chain().updateInlineUploadProgress(tempId, progressValue).focus().run();
|
|
98
|
+
});
|
|
99
|
+
case 8:
|
|
100
|
+
url = _context.sent;
|
|
101
|
+
editor.chain().removeInlineUploadProgress(tempId).focus().run();
|
|
102
|
+
chain = editor.chain().focus();
|
|
103
|
+
if (progressPos !== null) {
|
|
104
|
+
chain.setTextSelection(progressPos);
|
|
105
|
+
}
|
|
106
|
+
_context.prev = 12;
|
|
107
|
+
_context.next = 15;
|
|
108
|
+
return getImageDimensionsFromFile(file);
|
|
109
|
+
case 15:
|
|
110
|
+
dimensions = _context.sent;
|
|
111
|
+
chain.setImage({
|
|
112
|
+
src: url,
|
|
113
|
+
width: Math.min(dimensions.width, 760) // 使用原始宽度,但不超过760px
|
|
114
|
+
}).run();
|
|
115
|
+
_context.next = 25;
|
|
116
|
+
break;
|
|
117
|
+
case 19:
|
|
118
|
+
_context.prev = 19;
|
|
119
|
+
_context.t0 = _context["catch"](12);
|
|
120
|
+
console.warn('无法获取图片尺寸,使用默认宽度:', _context.t0);
|
|
121
|
+
fallbackChain = editor.chain().focus();
|
|
122
|
+
if (progressPos !== null) {
|
|
123
|
+
fallbackChain.setTextSelection(progressPos);
|
|
124
|
+
}
|
|
125
|
+
fallbackChain.setImage({
|
|
126
|
+
src: url,
|
|
127
|
+
width: 760
|
|
128
|
+
}).run();
|
|
129
|
+
case 25:
|
|
130
|
+
_context.next = 35;
|
|
131
|
+
break;
|
|
132
|
+
case 27:
|
|
133
|
+
_context.prev = 27;
|
|
134
|
+
_context.t1 = _context["catch"](3);
|
|
135
|
+
console.error('图片上传失败:', _context.t1);
|
|
136
|
+
editor.chain().removeInlineUploadProgress(tempId).focus().run();
|
|
137
|
+
_progressPos = findNodePosition('inlineUploadProgress', tempId);
|
|
138
|
+
_chain = editor.chain().focus();
|
|
139
|
+
if (_progressPos !== null) {
|
|
140
|
+
_chain.setTextSelection(_progressPos);
|
|
141
|
+
}
|
|
142
|
+
_chain.setImage({
|
|
143
|
+
src: '',
|
|
144
|
+
width: 760
|
|
145
|
+
}).run();
|
|
146
|
+
case 35:
|
|
147
|
+
case "end":
|
|
148
|
+
return _context.stop();
|
|
149
|
+
}
|
|
150
|
+
}, _loop, null, [[3, 27], [12, 19]]);
|
|
151
|
+
});
|
|
152
|
+
i = 0;
|
|
153
|
+
case 4:
|
|
154
|
+
if (!(i < imageFiles.length)) {
|
|
155
|
+
_context2.next = 9;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
return _context2.delegateYield(_loop(), "t0", 6);
|
|
159
|
+
case 6:
|
|
160
|
+
i++;
|
|
161
|
+
_context2.next = 4;
|
|
162
|
+
break;
|
|
163
|
+
case 9:
|
|
164
|
+
case "end":
|
|
165
|
+
return _context2.stop();
|
|
166
|
+
}
|
|
167
|
+
}, _callee);
|
|
168
|
+
}))();
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
})];
|
|
30
173
|
}
|
|
31
174
|
});
|
|
32
175
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
import { InlineUploadProgressAttributes } from '../component/UploadProgress/Inline';
|
|
3
|
+
declare module '@tiptap/core' {
|
|
4
|
+
interface Commands<ReturnType> {
|
|
5
|
+
inlineUploadProgress: {
|
|
6
|
+
setInlineUploadProgress: (options: InlineUploadProgressAttributes) => ReturnType;
|
|
7
|
+
updateInlineUploadProgress: (tempId: string, progress: number) => ReturnType;
|
|
8
|
+
removeInlineUploadProgress: (tempId: string) => ReturnType;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare const InlineUploadProgressExtension: Node<any, any>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { mergeAttributes, Node } from '@tiptap/core';
|
|
8
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
9
|
+
import InlineUploadProgressView from "../component/UploadProgress/Inline";
|
|
10
|
+
export var InlineUploadProgressExtension = Node.create({
|
|
11
|
+
name: 'inlineUploadProgress',
|
|
12
|
+
group: 'inline',
|
|
13
|
+
inline: true,
|
|
14
|
+
atom: true,
|
|
15
|
+
draggable: false,
|
|
16
|
+
selectable: false,
|
|
17
|
+
addAttributes: function addAttributes() {
|
|
18
|
+
return {
|
|
19
|
+
fileName: {
|
|
20
|
+
default: '',
|
|
21
|
+
parseHTML: function parseHTML(element) {
|
|
22
|
+
return element.getAttribute('data-file-name');
|
|
23
|
+
},
|
|
24
|
+
renderHTML: function renderHTML(attributes) {
|
|
25
|
+
if (!attributes.fileName) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
'data-file-name': attributes.fileName
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
fileType: {
|
|
34
|
+
default: 'image',
|
|
35
|
+
parseHTML: function parseHTML(element) {
|
|
36
|
+
return element.getAttribute('data-file-type');
|
|
37
|
+
},
|
|
38
|
+
renderHTML: function renderHTML(attributes) {
|
|
39
|
+
if (!attributes.fileType) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
'data-file-type': attributes.fileType
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
progress: {
|
|
48
|
+
default: 0,
|
|
49
|
+
parseHTML: function parseHTML(element) {
|
|
50
|
+
return parseFloat(element.getAttribute('data-progress') || '0');
|
|
51
|
+
},
|
|
52
|
+
renderHTML: function renderHTML(attributes) {
|
|
53
|
+
return {
|
|
54
|
+
'data-progress': attributes.progress
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
tempId: {
|
|
59
|
+
default: '',
|
|
60
|
+
parseHTML: function parseHTML(element) {
|
|
61
|
+
return element.getAttribute('data-temp-id');
|
|
62
|
+
},
|
|
63
|
+
renderHTML: function renderHTML(attributes) {
|
|
64
|
+
if (!attributes.tempId) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
'data-temp-id': attributes.tempId
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
parseHTML: function parseHTML() {
|
|
75
|
+
return [{
|
|
76
|
+
tag: 'span[data-type="inline-upload-progress"]'
|
|
77
|
+
}];
|
|
78
|
+
},
|
|
79
|
+
renderHTML: function renderHTML(_ref) {
|
|
80
|
+
var HTMLAttributes = _ref.HTMLAttributes;
|
|
81
|
+
return ['span', mergeAttributes({
|
|
82
|
+
'data-type': 'inline-upload-progress'
|
|
83
|
+
}, HTMLAttributes)];
|
|
84
|
+
},
|
|
85
|
+
addCommands: function addCommands() {
|
|
86
|
+
var _this = this;
|
|
87
|
+
return {
|
|
88
|
+
setInlineUploadProgress: function setInlineUploadProgress(options) {
|
|
89
|
+
return function (_ref2) {
|
|
90
|
+
var commands = _ref2.commands;
|
|
91
|
+
return commands.insertContent({
|
|
92
|
+
type: _this.name,
|
|
93
|
+
attrs: options
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
updateInlineUploadProgress: function updateInlineUploadProgress(tempId, progress) {
|
|
98
|
+
return function (_ref3) {
|
|
99
|
+
var tr = _ref3.tr,
|
|
100
|
+
state = _ref3.state;
|
|
101
|
+
var doc = state.doc;
|
|
102
|
+
var updated = false;
|
|
103
|
+
doc.descendants(function (node, pos) {
|
|
104
|
+
if (node.type.name === _this.name && node.attrs.tempId === tempId) {
|
|
105
|
+
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
106
|
+
progress: progress
|
|
107
|
+
}));
|
|
108
|
+
updated = true;
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return updated;
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
removeInlineUploadProgress: function removeInlineUploadProgress(tempId) {
|
|
116
|
+
return function (_ref4) {
|
|
117
|
+
var tr = _ref4.tr,
|
|
118
|
+
state = _ref4.state;
|
|
119
|
+
var doc = state.doc;
|
|
120
|
+
var removed = false;
|
|
121
|
+
doc.descendants(function (node, pos) {
|
|
122
|
+
if (node.type.name === _this.name && node.attrs.tempId === tempId) {
|
|
123
|
+
tr.delete(pos, pos + node.nodeSize);
|
|
124
|
+
removed = true;
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return removed;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
addNodeView: function addNodeView() {
|
|
134
|
+
return ReactNodeViewRenderer(InlineUploadProgressView);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/react';
|
|
2
|
-
export declare const getFileType: (file: File) => 'image' | 'video' | 'other';
|
|
2
|
+
export declare const getFileType: (file: File) => 'image' | 'video' | 'audio' | 'other';
|
|
3
3
|
export declare const formatFileSize: (bytes: number) => string;
|
|
4
4
|
export declare const getFileIcon: (fileName: string) => string;
|
|
5
5
|
export declare const insertImageContent: (editor: Editor, url: string, pos: number) => void;
|
package/dist/util/fileHandler.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctzhian/tiptap",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.20",
|
|
4
4
|
"description": "基于 Tiptap 二次开发的编辑器组件",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -81,36 +81,36 @@
|
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@floating-ui/dom": "^1.7.2",
|
|
84
|
-
"@tiptap/core": "^3.5
|
|
85
|
-
"@tiptap/extension-bubble-menu": "^3.5
|
|
86
|
-
"@tiptap/extension-code": "^3.5
|
|
87
|
-
"@tiptap/extension-code-block-lowlight": "^3.5
|
|
88
|
-
"@tiptap/extension-details": "^3.5
|
|
89
|
-
"@tiptap/extension-drag-handle-react": "^3.5
|
|
90
|
-
"@tiptap/extension-emoji": "^3.5
|
|
91
|
-
"@tiptap/extension-file-handler": "^3.5
|
|
92
|
-
"@tiptap/extension-highlight": "^3.5
|
|
93
|
-
"@tiptap/extension-image": "^3.5
|
|
94
|
-
"@tiptap/extension-invisible-characters": "^3.5
|
|
95
|
-
"@tiptap/extension-link": "^3.5
|
|
96
|
-
"@tiptap/extension-list": "^3.5
|
|
97
|
-
"@tiptap/extension-mathematics": "^3.5
|
|
98
|
-
"@tiptap/extension-mention": "^3.5
|
|
99
|
-
"@tiptap/extension-subscript": "^3.5
|
|
100
|
-
"@tiptap/extension-superscript": "^3.5
|
|
101
|
-
"@tiptap/extension-table": "^3.5
|
|
102
|
-
"@tiptap/extension-table-of-contents": "^3.5
|
|
103
|
-
"@tiptap/extension-text-align": "^3.5
|
|
104
|
-
"@tiptap/extension-text-style": "^3.5
|
|
105
|
-
"@tiptap/extension-unique-id": "^3.5
|
|
106
|
-
"@tiptap/extension-youtube": "^3.5
|
|
107
|
-
"@tiptap/extensions": "^3.5
|
|
108
|
-
"@tiptap/html": "^3.5
|
|
109
|
-
"@tiptap/pm": "^3.5
|
|
110
|
-
"@tiptap/react": "^3.5
|
|
111
|
-
"@tiptap/starter-kit": "^3.5
|
|
112
|
-
"@tiptap/static-renderer": "^3.5
|
|
113
|
-
"@tiptap/suggestion": "^3.5
|
|
84
|
+
"@tiptap/core": "^3.6.5",
|
|
85
|
+
"@tiptap/extension-bubble-menu": "^3.6.5",
|
|
86
|
+
"@tiptap/extension-code": "^3.6.5",
|
|
87
|
+
"@tiptap/extension-code-block-lowlight": "^3.6.5",
|
|
88
|
+
"@tiptap/extension-details": "^3.6.5",
|
|
89
|
+
"@tiptap/extension-drag-handle-react": "^3.6.5",
|
|
90
|
+
"@tiptap/extension-emoji": "^3.6.5",
|
|
91
|
+
"@tiptap/extension-file-handler": "^3.6.5",
|
|
92
|
+
"@tiptap/extension-highlight": "^3.6.5",
|
|
93
|
+
"@tiptap/extension-image": "^3.6.5",
|
|
94
|
+
"@tiptap/extension-invisible-characters": "^3.6.5",
|
|
95
|
+
"@tiptap/extension-link": "^3.6.5",
|
|
96
|
+
"@tiptap/extension-list": "^3.6.5",
|
|
97
|
+
"@tiptap/extension-mathematics": "^3.6.5",
|
|
98
|
+
"@tiptap/extension-mention": "^3.6.5",
|
|
99
|
+
"@tiptap/extension-subscript": "^3.6.5",
|
|
100
|
+
"@tiptap/extension-superscript": "^3.6.5",
|
|
101
|
+
"@tiptap/extension-table": "^3.6.5",
|
|
102
|
+
"@tiptap/extension-table-of-contents": "^3.6.5",
|
|
103
|
+
"@tiptap/extension-text-align": "^3.6.5",
|
|
104
|
+
"@tiptap/extension-text-style": "^3.6.5",
|
|
105
|
+
"@tiptap/extension-unique-id": "^3.6.5",
|
|
106
|
+
"@tiptap/extension-youtube": "^3.6.5",
|
|
107
|
+
"@tiptap/extensions": "^3.6.5",
|
|
108
|
+
"@tiptap/html": "^3.6.5",
|
|
109
|
+
"@tiptap/pm": "^3.6.5",
|
|
110
|
+
"@tiptap/react": "^3.6.5",
|
|
111
|
+
"@tiptap/starter-kit": "^3.6.5",
|
|
112
|
+
"@tiptap/static-renderer": "^3.6.5",
|
|
113
|
+
"@tiptap/suggestion": "^3.6.5",
|
|
114
114
|
"diff-match-patch": "^1.0.5",
|
|
115
115
|
"highlight.js": "^11.11.1",
|
|
116
116
|
"jszip": "^3.10.1",
|