@ctzhian/tiptap 1.11.3 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Editor/demo.js +16 -21
- package/dist/EditorMarkdown/index.js +2 -2
- 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 +43 -35
- package/dist/extension/component/CodeBlock/index.js +139 -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/component/UploadProgress/index.d.ts +1 -1
- package/dist/extension/index.js +1 -1
- package/dist/index.css +64 -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
package/dist/Editor/demo.js
CHANGED
|
@@ -7,12 +7,10 @@ import { Box } from '@mui/material';
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import "../index.css";
|
|
9
9
|
var Reader = function Reader() {
|
|
10
|
-
var isMarkdown = true;
|
|
11
10
|
var _useTiptap = useTiptap({
|
|
12
11
|
editable: true,
|
|
13
12
|
exclude: ['invisibleCharacters'],
|
|
14
13
|
onError: function onError(error) {
|
|
15
|
-
console.error('Editor Error:', error);
|
|
16
14
|
alert(error.message);
|
|
17
15
|
},
|
|
18
16
|
onValidateUrl: function () {
|
|
@@ -20,42 +18,39 @@ var Reader = function Reader() {
|
|
|
20
18
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
21
19
|
while (1) switch (_context.prev = _context.next) {
|
|
22
20
|
case 0:
|
|
23
|
-
console.log("\u9A8C\u8BC1 ".concat(type, " \u94FE\u63A5:"), url);
|
|
24
|
-
|
|
25
|
-
// 拦截 base64 链接
|
|
26
21
|
if (!url.startsWith('data:')) {
|
|
27
|
-
_context.next =
|
|
22
|
+
_context.next = 2;
|
|
28
23
|
break;
|
|
29
24
|
}
|
|
30
25
|
throw new Error("\u4E0D\u652F\u6301 base64 \u94FE\u63A5\uFF0C\u8BF7\u4F7F\u7528\u53EF\u8BBF\u95EE\u7684 ".concat(type, " URL"));
|
|
31
|
-
case
|
|
26
|
+
case 2:
|
|
32
27
|
_context.t0 = type;
|
|
33
|
-
_context.next = _context.t0 === 'image' ?
|
|
28
|
+
_context.next = _context.t0 === 'image' ? 5 : _context.t0 === 'video' ? 7 : _context.t0 === 'audio' ? 9 : _context.t0 === 'iframe' ? 11 : 13;
|
|
34
29
|
break;
|
|
35
|
-
case
|
|
30
|
+
case 5:
|
|
36
31
|
if (!url.match(/\.(jpg|jpeg|png|gif|webp|svg)(\?.*)?$/i)) {
|
|
37
32
|
console.warn('图片链接可能不是有效的图片格式');
|
|
38
33
|
}
|
|
39
|
-
return _context.abrupt("break",
|
|
40
|
-
case
|
|
34
|
+
return _context.abrupt("break", 13);
|
|
35
|
+
case 7:
|
|
41
36
|
if (!url.match(/\.(mp4|webm|ogg|mov|avi|wmv|flv|mkv)(\?.*)?$/i)) {
|
|
42
37
|
console.warn('视频链接可能不是有效的视频格式');
|
|
43
38
|
}
|
|
44
|
-
return _context.abrupt("break",
|
|
45
|
-
case
|
|
39
|
+
return _context.abrupt("break", 13);
|
|
40
|
+
case 9:
|
|
46
41
|
if (!url.match(/\.(mp3|wav|ogg|m4a|flac|aac|wma)(\?.*)?$/i)) {
|
|
47
42
|
console.warn('音频链接可能不是有效的音频格式');
|
|
48
43
|
}
|
|
49
|
-
return _context.abrupt("break",
|
|
50
|
-
case
|
|
44
|
+
return _context.abrupt("break", 13);
|
|
45
|
+
case 11:
|
|
51
46
|
// iframe 可以嵌入任何 URL,但可以检查是否是 HTTPS
|
|
52
47
|
if (url.startsWith('http://') && !url.includes('localhost')) {
|
|
53
48
|
console.warn('建议使用 HTTPS 链接以确保安全性');
|
|
54
49
|
}
|
|
55
|
-
return _context.abrupt("break",
|
|
56
|
-
case
|
|
50
|
+
return _context.abrupt("break", 13);
|
|
51
|
+
case 13:
|
|
57
52
|
return _context.abrupt("return", url);
|
|
58
|
-
case
|
|
53
|
+
case 14:
|
|
59
54
|
case "end":
|
|
60
55
|
return _context.stop();
|
|
61
56
|
}
|
|
@@ -67,10 +62,10 @@ var Reader = function Reader() {
|
|
|
67
62
|
return onValidateUrl;
|
|
68
63
|
}(),
|
|
69
64
|
onSave: function onSave(editor) {
|
|
70
|
-
var value =
|
|
65
|
+
var value = editor.getHTML();
|
|
71
66
|
console.log(value);
|
|
72
67
|
editor.chain().focus().setContent(value, {
|
|
73
|
-
contentType:
|
|
68
|
+
contentType: 'html'
|
|
74
69
|
}).run();
|
|
75
70
|
},
|
|
76
71
|
onAiWritingGetSuggestion: function () {
|
|
@@ -157,7 +152,7 @@ var Reader = function Reader() {
|
|
|
157
152
|
}
|
|
158
153
|
return onUpload;
|
|
159
154
|
}(),
|
|
160
|
-
content:
|
|
155
|
+
content: "<p>\u8FD9\u91CC\u662F\u6B63\u6587\u90E8\u5206\uFF0C\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A</p><p></p><h1 id=\"b8f46431-15cc-4d9a-823f-3b99a5048e9d\">\u8FD9\u662F\u4E00\u7EA7\u6807\u9898</h1><h2 id=\"ef598fd2-24f8-472f-bedc-a5e4e39e5373\">\u4E8C\u7EA7\u6807\u9898</h2><h3 id=\"2ea03e39-c201-49ae-9236-3acf23b14965\">\u4E09\u7EA7\u6807\u9898</h3><h4 id=\"9a0dd00d-e0b8-4ae4-9371-b6f2e49ce0af\">\u56DB\u7EA7\u6807\u9898</h4><p></p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li></ol></li></ol></li></ol></li><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li></ol><p></p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li></ul></li></ul></li></ul></li><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li></ul><p></p><ul data-type=\"taskList\"><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>\u4EFB\u52A1\u5217\u8868</p><ul data-type=\"taskList\"><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"true\"><label><input type=\"checkbox\" checked=\"checked\"><span></span></label><div><p>\u4EFB\u52A1\u5217\u8868</p></div></li><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>\u4EFB\u52A1\u5217\u8868</p></div></li></ul></div></li><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>\u4EFB\u52A1\u5217\u8868</p></div></li><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>\u4EFB\u52A1\u5217\u8868</p></div></li></ul><p></p><blockquote><p>\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9</p><p>\u6362\u4E00\u6BB5\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9</p></blockquote><p></p><pre><code class=\"language-c\">#include <stdio.h>\n\nint main(int argc, char* argv[]) {\n return 0;\n}</code></pre><p></p><div data-id=\"alert_d89jtsekma\" data-variant=\"warning\" data-type=\"icon\" data-node=\"alert\"><p>\u8FD9\u91CC\u662F\u9AD8\u4EAE\u5757</p></div><div data-id=\"alert_y52bknyrhp\" data-variant=\"default\" data-type=\"icon\" data-node=\"alert\"><p></p></div><div data-id=\"alert_8kccvrutm1b\" data-variant=\"error\" data-type=\"icon\" data-node=\"alert\"><p><span style=\"color: rgb(254, 69, 69);\">\u8FD9\u91CC\u662F\u9AD8\u4EAE\u5757</span></p></div><p></p><p><a target=\"_blank\" type=\"text\" href=\"\u641C\u7D22\" title=\"\u8FD9\u662F\u94FE\u63A5\">\u8FD9\u662F\u94FE\u63A5</a></p><p><a target=\"_blank\" type=\"text\" href=\"http://a123123\" title=\"http://a123123\">http://a123123</a></p><a target=\"_blank\" type=\"block\" href=\"http://localhost:8000/components/%E6%90%9C%E7%B4%A2\" title=\"\u8FD9\u662F\u94FE\u63A5\">\u8FD9\u662F\u94FE\u63A5</a><hr class=\"custom-horizontal-rule\"><p>\u8FD9\u662F\u5206\u5272\u7EBF</p><hr class=\"custom-horizontal-rule\"><p></p><p><span data-latex=\"a, b, c \neq { { a}, b, c}\" data-type=\"inline-math\"></span></p><div data-latex=\"\frac{int_{0}^{\frac{pi}{2}}}{sum_{i=1}^{n}} = 1\" data-type=\"block-math\"></div><p></p><p style=\"text-align: center;\"><img src=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" width=\"375\"></p><p style=\"text-align: left;\"></p><div data-tag=\"attachment\" url=\"\" title=\"\" size=\"0\" data-url=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" data-title=\"4174c1ae-6d06-4287-a184-0b24c7c698fd.png\" data-size=\"193.47 KB\"></div><div data-tag=\"attachment\" url=\"\" title=\"\" size=\"0\" data-url=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" data-title=\"\u9ED8\u8BA4\u77E5\u8BC6\u5E93222.lakebook\" data-size=\"170.5 KB\"></div><p style=\"text-align: left;\"></p><div class=\"tableWrapper\"><table style=\"min-width: 400px;\"><colgroup><col style=\"min-width: 100px;\"><col style=\"min-width: 100px;\"><col style=\"min-width: 100px;\"><col style=\"min-width: 100px;\"></colgroup><tbody><tr class=\"table-row\"><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>\u963F\u65AF\u987F</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>\u5F97\u5230\u7684</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>\u4E0A\u4E0A\u8272</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>\u53EF\u63A7\u54C7</p></th></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p><img src=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" width=\"100\"></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td></tr></tbody></table></div><p></p><p>\u4E30\u5C0F\u5B66\u6821\u56ED\u751F\u6D3B<strong>\u52A0\u918B\u52A0\u918B</strong><em>\u5199\u9898\u5199\u9898</em></p>"
|
|
161
156
|
}),
|
|
162
157
|
editor = _useTiptap.editor;
|
|
163
158
|
return /*#__PURE__*/React.createElement(EditorThemeProvider, {
|
|
@@ -77,7 +77,7 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
77
77
|
top: 0,
|
|
78
78
|
left: 0,
|
|
79
79
|
right: 0,
|
|
80
|
-
zIndex:
|
|
80
|
+
zIndex: 2000
|
|
81
81
|
})
|
|
82
82
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
83
83
|
direction: "row",
|
|
@@ -91,7 +91,7 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
91
91
|
borderRadius: '4px 4px 0 0',
|
|
92
92
|
fontSize: 12,
|
|
93
93
|
lineHeight: '20px',
|
|
94
|
-
color: 'text.
|
|
94
|
+
color: 'text.auxiliary',
|
|
95
95
|
'.md-display-mode-active': {
|
|
96
96
|
color: 'primary.main',
|
|
97
97
|
bgcolor: alpha(theme.palette.primary.main, 0.1)
|
package/dist/asset/css/index.css
CHANGED
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
padding: 0.25rem;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
.tiptap.ProseMirror a {
|
|
29
|
+
text-decoration: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
.tiptap.ProseMirror label:has(input[type="checkbox"]) {
|
|
29
33
|
line-height: 1;
|
|
30
34
|
padding-top: 0.5rem;
|
|
@@ -36,7 +40,7 @@
|
|
|
36
40
|
-moz-appearance: none;
|
|
37
41
|
width: 1rem;
|
|
38
42
|
height: 1rem;
|
|
39
|
-
border:
|
|
43
|
+
border: 1px solid;
|
|
40
44
|
border-radius: 4px;
|
|
41
45
|
background-color: var(--mui-palette-background-default);
|
|
42
46
|
cursor: pointer;
|
|
@@ -50,8 +54,8 @@
|
|
|
50
54
|
|
|
51
55
|
.tiptap.ProseMirror input[type="checkbox"]:checked::after {
|
|
52
56
|
content: "";
|
|
53
|
-
width:
|
|
54
|
-
height:
|
|
57
|
+
width: 70%;
|
|
58
|
+
height: 70%;
|
|
55
59
|
position: absolute;
|
|
56
60
|
left: 50%;
|
|
57
61
|
top: 50%;
|
|
@@ -97,7 +101,7 @@
|
|
|
97
101
|
.tiptap.ProseMirror .react-renderer.node-blockLink:has(.block-link-wrapper),
|
|
98
102
|
.tiptap.ProseMirror .react-renderer.node-attachment:has(.block-attachment-wrapper) {
|
|
99
103
|
display: block;
|
|
100
|
-
margin:
|
|
104
|
+
margin: 1rem 0;
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
.tiptap.ProseMirror p :first-child:is(.react-renderer.node-image),
|
|
@@ -114,6 +118,13 @@
|
|
|
114
118
|
.tiptap.ProseMirror .video-wrapper,
|
|
115
119
|
.tiptap.ProseMirror .image-wrapper {
|
|
116
120
|
display: inline-block;
|
|
121
|
+
box-sizing: border-box;
|
|
122
|
+
text-align: center;
|
|
123
|
+
line-height: 1;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.tiptap.ProseMirror .image-wrapper img {
|
|
127
|
+
line-height: 0;
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
.tiptap.ProseMirror .codeblock-wrapper.ProseMirror-selectednode>pre,
|
|
@@ -124,10 +135,6 @@
|
|
|
124
135
|
background-color: color-mix(in srgb, var(--mui-palette-primary-main) 5%, transparent);
|
|
125
136
|
}
|
|
126
137
|
|
|
127
|
-
.tiptap.ProseMirror .image-wrapper img {
|
|
128
|
-
vertical-align: middle;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
138
|
.tiptap.ProseMirror .custom-placeholder-node {
|
|
132
139
|
position: relative;
|
|
133
140
|
}
|
|
@@ -162,4 +169,8 @@
|
|
|
162
169
|
height: 1.5rem;
|
|
163
170
|
left: 32px;
|
|
164
171
|
z-index: 1;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.tiptap.ProseMirror .custom-horizontal-rule {
|
|
175
|
+
margin: 20px 0;
|
|
165
176
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MenuItem } from "../../type";
|
|
2
|
+
import { PopoverOrigin } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface ActionDropdownProps {
|
|
5
|
+
/** 菜单列表 */
|
|
6
|
+
list: MenuItem[];
|
|
7
|
+
/** 当前选中项的 key */
|
|
8
|
+
selected: string | number;
|
|
9
|
+
/** 触发器提示 */
|
|
10
|
+
tip?: string;
|
|
11
|
+
/** Popover ID */
|
|
12
|
+
id?: string;
|
|
13
|
+
/** 菜单宽度 */
|
|
14
|
+
width?: number;
|
|
15
|
+
/** 菜单最小宽度 */
|
|
16
|
+
minWidth?: number;
|
|
17
|
+
/** 右侧箭头图标 */
|
|
18
|
+
arrowIcon?: React.ReactNode;
|
|
19
|
+
/** Popover 锚点位置 */
|
|
20
|
+
anchorOrigin?: PopoverOrigin;
|
|
21
|
+
/** Popover 变换位置 */
|
|
22
|
+
transformOrigin?: PopoverOrigin;
|
|
23
|
+
}
|
|
24
|
+
declare const ActionDropdown: React.FC<ActionDropdownProps>;
|
|
25
|
+
export default ActionDropdown;
|
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { ToolbarItem } from "../Toolbar";
|
|
14
|
+
import { Box, Popover, Stack } from '@mui/material';
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import { ArrowDownSLineIcon } from "../Icons";
|
|
17
|
+
var ActionDropdown = function ActionDropdown(_ref) {
|
|
18
|
+
var list = _ref.list,
|
|
19
|
+
selected = _ref.selected,
|
|
20
|
+
tip = _ref.tip,
|
|
21
|
+
_ref$id = _ref.id,
|
|
22
|
+
id = _ref$id === void 0 ? 'action-dropdown' : _ref$id,
|
|
23
|
+
width = _ref.width,
|
|
24
|
+
_ref$minWidth = _ref.minWidth,
|
|
25
|
+
minWidth = _ref$minWidth === void 0 ? 160 : _ref$minWidth,
|
|
26
|
+
arrowIcon = _ref.arrowIcon,
|
|
27
|
+
_ref$anchorOrigin = _ref.anchorOrigin,
|
|
28
|
+
anchorOrigin = _ref$anchorOrigin === void 0 ? {
|
|
29
|
+
vertical: 'bottom',
|
|
30
|
+
horizontal: 'left'
|
|
31
|
+
} : _ref$anchorOrigin,
|
|
32
|
+
_ref$transformOrigin = _ref.transformOrigin,
|
|
33
|
+
transformOrigin = _ref$transformOrigin === void 0 ? {
|
|
34
|
+
vertical: 'top',
|
|
35
|
+
horizontal: 'left'
|
|
36
|
+
} : _ref$transformOrigin;
|
|
37
|
+
var _React$useState = React.useState(null),
|
|
38
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
39
|
+
anchorEl = _React$useState2[0],
|
|
40
|
+
setAnchorEl = _React$useState2[1];
|
|
41
|
+
|
|
42
|
+
// 根据 selected 找到当前选中的项
|
|
43
|
+
var selectedItem = React.useMemo(function () {
|
|
44
|
+
return list.find(function (item) {
|
|
45
|
+
return item.key === selected;
|
|
46
|
+
});
|
|
47
|
+
}, [list, selected]);
|
|
48
|
+
var handleClick = function handleClick(event) {
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
setAnchorEl(event.currentTarget);
|
|
51
|
+
};
|
|
52
|
+
var handleClose = function handleClose() {
|
|
53
|
+
setAnchorEl(null);
|
|
54
|
+
};
|
|
55
|
+
var handleItemClick = function handleItemClick(event, item) {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
|
|
59
|
+
// 立即执行回调
|
|
60
|
+
if (item.onClick) {
|
|
61
|
+
item.onClick();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 然后关闭菜单
|
|
65
|
+
handleClose();
|
|
66
|
+
};
|
|
67
|
+
var open = Boolean(anchorEl);
|
|
68
|
+
var curId = open ? id : undefined;
|
|
69
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
70
|
+
icon: selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon,
|
|
71
|
+
text: /*#__PURE__*/React.createElement(Stack, {
|
|
72
|
+
direction: "row",
|
|
73
|
+
alignItems: "center",
|
|
74
|
+
gap: 0.5
|
|
75
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
76
|
+
component: "span"
|
|
77
|
+
}, selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.label), /*#__PURE__*/React.createElement(ArrowDownSLineIcon, {
|
|
78
|
+
sx: {
|
|
79
|
+
fontSize: 16,
|
|
80
|
+
transition: 'transform 0.2s ease-in-out',
|
|
81
|
+
transform: open ? 'rotate(-180deg)' : 'rotate(0deg)'
|
|
82
|
+
}
|
|
83
|
+
})),
|
|
84
|
+
tip: tip,
|
|
85
|
+
onClick: handleClick,
|
|
86
|
+
"aria-describedby": curId
|
|
87
|
+
}), /*#__PURE__*/React.createElement(Popover, {
|
|
88
|
+
id: curId,
|
|
89
|
+
open: open,
|
|
90
|
+
anchorEl: anchorEl,
|
|
91
|
+
onClose: handleClose,
|
|
92
|
+
anchorOrigin: anchorOrigin,
|
|
93
|
+
transformOrigin: transformOrigin,
|
|
94
|
+
disableScrollLock: true,
|
|
95
|
+
disableAutoFocus: true,
|
|
96
|
+
disableEnforceFocus: true,
|
|
97
|
+
slotProps: {
|
|
98
|
+
root: {
|
|
99
|
+
slotProps: {
|
|
100
|
+
backdrop: {
|
|
101
|
+
invisible: true
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
107
|
+
sx: _objectSpread({
|
|
108
|
+
p: 0.5,
|
|
109
|
+
minWidth: minWidth,
|
|
110
|
+
lineHeight: 1.625
|
|
111
|
+
}, width ? {
|
|
112
|
+
width: width
|
|
113
|
+
} : {})
|
|
114
|
+
}, list.map(function (item) {
|
|
115
|
+
var _item$children;
|
|
116
|
+
return item.customLabel ? /*#__PURE__*/React.createElement(Box, {
|
|
117
|
+
key: item.key
|
|
118
|
+
}, item.customLabel) : /*#__PURE__*/React.createElement(Box, {
|
|
119
|
+
key: item.key,
|
|
120
|
+
onMouseDown: function onMouseDown(e) {
|
|
121
|
+
return handleItemClick(e, item);
|
|
122
|
+
},
|
|
123
|
+
sx: _objectSpread({
|
|
124
|
+
cursor: 'pointer',
|
|
125
|
+
borderRadius: 1,
|
|
126
|
+
fontSize: 14,
|
|
127
|
+
p: 1,
|
|
128
|
+
userSelect: 'none',
|
|
129
|
+
':hover': {
|
|
130
|
+
bgcolor: 'action.hover'
|
|
131
|
+
}
|
|
132
|
+
}, item.key === selected ? {
|
|
133
|
+
color: 'primary.main',
|
|
134
|
+
bgcolor: 'action.selected'
|
|
135
|
+
} : {})
|
|
136
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
137
|
+
alignItems: "center",
|
|
138
|
+
gap: 1.5,
|
|
139
|
+
direction: "row"
|
|
140
|
+
}, item.icon, /*#__PURE__*/React.createElement(Box, {
|
|
141
|
+
sx: _objectSpread({
|
|
142
|
+
flexGrow: 1
|
|
143
|
+
}, item.textSx)
|
|
144
|
+
}, item.label), item.extra, (_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length ? arrowIcon : null));
|
|
145
|
+
}))));
|
|
146
|
+
};
|
|
147
|
+
export default ActionDropdown;
|
|
@@ -40,7 +40,7 @@ var DragIcon = function DragIcon(_ref) {
|
|
|
40
40
|
display: 'flex',
|
|
41
41
|
alignItems: 'center',
|
|
42
42
|
justifyContent: 'center',
|
|
43
|
-
color: 'text.
|
|
43
|
+
color: 'text.auxiliary',
|
|
44
44
|
cursor: 'grab',
|
|
45
45
|
borderColor: 'divider',
|
|
46
46
|
bgcolor: 'background.paper',
|
|
@@ -72,7 +72,7 @@ var AddIcon = function AddIcon(_ref2) {
|
|
|
72
72
|
display: 'flex',
|
|
73
73
|
alignItems: 'center',
|
|
74
74
|
justifyContent: 'center',
|
|
75
|
-
color: 'text.
|
|
75
|
+
color: 'text.auxiliary',
|
|
76
76
|
cursor: 'grab',
|
|
77
77
|
borderColor: 'divider',
|
|
78
78
|
bgcolor: 'background.paper',
|
|
@@ -10,6 +10,8 @@ export interface FloatingPopoverProps {
|
|
|
10
10
|
offset?: number;
|
|
11
11
|
className?: string;
|
|
12
12
|
style?: React.CSSProperties;
|
|
13
|
+
onMouseEnter?: (event: React.MouseEvent) => void;
|
|
14
|
+
onMouseLeave?: (event: React.MouseEvent) => void;
|
|
13
15
|
}
|
|
14
16
|
export declare const FloatingPopover: React.FC<FloatingPopoverProps>;
|
|
15
17
|
export default FloatingPopover;
|
|
@@ -26,7 +26,9 @@ export var FloatingPopover = function FloatingPopover(_ref) {
|
|
|
26
26
|
_ref$offset = _ref.offset,
|
|
27
27
|
offsetValue = _ref$offset === void 0 ? 8 : _ref$offset,
|
|
28
28
|
className = _ref.className,
|
|
29
|
-
style = _ref.style
|
|
29
|
+
style = _ref.style,
|
|
30
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
31
|
+
onMouseLeave = _ref.onMouseLeave;
|
|
30
32
|
var popoverRef = useRef(null);
|
|
31
33
|
var _useState = useState({
|
|
32
34
|
x: 0,
|
|
@@ -87,6 +89,7 @@ export var FloatingPopover = function FloatingPopover(_ref) {
|
|
|
87
89
|
}, [open, onClose, anchorEl]);
|
|
88
90
|
if (!open) return null;
|
|
89
91
|
return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
"aria-hidden": "true",
|
|
90
93
|
style: {
|
|
91
94
|
position: 'fixed',
|
|
92
95
|
top: 0,
|
|
@@ -99,6 +102,9 @@ export var FloatingPopover = function FloatingPopover(_ref) {
|
|
|
99
102
|
}), /*#__PURE__*/React.createElement(Paper, {
|
|
100
103
|
ref: popoverRef,
|
|
101
104
|
className: className,
|
|
105
|
+
onMouseEnter: onMouseEnter,
|
|
106
|
+
onMouseLeave: onMouseLeave,
|
|
107
|
+
"aria-hidden": false,
|
|
102
108
|
style: _objectSpread({
|
|
103
109
|
position: strategy,
|
|
104
110
|
left: position.x,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export interface HoverPopoverProps {
|
|
3
|
+
/** 被包裹的触发元素 */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** Popover 内部展示的内容 */
|
|
6
|
+
actions: ReactNode;
|
|
7
|
+
/** hover 延迟时间(毫秒),默认 500ms */
|
|
8
|
+
hoverDelay?: number;
|
|
9
|
+
/** 关闭延迟时间(毫秒),默认 300ms */
|
|
10
|
+
closeDelay?: number;
|
|
11
|
+
/** Popover 位置,默认 'top' */
|
|
12
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
13
|
+
/** Popover 与触发元素的距离(像素),默认 4 */
|
|
14
|
+
offset?: number;
|
|
15
|
+
/** 是否禁用 hover 效果 */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** 自定义类名 */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** 样式对象 */
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* HoverPopover 组件
|
|
24
|
+
*
|
|
25
|
+
* 当鼠标悬停在 children 上超过指定时间后,显示 popover
|
|
26
|
+
* 支持鼠标移到 popover 上时保持打开状态
|
|
27
|
+
*/
|
|
28
|
+
export declare const HoverPopover: React.FC<HoverPopoverProps>;
|
|
29
|
+
export default HoverPopover;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { FloatingPopover } from "./..";
|
|
8
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
9
|
+
/**
|
|
10
|
+
* HoverPopover 组件
|
|
11
|
+
*
|
|
12
|
+
* 当鼠标悬停在 children 上超过指定时间后,显示 popover
|
|
13
|
+
* 支持鼠标移到 popover 上时保持打开状态
|
|
14
|
+
*/
|
|
15
|
+
export var HoverPopover = function HoverPopover(_ref) {
|
|
16
|
+
var children = _ref.children,
|
|
17
|
+
actions = _ref.actions,
|
|
18
|
+
_ref$hoverDelay = _ref.hoverDelay,
|
|
19
|
+
hoverDelay = _ref$hoverDelay === void 0 ? 500 : _ref$hoverDelay,
|
|
20
|
+
_ref$closeDelay = _ref.closeDelay,
|
|
21
|
+
closeDelay = _ref$closeDelay === void 0 ? 300 : _ref$closeDelay,
|
|
22
|
+
_ref$placement = _ref.placement,
|
|
23
|
+
placement = _ref$placement === void 0 ? 'top' : _ref$placement,
|
|
24
|
+
_ref$offset = _ref.offset,
|
|
25
|
+
offset = _ref$offset === void 0 ? 4 : _ref$offset,
|
|
26
|
+
_ref$disabled = _ref.disabled,
|
|
27
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
28
|
+
className = _ref.className,
|
|
29
|
+
style = _ref.style;
|
|
30
|
+
var _useState = useState(null),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
anchorEl = _useState2[0],
|
|
33
|
+
setAnchorEl = _useState2[1];
|
|
34
|
+
var hoverTimerRef = useRef(null);
|
|
35
|
+
var closeTimerRef = useRef(null);
|
|
36
|
+
var childRef = useRef(null);
|
|
37
|
+
|
|
38
|
+
// 清理定时器
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
return function () {
|
|
41
|
+
if (hoverTimerRef.current) {
|
|
42
|
+
clearTimeout(hoverTimerRef.current);
|
|
43
|
+
}
|
|
44
|
+
if (closeTimerRef.current) {
|
|
45
|
+
clearTimeout(closeTimerRef.current);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
var handleMouseEnter = function handleMouseEnter(event) {
|
|
50
|
+
if (disabled) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 清除关闭定时器
|
|
55
|
+
if (closeTimerRef.current) {
|
|
56
|
+
clearTimeout(closeTimerRef.current);
|
|
57
|
+
closeTimerRef.current = null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 清除之前的 hover 定时器
|
|
61
|
+
if (hoverTimerRef.current) {
|
|
62
|
+
clearTimeout(hoverTimerRef.current);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 保存 currentTarget 引用,因为 React 事件对象会被重用
|
|
66
|
+
var target = event.currentTarget;
|
|
67
|
+
var timer = setTimeout(function () {
|
|
68
|
+
setAnchorEl(target);
|
|
69
|
+
hoverTimerRef.current = null;
|
|
70
|
+
}, hoverDelay);
|
|
71
|
+
hoverTimerRef.current = timer;
|
|
72
|
+
};
|
|
73
|
+
var handleMouseLeave = function handleMouseLeave() {
|
|
74
|
+
if (disabled) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 清除 hover 定时器
|
|
79
|
+
if (hoverTimerRef.current) {
|
|
80
|
+
clearTimeout(hoverTimerRef.current);
|
|
81
|
+
hoverTimerRef.current = null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 清除之前的关闭定时器
|
|
85
|
+
if (closeTimerRef.current) {
|
|
86
|
+
clearTimeout(closeTimerRef.current);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 延迟关闭 popover
|
|
90
|
+
var timer = setTimeout(function () {
|
|
91
|
+
setAnchorEl(null);
|
|
92
|
+
closeTimerRef.current = null;
|
|
93
|
+
}, closeDelay);
|
|
94
|
+
closeTimerRef.current = timer;
|
|
95
|
+
};
|
|
96
|
+
var handlePopoverMouseEnter = function handlePopoverMouseEnter(event) {
|
|
97
|
+
event.stopPropagation();
|
|
98
|
+
|
|
99
|
+
// 鼠标进入 popover,取消关闭
|
|
100
|
+
if (hoverTimerRef.current) {
|
|
101
|
+
clearTimeout(hoverTimerRef.current);
|
|
102
|
+
hoverTimerRef.current = null;
|
|
103
|
+
}
|
|
104
|
+
if (closeTimerRef.current) {
|
|
105
|
+
clearTimeout(closeTimerRef.current);
|
|
106
|
+
closeTimerRef.current = null;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var handlePopoverMouseLeave = function handlePopoverMouseLeave(event) {
|
|
110
|
+
event.stopPropagation();
|
|
111
|
+
|
|
112
|
+
// 鼠标离开 popover,延迟关闭
|
|
113
|
+
handleMouseLeave();
|
|
114
|
+
};
|
|
115
|
+
var handleForceClose = function handleForceClose() {
|
|
116
|
+
// 强制关闭,清除所有定时器
|
|
117
|
+
if (hoverTimerRef.current) {
|
|
118
|
+
clearTimeout(hoverTimerRef.current);
|
|
119
|
+
hoverTimerRef.current = null;
|
|
120
|
+
}
|
|
121
|
+
if (closeTimerRef.current) {
|
|
122
|
+
clearTimeout(closeTimerRef.current);
|
|
123
|
+
closeTimerRef.current = null;
|
|
124
|
+
}
|
|
125
|
+
setAnchorEl(null);
|
|
126
|
+
};
|
|
127
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
ref: childRef,
|
|
129
|
+
onMouseEnter: handleMouseEnter,
|
|
130
|
+
onMouseLeave: handleMouseLeave,
|
|
131
|
+
className: className,
|
|
132
|
+
style: style
|
|
133
|
+
}, children), /*#__PURE__*/React.createElement(FloatingPopover, {
|
|
134
|
+
open: Boolean(anchorEl),
|
|
135
|
+
anchorEl: anchorEl,
|
|
136
|
+
onClose: handleForceClose,
|
|
137
|
+
placement: placement,
|
|
138
|
+
offset: offset,
|
|
139
|
+
onMouseEnter: handlePopoverMouseEnter,
|
|
140
|
+
onMouseLeave: handlePopoverMouseLeave
|
|
141
|
+
}, actions));
|
|
142
|
+
};
|
|
143
|
+
export default HoverPopover;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { SvgIcon } from "@mui/material";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export var ChromeIcon = function ChromeIcon(props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement(SvgIcon, _extends({
|
|
6
|
+
viewBox: "0 0 1024 1024",
|
|
7
|
+
version: "1.1",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
d: "M511.902596 511.902881m-511.902596 0a511.902596 511.902596 0 1 0 1023.805193 0 511.902596 511.902596 0 1 0-1023.805193 0Z",
|
|
11
|
+
fill: "#FFFFFF",
|
|
12
|
+
"p-id": "18082"
|
|
13
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
14
|
+
d: "M123.624477 178.313022c237.94939-276.910866 679.209428-222.279483 844.098942 101.299836H571.340176c-71.381973 0-117.510085-1.621025-167.477467 24.656642-58.698164 30.913229-102.9493 88.217881-118.448573 155.476194L123.624477 178.341461v-0.056878z",
|
|
15
|
+
fill: "#EA4335",
|
|
16
|
+
"p-id": "18083"
|
|
17
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
18
|
+
d: "M341.609666 511.902881a170.349808 170.349808 0 0 0 170.122296 170.179174A170.349808 170.349808 0 0 0 681.854258 511.902881a170.349808 170.349808 0 0 0-170.122296-170.207614A170.349808 170.349808 0 0 0 341.609666 511.902881z",
|
|
19
|
+
fill: "#4285F4",
|
|
20
|
+
"p-id": "18084"
|
|
21
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
22
|
+
d: "M577.767397 734.694266c-95.526712 28.353716-207.235234-3.128294-268.464473-108.779301A152048.010865 152048.010865 0 0 1 83.041977 232.432502c-196.513719 301.169361-27.130838 711.658365 329.608394 781.703704l165.088587-279.44194h0.056878z",
|
|
23
|
+
fill: "#34A853",
|
|
24
|
+
"p-id": "18085"
|
|
25
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
26
|
+
d: "M669.73923 341.666828a233.086316 233.086316 0 0 1 42.999818 286.580137c-40.5825 69.960021-170.122296 288.627747-232.915681 394.506268 367.574503 22.63747 635.61239-337.571323 514.518987-681.114844H669.73923v0.028439z",
|
|
27
|
+
fill: "#FBBC05",
|
|
28
|
+
"p-id": "18086"
|
|
29
|
+
}));
|
|
30
|
+
};
|
|
31
|
+
ChromeIcon.displayName = 'icon-chrome';
|