@ctzhian/tiptap 2.12.4 → 2.12.6
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.
|
@@ -32,6 +32,21 @@ export var AttachmentContent = function AttachmentContent(_ref) {
|
|
|
32
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
33
33
|
isHovered = _useState2[0],
|
|
34
34
|
setIsHovered = _useState2[1];
|
|
35
|
+
var handlePreview = function handlePreview(e) {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
try {
|
|
39
|
+
var a = document.createElement('a');
|
|
40
|
+
a.href = attrs.url;
|
|
41
|
+
a.target = '_blank';
|
|
42
|
+
document.body.appendChild(a);
|
|
43
|
+
a.click();
|
|
44
|
+
document.body.removeChild(a);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('预览失败:', error);
|
|
47
|
+
window.open(attrs.url, '_blank');
|
|
48
|
+
}
|
|
49
|
+
};
|
|
35
50
|
|
|
36
51
|
// 处理文件下载
|
|
37
52
|
var handleDownload = /*#__PURE__*/function () {
|
|
@@ -204,13 +219,7 @@ export var AttachmentContent = function AttachmentContent(_ref) {
|
|
|
204
219
|
gap: 0.5
|
|
205
220
|
}, isPdf && /*#__PURE__*/React.createElement(IconButton, {
|
|
206
221
|
size: "small",
|
|
207
|
-
|
|
208
|
-
href: attrs.url,
|
|
209
|
-
target: "_blank",
|
|
210
|
-
rel: "noopener noreferrer",
|
|
211
|
-
onClick: function onClick(e) {
|
|
212
|
-
return e.stopPropagation();
|
|
213
|
-
},
|
|
222
|
+
onClick: handlePreview,
|
|
214
223
|
sx: {
|
|
215
224
|
color: attrs.url === 'error' ? 'error.main' : 'text.disabled',
|
|
216
225
|
alignSelf: 'center'
|