@ctzhian/tiptap 1.11.4 → 1.12.1
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 +17 -22
- package/dist/EditorMarkdown/index.js +1 -1
- package/dist/asset/css/index.css +19 -8
- package/dist/component/ActionDropdown/index.d.ts +25 -0
- package/dist/component/ActionDropdown/index.js +147 -0
- package/dist/component/CustomDragHandle/index.js +2 -2
- package/dist/component/FloatingPopover/index.d.ts +2 -0
- package/dist/component/FloatingPopover/index.js +7 -1
- package/dist/component/HoverPopover/index.d.ts +29 -0
- package/dist/component/HoverPopover/index.js +143 -0
- package/dist/component/Icons/chrome-icon.d.ts +6 -0
- package/dist/component/Icons/chrome-icon.js +31 -0
- package/dist/component/Icons/edit-line-icon.d.ts +6 -0
- package/dist/component/Icons/edit-line-icon.js +13 -0
- package/dist/component/Icons/file-icon.d.ts +6 -0
- package/dist/component/Icons/file-icon.js +20 -0
- package/dist/component/Icons/index.d.ts +3 -0
- package/dist/component/Icons/index.js +3 -0
- package/dist/component/index.d.ts +2 -0
- package/dist/component/index.js +2 -0
- package/dist/extension/component/Alert/index.js +73 -85
- package/dist/extension/component/Attachment/AttachmentContent.d.ts +14 -0
- package/dist/extension/component/Attachment/AttachmentContent.js +142 -0
- package/dist/extension/component/Attachment/index.js +144 -201
- package/dist/extension/component/CodeBlock/Readonly.js +42 -35
- package/dist/extension/component/CodeBlock/index.js +137 -90
- package/dist/extension/component/Image/Insert.js +41 -26
- package/dist/extension/component/Image/Readonly.js +13 -6
- package/dist/extension/component/Image/index.d.ts +1 -0
- package/dist/extension/component/Image/index.js +234 -92
- package/dist/extension/component/Link/Insert.js +1 -1
- package/dist/extension/component/Link/LinkContent.d.ts +13 -0
- package/dist/extension/component/Link/LinkContent.js +169 -0
- package/dist/extension/component/Link/index.js +182 -264
- package/dist/extension/component/MentionList/index.js +1 -1
- package/dist/extension/index.js +1 -1
- package/dist/index.css +65 -63
- package/dist/themes/dark.js +2 -2
- package/dist/themes/light.d.ts +1 -1
- package/dist/themes/light.js +2 -2
- package/dist/themes/palette.d.ts +1 -1
- package/package.json +1 -1
- package/dist/extension/component/Attachment/Readonly.d.ts +0 -9
- package/dist/extension/component/Attachment/Readonly.js +0 -91
- package/dist/extension/component/CustomLink/Insert.d.ts +0 -0
- package/dist/extension/component/CustomLink/Insert.js +0 -176
- package/dist/extension/component/CustomLink/Readonly.d.ts +0 -0
- package/dist/extension/component/CustomLink/Readonly.js +0 -106
- package/dist/extension/component/CustomLink/index.d.ts +0 -0
- package/dist/extension/component/CustomLink/index.js +0 -440
- package/dist/extension/component/Link/Readonly.d.ts +0 -8
- package/dist/extension/component/Link/Readonly.js +0 -110
|
@@ -9,10 +9,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
9
9
|
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; } }
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
11
|
import { FloatingPopover } from "../../../component";
|
|
12
|
-
import { CustomSizeIcon, DeleteLineIcon,
|
|
13
|
-
import {
|
|
12
|
+
import { AlignCenterIcon, AlignLeftIcon, AlignRightIcon, CustomSizeIcon, DeleteLineIcon, EditLineIcon } from "../../../component/Icons";
|
|
13
|
+
import { ToolbarItem } from "../../../component/Toolbar";
|
|
14
|
+
import { alpha, Box, Button, Divider, Stack, TextField, useTheme } from "@mui/material";
|
|
14
15
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
15
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
16
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
17
|
+
import { HoverPopover } from "../../../component/HoverPopover";
|
|
16
18
|
import CropImage from "./Crop";
|
|
17
19
|
import InsertImage from "./Insert";
|
|
18
20
|
import ReadonlyImage from "./Readonly";
|
|
@@ -75,9 +77,11 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
75
77
|
selected = _ref.selected,
|
|
76
78
|
onUpload = _ref.onUpload,
|
|
77
79
|
_onError = _ref.onError,
|
|
78
|
-
onValidateUrl = _ref.onValidateUrl
|
|
80
|
+
onValidateUrl = _ref.onValidateUrl,
|
|
81
|
+
getPos = _ref.getPos;
|
|
79
82
|
var attrs = node.attrs;
|
|
80
83
|
var imageRef = useRef(null);
|
|
84
|
+
var theme = useTheme();
|
|
81
85
|
var _useState = useState(false),
|
|
82
86
|
_useState2 = _slicedToArray(_useState, 2),
|
|
83
87
|
isDragging = _useState2[0],
|
|
@@ -94,20 +98,23 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
94
98
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
95
99
|
editSrc = _useState8[0],
|
|
96
100
|
setEditSrc = _useState8[1];
|
|
97
|
-
var _useState9 = useState(
|
|
101
|
+
var _useState9 = useState(null),
|
|
98
102
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var
|
|
103
|
+
dragCorner = _useState10[0],
|
|
104
|
+
setDragCorner = _useState10[1];
|
|
105
|
+
var dragStartXRef = useRef(0);
|
|
106
|
+
var dragStartWidthRef = useRef(0);
|
|
107
|
+
var _useState11 = useState(attrs.title || ''),
|
|
102
108
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
103
|
-
|
|
104
|
-
|
|
109
|
+
editTitle = _useState12[0],
|
|
110
|
+
setEditTitle = _useState12[1];
|
|
105
111
|
var _useState13 = useState(null),
|
|
106
112
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
107
113
|
anchorEl = _useState14[0],
|
|
108
114
|
setAnchorEl = _useState14[1];
|
|
109
|
-
var
|
|
110
|
-
|
|
115
|
+
var imageContentRef = useRef(null);
|
|
116
|
+
var handleShowPopover = function handleShowPopover() {
|
|
117
|
+
return setAnchorEl(imageContentRef.current);
|
|
111
118
|
};
|
|
112
119
|
var handleClosePopover = function handleClosePopover() {
|
|
113
120
|
return setAnchorEl(null);
|
|
@@ -147,24 +154,36 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
147
154
|
});
|
|
148
155
|
}
|
|
149
156
|
}, [attrs.src, attrs.width, updateAttributes]);
|
|
150
|
-
var handleMouseDown = function handleMouseDown(e) {
|
|
157
|
+
var handleMouseDown = function handleMouseDown(e, corner) {
|
|
151
158
|
e.preventDefault();
|
|
159
|
+
e.stopPropagation();
|
|
152
160
|
setIsDragging(true);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
161
|
+
setDragCorner(corner);
|
|
162
|
+
dragStartXRef.current = e.clientX;
|
|
163
|
+
dragStartWidthRef.current = getCurrentDisplayWidth();
|
|
156
164
|
};
|
|
157
|
-
var handleMouseMove = function
|
|
158
|
-
if (!isDragging) return;
|
|
159
|
-
var deltaX = e.clientX -
|
|
160
|
-
var newWidth
|
|
165
|
+
var handleMouseMove = useCallback(function (e) {
|
|
166
|
+
if (!isDragging || !dragCorner) return;
|
|
167
|
+
var deltaX = e.clientX - dragStartXRef.current;
|
|
168
|
+
var newWidth;
|
|
169
|
+
|
|
170
|
+
// 根据不同的角计算宽度变化
|
|
171
|
+
if (dragCorner === 'top-right' || dragCorner === 'bottom-right') {
|
|
172
|
+
// 右侧角:向右拉伸,宽度增加
|
|
173
|
+
newWidth = dragStartWidthRef.current + deltaX;
|
|
174
|
+
} else {
|
|
175
|
+
// 左侧角:向左拉伸,宽度增加(deltaX 为负时宽度增加)
|
|
176
|
+
newWidth = dragStartWidthRef.current - deltaX;
|
|
177
|
+
}
|
|
178
|
+
newWidth = Math.max(100, Math.min(1200, newWidth));
|
|
161
179
|
updateAttributes({
|
|
162
180
|
width: newWidth
|
|
163
181
|
});
|
|
164
|
-
};
|
|
165
|
-
var handleMouseUp = function
|
|
166
|
-
|
|
167
|
-
|
|
182
|
+
}, [isDragging, dragCorner, updateAttributes]);
|
|
183
|
+
var handleMouseUp = useCallback(function () {
|
|
184
|
+
setIsDragging(false);
|
|
185
|
+
setDragCorner(null);
|
|
186
|
+
}, []);
|
|
168
187
|
var handleCropClick = function handleCropClick() {
|
|
169
188
|
return setIsCropping(true);
|
|
170
189
|
};
|
|
@@ -202,7 +221,8 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
202
221
|
updateAttributes({
|
|
203
222
|
src: validatedUrl,
|
|
204
223
|
width: currentWidth,
|
|
205
|
-
error: true
|
|
224
|
+
error: true,
|
|
225
|
+
title: editTitle.trim()
|
|
206
226
|
});
|
|
207
227
|
setEditSrc(validatedUrl);
|
|
208
228
|
_context.next = 15;
|
|
@@ -223,6 +243,14 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
223
243
|
return _ref2.apply(this, arguments);
|
|
224
244
|
};
|
|
225
245
|
}();
|
|
246
|
+
var runTextAlignOnImageParagraph = function runTextAlignOnImageParagraph(align) {
|
|
247
|
+
var pos = typeof getPos === 'function' ? getPos() : null;
|
|
248
|
+
var chain = editor.chain().focus();
|
|
249
|
+
if (pos != null) {
|
|
250
|
+
chain.setTextSelection(pos);
|
|
251
|
+
}
|
|
252
|
+
chain.toggleTextAlign(align).run();
|
|
253
|
+
};
|
|
226
254
|
useEffect(function () {
|
|
227
255
|
if (isDragging) {
|
|
228
256
|
document.addEventListener('mousemove', handleMouseMove);
|
|
@@ -232,7 +260,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
232
260
|
document.removeEventListener('mouseup', handleMouseUp);
|
|
233
261
|
};
|
|
234
262
|
}
|
|
235
|
-
}, [isDragging]);
|
|
263
|
+
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
236
264
|
if (!attrs.src && !editor.isEditable) {
|
|
237
265
|
return null;
|
|
238
266
|
}
|
|
@@ -265,19 +293,94 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
265
293
|
className: "image-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
|
|
266
294
|
as: 'span',
|
|
267
295
|
'data-drag-handle': false
|
|
296
|
+
}, /*#__PURE__*/React.createElement(HoverPopover, {
|
|
297
|
+
actions: /*#__PURE__*/React.createElement(Stack, {
|
|
298
|
+
direction: 'row',
|
|
299
|
+
alignItems: 'center',
|
|
300
|
+
sx: {
|
|
301
|
+
p: 0.5
|
|
302
|
+
}
|
|
303
|
+
}, /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
304
|
+
icon: /*#__PURE__*/React.createElement(EditLineIcon, {
|
|
305
|
+
sx: {
|
|
306
|
+
fontSize: '1rem'
|
|
307
|
+
}
|
|
308
|
+
}),
|
|
309
|
+
tip: "\u7F16\u8F91\u56FE\u7247",
|
|
310
|
+
onClick: handleShowPopover
|
|
311
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
312
|
+
icon: /*#__PURE__*/React.createElement(CustomSizeIcon, {
|
|
313
|
+
sx: {
|
|
314
|
+
fontSize: '1rem'
|
|
315
|
+
}
|
|
316
|
+
}),
|
|
317
|
+
tip: "\u88C1\u5207\u56FE\u7247",
|
|
318
|
+
onClick: handleCropClick
|
|
319
|
+
}), /*#__PURE__*/React.createElement(Divider, {
|
|
320
|
+
orientation: "vertical",
|
|
321
|
+
flexItem: true,
|
|
322
|
+
sx: {
|
|
323
|
+
height: '1rem',
|
|
324
|
+
mx: 0.5,
|
|
325
|
+
alignSelf: 'center',
|
|
326
|
+
borderColor: 'divider'
|
|
327
|
+
}
|
|
328
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
329
|
+
icon: /*#__PURE__*/React.createElement(AlignLeftIcon, {
|
|
330
|
+
sx: {
|
|
331
|
+
fontSize: '1rem'
|
|
332
|
+
}
|
|
333
|
+
}),
|
|
334
|
+
tip: "\u5DE6\u4FA7\u5BF9\u9F50",
|
|
335
|
+
onClick: function onClick() {
|
|
336
|
+
runTextAlignOnImageParagraph('left');
|
|
337
|
+
}
|
|
338
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
339
|
+
icon: /*#__PURE__*/React.createElement(AlignCenterIcon, {
|
|
340
|
+
sx: {
|
|
341
|
+
fontSize: '1rem'
|
|
342
|
+
}
|
|
343
|
+
}),
|
|
344
|
+
tip: "\u5C45\u4E2D\u5BF9\u9F50",
|
|
345
|
+
onClick: function onClick() {
|
|
346
|
+
runTextAlignOnImageParagraph('center');
|
|
347
|
+
}
|
|
348
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
349
|
+
icon: /*#__PURE__*/React.createElement(AlignRightIcon, {
|
|
350
|
+
sx: {
|
|
351
|
+
fontSize: '1rem'
|
|
352
|
+
}
|
|
353
|
+
}),
|
|
354
|
+
tip: "\u53F3\u4FA7\u5BF9\u9F50",
|
|
355
|
+
onClick: function onClick() {
|
|
356
|
+
runTextAlignOnImageParagraph('right');
|
|
357
|
+
}
|
|
358
|
+
}), /*#__PURE__*/React.createElement(Divider, {
|
|
359
|
+
orientation: "vertical",
|
|
360
|
+
flexItem: true,
|
|
361
|
+
sx: {
|
|
362
|
+
height: '1rem',
|
|
363
|
+
mx: 0.5,
|
|
364
|
+
alignSelf: 'center',
|
|
365
|
+
borderColor: 'divider'
|
|
366
|
+
}
|
|
367
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
368
|
+
icon: /*#__PURE__*/React.createElement(DeleteLineIcon, {
|
|
369
|
+
sx: {
|
|
370
|
+
fontSize: '1rem'
|
|
371
|
+
}
|
|
372
|
+
}),
|
|
373
|
+
tip: "\u5220\u9664\u56FE\u7247",
|
|
374
|
+
onClick: deleteNode
|
|
375
|
+
})),
|
|
376
|
+
placement: "top",
|
|
377
|
+
offset: 4
|
|
268
378
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
269
379
|
component: 'span',
|
|
380
|
+
ref: imageContentRef,
|
|
270
381
|
sx: {
|
|
271
382
|
position: 'relative',
|
|
272
|
-
display: 'inline-block'
|
|
273
|
-
border: '1px solid',
|
|
274
|
-
borderColor: 'divider',
|
|
275
|
-
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
276
|
-
p: '0.25rem',
|
|
277
|
-
bgcolor: 'background.paper',
|
|
278
|
-
'&:hover .image-controls': {
|
|
279
|
-
opacity: 1
|
|
280
|
-
}
|
|
383
|
+
display: 'inline-block'
|
|
281
384
|
},
|
|
282
385
|
onMouseEnter: function onMouseEnter() {
|
|
283
386
|
return setIsHovering(true);
|
|
@@ -292,85 +395,109 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
292
395
|
style: {
|
|
293
396
|
maxWidth: '100%',
|
|
294
397
|
height: 'auto',
|
|
295
|
-
cursor: 'default'
|
|
398
|
+
cursor: 'default',
|
|
399
|
+
border: '2px solid',
|
|
400
|
+
borderColor: isHovering || isDragging ? alpha(theme.palette.primary.main, 0.3) : 'transparent'
|
|
296
401
|
},
|
|
297
402
|
onError: function onError(e) {
|
|
298
403
|
_onError === null || _onError === void 0 || _onError(e);
|
|
299
404
|
}
|
|
300
|
-
}), (isHovering || isDragging) && /*#__PURE__*/React.createElement(Box, {
|
|
301
|
-
onMouseDown:
|
|
405
|
+
}), (isHovering || isDragging) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, {
|
|
406
|
+
onMouseDown: function onMouseDown(e) {
|
|
407
|
+
return handleMouseDown(e, 'top-left');
|
|
408
|
+
},
|
|
302
409
|
sx: {
|
|
303
410
|
position: 'absolute',
|
|
304
|
-
|
|
305
|
-
top:
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
411
|
+
left: -4,
|
|
412
|
+
top: -4,
|
|
413
|
+
width: 12,
|
|
414
|
+
height: 12,
|
|
415
|
+
bgcolor: 'background.default',
|
|
416
|
+
cursor: 'nwse-resize',
|
|
417
|
+
borderRadius: '50%',
|
|
418
|
+
border: '2px solid',
|
|
419
|
+
borderColor: isDragging && dragCorner === 'top-left' ? 'primary.main' : alpha(theme.palette.primary.main, 0.3),
|
|
312
420
|
'&:hover': {
|
|
313
|
-
|
|
421
|
+
borderColor: 'primary.main'
|
|
314
422
|
},
|
|
315
423
|
transition: 'background-color 0.2s ease',
|
|
316
424
|
zIndex: 10
|
|
317
425
|
}
|
|
318
|
-
}),
|
|
319
|
-
|
|
426
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
427
|
+
onMouseDown: function onMouseDown(e) {
|
|
428
|
+
return handleMouseDown(e, 'top-right');
|
|
429
|
+
},
|
|
320
430
|
sx: {
|
|
321
431
|
position: 'absolute',
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
}, /*#__PURE__*/React.createElement(EditBoxLineIcon, {
|
|
338
|
-
sx: {
|
|
339
|
-
fontSize: 18
|
|
340
|
-
}
|
|
341
|
-
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
342
|
-
arrow: true,
|
|
343
|
-
title: "\u88C1\u5207\u56FE\u7247"
|
|
344
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
345
|
-
size: "small",
|
|
346
|
-
onClick: handleCropClick,
|
|
347
|
-
sx: {
|
|
348
|
-
color: 'text.primary',
|
|
349
|
-
bgcolor: 'background.paper'
|
|
432
|
+
right: -4,
|
|
433
|
+
top: -4,
|
|
434
|
+
width: 12,
|
|
435
|
+
height: 12,
|
|
436
|
+
bgcolor: 'background.default',
|
|
437
|
+
cursor: 'nesw-resize',
|
|
438
|
+
borderRadius: '50%',
|
|
439
|
+
border: '2px solid',
|
|
440
|
+
borderColor: isDragging && dragCorner === 'top-right' ? 'primary.main' : alpha(theme.palette.primary.main, 0.3),
|
|
441
|
+
'&:hover': {
|
|
442
|
+
borderColor: 'primary.main'
|
|
443
|
+
},
|
|
444
|
+
transition: 'background-color 0.2s ease',
|
|
445
|
+
zIndex: 10
|
|
350
446
|
}
|
|
351
|
-
}, /*#__PURE__*/React.createElement(
|
|
447
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
448
|
+
onMouseDown: function onMouseDown(e) {
|
|
449
|
+
return handleMouseDown(e, 'bottom-left');
|
|
450
|
+
},
|
|
352
451
|
sx: {
|
|
353
|
-
|
|
452
|
+
position: 'absolute',
|
|
453
|
+
left: -4,
|
|
454
|
+
bottom: -2,
|
|
455
|
+
width: 12,
|
|
456
|
+
height: 12,
|
|
457
|
+
cursor: 'nesw-resize',
|
|
458
|
+
borderRadius: '50%',
|
|
459
|
+
border: '2px solid',
|
|
460
|
+
bgcolor: 'background.default',
|
|
461
|
+
borderColor: isDragging && dragCorner === 'bottom-left' ? 'primary.main' : alpha(theme.palette.primary.main, 0.3),
|
|
462
|
+
'&:hover': {
|
|
463
|
+
borderColor: 'primary.main'
|
|
464
|
+
},
|
|
465
|
+
transition: 'background-color 0.2s ease',
|
|
466
|
+
zIndex: 10
|
|
354
467
|
}
|
|
355
|
-
})
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
size: "small",
|
|
360
|
-
onClick: deleteNode,
|
|
468
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
469
|
+
onMouseDown: function onMouseDown(e) {
|
|
470
|
+
return handleMouseDown(e, 'bottom-right');
|
|
471
|
+
},
|
|
361
472
|
sx: {
|
|
362
|
-
|
|
363
|
-
|
|
473
|
+
position: 'absolute',
|
|
474
|
+
right: -4,
|
|
475
|
+
bottom: -2,
|
|
476
|
+
width: 12,
|
|
477
|
+
height: 12,
|
|
478
|
+
bgcolor: 'background.default',
|
|
479
|
+
cursor: 'nwse-resize',
|
|
480
|
+
borderRadius: '50%',
|
|
481
|
+
border: '2px solid',
|
|
482
|
+
borderColor: isDragging && dragCorner === 'bottom-right' ? 'primary.main' : alpha(theme.palette.primary.main, 0.3),
|
|
483
|
+
'&:hover': {
|
|
484
|
+
borderColor: 'primary.main'
|
|
485
|
+
},
|
|
486
|
+
transition: 'background-color 0.2s ease',
|
|
487
|
+
zIndex: 10
|
|
364
488
|
}
|
|
365
|
-
}, /*#__PURE__*/React.createElement(
|
|
489
|
+
}))), attrs.title && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Box, {
|
|
490
|
+
component: "span",
|
|
366
491
|
sx: {
|
|
367
|
-
|
|
492
|
+
display: 'inline-block',
|
|
493
|
+
fontSize: '0.75rem',
|
|
494
|
+
color: 'text.auxiliary'
|
|
368
495
|
}
|
|
369
|
-
})))
|
|
496
|
+
}, attrs.title))), /*#__PURE__*/React.createElement(FloatingPopover, {
|
|
370
497
|
open: Boolean(anchorEl),
|
|
371
498
|
anchorEl: anchorEl,
|
|
372
499
|
onClose: handleClosePopover,
|
|
373
|
-
placement: "
|
|
500
|
+
placement: "top"
|
|
374
501
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
375
502
|
sx: {
|
|
376
503
|
p: 2,
|
|
@@ -378,7 +505,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
378
505
|
}
|
|
379
506
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
380
507
|
sx: {
|
|
381
|
-
fontSize: '0.
|
|
508
|
+
fontSize: '0.75rem',
|
|
382
509
|
color: 'text.secondary',
|
|
383
510
|
lineHeight: '1.5',
|
|
384
511
|
mb: 1
|
|
@@ -391,6 +518,21 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
391
518
|
return setEditSrc(e.target.value);
|
|
392
519
|
},
|
|
393
520
|
placeholder: "\u8F93\u5165\u56FE\u7247\u7684 URL"
|
|
521
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
522
|
+
sx: {
|
|
523
|
+
fontSize: '0.75rem',
|
|
524
|
+
color: 'text.secondary',
|
|
525
|
+
lineHeight: '1.5',
|
|
526
|
+
mb: 1
|
|
527
|
+
}
|
|
528
|
+
}, "\u56FE\u7247\u63CF\u8FF0"), /*#__PURE__*/React.createElement(TextField, {
|
|
529
|
+
fullWidth: true,
|
|
530
|
+
size: "small",
|
|
531
|
+
value: editTitle,
|
|
532
|
+
onChange: function onChange(e) {
|
|
533
|
+
return setEditTitle(e.target.value);
|
|
534
|
+
},
|
|
535
|
+
placeholder: "\u8F93\u5165\u56FE\u7247\u63CF\u8FF0\uFF08\u53EF\u9009\uFF09"
|
|
394
536
|
}), /*#__PURE__*/React.createElement(Stack, {
|
|
395
537
|
direction: 'row',
|
|
396
538
|
gap: 1,
|
|
@@ -185,7 +185,7 @@ var InsertLink = function InsertLink(_ref) {
|
|
|
185
185
|
control: /*#__PURE__*/React.createElement(Radio, {
|
|
186
186
|
size: "small"
|
|
187
187
|
}),
|
|
188
|
-
label: "\
|
|
188
|
+
label: "\u6587\u5B57"
|
|
189
189
|
}), /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
190
190
|
value: "icon",
|
|
191
191
|
control: /*#__PURE__*/React.createElement(Radio, {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { LinkAttributes } from ".";
|
|
3
|
+
interface LinkContentProps {
|
|
4
|
+
attrs: LinkAttributes;
|
|
5
|
+
/** 是否为编辑模式 */
|
|
6
|
+
editable?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 链接内容组件
|
|
10
|
+
* 用于渲染链接的实际内容,支持编辑和只读模式
|
|
11
|
+
*/
|
|
12
|
+
export declare const LinkContent: React.FC<LinkContentProps>;
|
|
13
|
+
export default LinkContent;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import { ChromeIcon } from "../../../component/Icons";
|
|
3
|
+
import { getLinkTitle } from "../../../util";
|
|
4
|
+
import { Avatar, Box, Stack } from "@mui/material";
|
|
5
|
+
import React from "react";
|
|
6
|
+
/**
|
|
7
|
+
* 链接内容组件
|
|
8
|
+
* 用于渲染链接的实际内容,支持编辑和只读模式
|
|
9
|
+
*/
|
|
10
|
+
export var LinkContent = function LinkContent(_ref) {
|
|
11
|
+
var attrs = _ref.attrs,
|
|
12
|
+
_ref$editable = _ref.editable,
|
|
13
|
+
editable = _ref$editable === void 0 ? false : _ref$editable;
|
|
14
|
+
var favicon = '';
|
|
15
|
+
try {
|
|
16
|
+
favicon = attrs.href ? new URL(attrs.href).origin + '/favicon.ico' : '';
|
|
17
|
+
} catch (err) {}
|
|
18
|
+
|
|
19
|
+
// 编辑模式和只读模式的样式差异
|
|
20
|
+
var blockStyles = editable ? {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
border: '1px solid',
|
|
23
|
+
borderColor: 'divider',
|
|
24
|
+
cursor: 'pointer',
|
|
25
|
+
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
26
|
+
p: 2,
|
|
27
|
+
textDecoration: 'none',
|
|
28
|
+
color: 'inherit',
|
|
29
|
+
':hover': {
|
|
30
|
+
borderColor: 'primary.main'
|
|
31
|
+
}
|
|
32
|
+
} : {
|
|
33
|
+
display: 'block'
|
|
34
|
+
};
|
|
35
|
+
var blockInnerStyles = editable ? {
|
|
36
|
+
width: '100%'
|
|
37
|
+
} : {
|
|
38
|
+
border: '1px solid',
|
|
39
|
+
borderColor: 'divider',
|
|
40
|
+
color: 'text.primary',
|
|
41
|
+
cursor: 'pointer',
|
|
42
|
+
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
43
|
+
p: 2,
|
|
44
|
+
':hover': {
|
|
45
|
+
borderColor: 'primary.main'
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var inlineStyles = editable ? {
|
|
49
|
+
color: 'primary.main',
|
|
50
|
+
cursor: 'pointer',
|
|
51
|
+
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
52
|
+
transition: 'background-color 0.2s ease',
|
|
53
|
+
display: 'inline',
|
|
54
|
+
':hover': {
|
|
55
|
+
textDecoration: 'underline !important'
|
|
56
|
+
}
|
|
57
|
+
} : {
|
|
58
|
+
display: 'inline-flex',
|
|
59
|
+
alignItems: 'baseline',
|
|
60
|
+
gap: '2px',
|
|
61
|
+
color: 'primary.main',
|
|
62
|
+
'&:hover': {
|
|
63
|
+
textDecoration: 'underline !important'
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, attrs.type === 'block' ? /*#__PURE__*/React.createElement(Box, _extends({
|
|
67
|
+
component: "a",
|
|
68
|
+
href: attrs.href,
|
|
69
|
+
target: attrs.target,
|
|
70
|
+
rel: editable ? attrs.target === '_blank' ? 'noopener noreferrer' : undefined : attrs.rel
|
|
71
|
+
}, !editable && {
|
|
72
|
+
'data-title': attrs.title,
|
|
73
|
+
'data-type': attrs.type
|
|
74
|
+
}, {
|
|
75
|
+
sx: blockStyles
|
|
76
|
+
}), /*#__PURE__*/React.createElement(Stack, {
|
|
77
|
+
direction: 'row',
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
gap: 2,
|
|
80
|
+
sx: blockInnerStyles
|
|
81
|
+
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
82
|
+
sx: {
|
|
83
|
+
width: '2rem',
|
|
84
|
+
height: '2rem',
|
|
85
|
+
alignSelf: 'center',
|
|
86
|
+
bgcolor: '#FFFFFF'
|
|
87
|
+
},
|
|
88
|
+
src: favicon
|
|
89
|
+
}, /*#__PURE__*/React.createElement(ChromeIcon, {
|
|
90
|
+
sx: {
|
|
91
|
+
fontSize: '2rem',
|
|
92
|
+
cursor: 'grab',
|
|
93
|
+
color: 'primary.main',
|
|
94
|
+
alignSelf: 'center',
|
|
95
|
+
':active': {
|
|
96
|
+
cursor: 'grabbing'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
})), /*#__PURE__*/React.createElement(Stack, {
|
|
100
|
+
sx: {
|
|
101
|
+
flex: 1
|
|
102
|
+
},
|
|
103
|
+
gap: 0.5
|
|
104
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
105
|
+
sx: {
|
|
106
|
+
fontSize: '0.875rem',
|
|
107
|
+
fontWeight: 'bold'
|
|
108
|
+
}
|
|
109
|
+
}, attrs.title || getLinkTitle(attrs.href)), /*#__PURE__*/React.createElement(Box, {
|
|
110
|
+
sx: {
|
|
111
|
+
fontSize: '0.75rem',
|
|
112
|
+
color: 'text.secondary'
|
|
113
|
+
}
|
|
114
|
+
}, attrs.href)))) : /*#__PURE__*/React.createElement(Box, _extends({
|
|
115
|
+
component: "a",
|
|
116
|
+
href: attrs.href,
|
|
117
|
+
target: attrs.target,
|
|
118
|
+
rel: editable ? attrs.target === '_blank' ? 'noopener noreferrer' : undefined : attrs.rel
|
|
119
|
+
}, !editable && {
|
|
120
|
+
'data-title': attrs.title,
|
|
121
|
+
'data-type': attrs.type
|
|
122
|
+
}, {
|
|
123
|
+
sx: inlineStyles
|
|
124
|
+
}), editable ? /*#__PURE__*/React.createElement(Box, {
|
|
125
|
+
component: 'span',
|
|
126
|
+
sx: {
|
|
127
|
+
display: 'inline-flex',
|
|
128
|
+
alignItems: 'baseline',
|
|
129
|
+
gap: 0.5
|
|
130
|
+
}
|
|
131
|
+
}, attrs.type === 'icon' && /*#__PURE__*/React.createElement(Avatar, {
|
|
132
|
+
sx: {
|
|
133
|
+
width: '1rem',
|
|
134
|
+
height: '1rem',
|
|
135
|
+
alignSelf: 'center',
|
|
136
|
+
bgcolor: '#FFFFFF'
|
|
137
|
+
},
|
|
138
|
+
src: favicon
|
|
139
|
+
}, /*#__PURE__*/React.createElement(ChromeIcon, {
|
|
140
|
+
sx: {
|
|
141
|
+
fontSize: '1rem',
|
|
142
|
+
cursor: 'grab',
|
|
143
|
+
color: 'primary.main',
|
|
144
|
+
alignSelf: 'center',
|
|
145
|
+
':active': {
|
|
146
|
+
cursor: 'grabbing'
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
})), attrs.title || getLinkTitle(attrs.href)) : /*#__PURE__*/React.createElement(React.Fragment, null, attrs.type === 'icon' && /*#__PURE__*/React.createElement(Avatar, {
|
|
150
|
+
sx: {
|
|
151
|
+
width: '1rem',
|
|
152
|
+
height: '1rem',
|
|
153
|
+
alignSelf: 'center',
|
|
154
|
+
bgcolor: '#FFFFFF'
|
|
155
|
+
},
|
|
156
|
+
src: favicon
|
|
157
|
+
}, /*#__PURE__*/React.createElement(ChromeIcon, {
|
|
158
|
+
sx: {
|
|
159
|
+
fontSize: '1rem',
|
|
160
|
+
cursor: 'grab',
|
|
161
|
+
color: 'primary.main',
|
|
162
|
+
alignSelf: 'center',
|
|
163
|
+
':active': {
|
|
164
|
+
cursor: 'grabbing'
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
})), attrs.title || getLinkTitle(attrs.href))));
|
|
168
|
+
};
|
|
169
|
+
export default LinkContent;
|