@ctzhian/tiptap 1.0.0 → 1.1.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 +1 -1
- package/dist/EditorDiff/demo.js +1 -1
- package/dist/EditorToolbar/index.js +19 -3
- package/dist/component/CustomBubbleMenu/SelectionText.js +1 -1
- package/dist/component/CustomDragHandle/index.js +237 -191
- package/dist/component/Icons/index.d.ts +1 -0
- package/dist/component/Icons/index.js +1 -0
- package/dist/component/Icons/information-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/information-2-line-icon.js +13 -0
- package/dist/component/Menu/NestedList.d.ts +14 -0
- package/dist/component/Menu/NestedList.js +149 -0
- package/dist/component/Menu/index.js +12 -117
- package/dist/component/Toolbar/EditorCode.js +1 -1
- package/dist/component/Toolbar/EditorMore/NotificationDialog.js +2 -1
- package/dist/component/index.d.ts +2 -0
- package/dist/component/index.js +3 -1
- package/dist/contants/enums.d.ts +1 -0
- package/dist/contants/enums.js +10 -3
- package/dist/contants/shortcut-key.js +1 -1
- package/dist/contants/slash-commands.d.ts +2 -1
- package/dist/contants/slash-commands.js +98 -42
- package/dist/extension/component/Alert/index.d.ts +7 -9
- package/dist/extension/component/Alert/index.js +186 -109
- package/dist/extension/component/SlashCommandsList/index.js +235 -100
- package/dist/extension/node/Alert.d.ts +19 -8
- package/dist/extension/node/Alert.js +210 -131
- package/dist/extension/suggestion/slash.d.ts +2 -1
- package/dist/extension/suggestion/slash.js +3 -1
- package/dist/index.css +14 -26
- package/dist/type/index.d.ts +11 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { AttachmentLineIcon, CodeBoxLineIcon, CodeLineIcon, DoubleQuotesLIcon, FunctionsIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, H6Icon, ImageLineIcon, LinkIcon, ListCheck2Icon, ListOrdered2Icon, ListUnorderedIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, Table2Icon, TextWrapIcon } from "../component/Icons";
|
|
2
|
+
import { AttachmentLineIcon, CodeBoxLineIcon, CodeLineIcon, DoubleQuotesLIcon, FunctionsIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, H6Icon, ImageLineIcon, Information2LineIcon, LinkIcon, ListCheck2Icon, ListOrdered2Icon, ListUnorderedIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, Table2Icon, TextWrapIcon } from "../component/Icons";
|
|
3
3
|
export var slashCommands = [{
|
|
4
|
-
title: '
|
|
4
|
+
title: '一级标题',
|
|
5
5
|
icon: /*#__PURE__*/React.createElement(H1Icon, {
|
|
6
6
|
sx: {
|
|
7
7
|
fontSize: '1rem'
|
|
@@ -15,7 +15,7 @@ export var slashCommands = [{
|
|
|
15
15
|
}).run();
|
|
16
16
|
}
|
|
17
17
|
}, {
|
|
18
|
-
title: '
|
|
18
|
+
title: '二级标题',
|
|
19
19
|
icon: /*#__PURE__*/React.createElement(H2Icon, {
|
|
20
20
|
sx: {
|
|
21
21
|
fontSize: '1rem'
|
|
@@ -29,7 +29,7 @@ export var slashCommands = [{
|
|
|
29
29
|
}).run();
|
|
30
30
|
}
|
|
31
31
|
}, {
|
|
32
|
-
title: '
|
|
32
|
+
title: '三级标题',
|
|
33
33
|
icon: /*#__PURE__*/React.createElement(H3Icon, {
|
|
34
34
|
sx: {
|
|
35
35
|
fontSize: '1rem'
|
|
@@ -43,7 +43,7 @@ export var slashCommands = [{
|
|
|
43
43
|
}).run();
|
|
44
44
|
}
|
|
45
45
|
}, {
|
|
46
|
-
title: '
|
|
46
|
+
title: '四级标题',
|
|
47
47
|
icon: /*#__PURE__*/React.createElement(H4Icon, {
|
|
48
48
|
sx: {
|
|
49
49
|
fontSize: '1rem'
|
|
@@ -57,7 +57,7 @@ export var slashCommands = [{
|
|
|
57
57
|
}).run();
|
|
58
58
|
}
|
|
59
59
|
}, {
|
|
60
|
-
title: '
|
|
60
|
+
title: '五级标题',
|
|
61
61
|
icon: /*#__PURE__*/React.createElement(H5Icon, {
|
|
62
62
|
sx: {
|
|
63
63
|
fontSize: '1rem'
|
|
@@ -71,7 +71,7 @@ export var slashCommands = [{
|
|
|
71
71
|
}).run();
|
|
72
72
|
}
|
|
73
73
|
}, {
|
|
74
|
-
title: '
|
|
74
|
+
title: '六级标题',
|
|
75
75
|
icon: /*#__PURE__*/React.createElement(H6Icon, {
|
|
76
76
|
sx: {
|
|
77
77
|
fontSize: '1rem'
|
|
@@ -145,7 +145,7 @@ export var slashCommands = [{
|
|
|
145
145
|
editor.chain().focus().deleteRange(range).setHorizontalRule().run();
|
|
146
146
|
}
|
|
147
147
|
}, {
|
|
148
|
-
title: '
|
|
148
|
+
title: '引用块',
|
|
149
149
|
icon: /*#__PURE__*/React.createElement(DoubleQuotesLIcon, {
|
|
150
150
|
sx: {
|
|
151
151
|
fontSize: '1rem'
|
|
@@ -157,8 +157,8 @@ export var slashCommands = [{
|
|
|
157
157
|
editor.chain().focus().deleteRange(range).toggleBlockquote().run();
|
|
158
158
|
}
|
|
159
159
|
}, {
|
|
160
|
-
title: '
|
|
161
|
-
icon: /*#__PURE__*/React.createElement(
|
|
160
|
+
title: '行内代码',
|
|
161
|
+
icon: /*#__PURE__*/React.createElement(CodeLineIcon, {
|
|
162
162
|
sx: {
|
|
163
163
|
fontSize: '1rem'
|
|
164
164
|
}
|
|
@@ -166,13 +166,11 @@ export var slashCommands = [{
|
|
|
166
166
|
command: function command(_ref13) {
|
|
167
167
|
var editor = _ref13.editor,
|
|
168
168
|
range = _ref13.range;
|
|
169
|
-
editor.chain().focus().deleteRange(range).
|
|
170
|
-
href: ''
|
|
171
|
-
}).run();
|
|
169
|
+
editor.chain().focus().deleteRange(range).setMark('code').run();
|
|
172
170
|
}
|
|
173
171
|
}, {
|
|
174
|
-
title: '
|
|
175
|
-
icon: /*#__PURE__*/React.createElement(
|
|
172
|
+
title: '代码块',
|
|
173
|
+
icon: /*#__PURE__*/React.createElement(CodeBoxLineIcon, {
|
|
176
174
|
sx: {
|
|
177
175
|
fontSize: '1rem'
|
|
178
176
|
}
|
|
@@ -180,11 +178,11 @@ export var slashCommands = [{
|
|
|
180
178
|
command: function command(_ref14) {
|
|
181
179
|
var editor = _ref14.editor,
|
|
182
180
|
range = _ref14.range;
|
|
183
|
-
editor.chain().focus().deleteRange(range).
|
|
181
|
+
editor.chain().focus().deleteRange(range).toggleCodeBlock().run();
|
|
184
182
|
}
|
|
185
183
|
}, {
|
|
186
|
-
title: '
|
|
187
|
-
icon: /*#__PURE__*/React.createElement(
|
|
184
|
+
title: '链接',
|
|
185
|
+
icon: /*#__PURE__*/React.createElement(LinkIcon, {
|
|
188
186
|
sx: {
|
|
189
187
|
fontSize: '1rem'
|
|
190
188
|
}
|
|
@@ -192,11 +190,13 @@ export var slashCommands = [{
|
|
|
192
190
|
command: function command(_ref15) {
|
|
193
191
|
var editor = _ref15.editor,
|
|
194
192
|
range = _ref15.range;
|
|
195
|
-
editor.chain().focus().deleteRange(range).
|
|
193
|
+
editor.chain().focus().deleteRange(range).setInlineLink({
|
|
194
|
+
href: ''
|
|
195
|
+
}).run();
|
|
196
196
|
}
|
|
197
197
|
}, {
|
|
198
|
-
title: '
|
|
199
|
-
icon: /*#__PURE__*/React.createElement(
|
|
198
|
+
title: '折叠块',
|
|
199
|
+
icon: /*#__PURE__*/React.createElement(MenuFold2FillIcon, {
|
|
200
200
|
sx: {
|
|
201
201
|
fontSize: '1rem'
|
|
202
202
|
}
|
|
@@ -204,11 +204,11 @@ export var slashCommands = [{
|
|
|
204
204
|
command: function command(_ref16) {
|
|
205
205
|
var editor = _ref16.editor,
|
|
206
206
|
range = _ref16.range;
|
|
207
|
-
editor.chain().focus().deleteRange(range).
|
|
207
|
+
editor.chain().focus().deleteRange(range).setDetails().run();
|
|
208
208
|
}
|
|
209
209
|
}, {
|
|
210
|
-
title: '
|
|
211
|
-
icon: /*#__PURE__*/React.createElement(
|
|
210
|
+
title: '表格',
|
|
211
|
+
icon: /*#__PURE__*/React.createElement(Table2Icon, {
|
|
212
212
|
sx: {
|
|
213
213
|
fontSize: '1rem'
|
|
214
214
|
}
|
|
@@ -216,6 +216,62 @@ export var slashCommands = [{
|
|
|
216
216
|
command: function command(_ref17) {
|
|
217
217
|
var editor = _ref17.editor,
|
|
218
218
|
range = _ref17.range;
|
|
219
|
+
editor.chain().focus().deleteRange(range).insertTable({
|
|
220
|
+
rows: 3,
|
|
221
|
+
cols: 4,
|
|
222
|
+
withHeaderRow: true
|
|
223
|
+
}).run();
|
|
224
|
+
}
|
|
225
|
+
}, {
|
|
226
|
+
title: '警告提示',
|
|
227
|
+
icon: /*#__PURE__*/React.createElement(Information2LineIcon, {
|
|
228
|
+
sx: {
|
|
229
|
+
fontSize: '1rem'
|
|
230
|
+
}
|
|
231
|
+
}),
|
|
232
|
+
command: function command(_ref18) {
|
|
233
|
+
var editor = _ref18.editor,
|
|
234
|
+
range = _ref18.range,
|
|
235
|
+
attrs = _ref18.attrs;
|
|
236
|
+
editor.chain().focus().deleteRange(range).toggleAlert({
|
|
237
|
+
type: (attrs === null || attrs === void 0 ? void 0 : attrs.type) || 'icon',
|
|
238
|
+
variant: (attrs === null || attrs === void 0 ? void 0 : attrs.variant) || 'info'
|
|
239
|
+
}).run();
|
|
240
|
+
}
|
|
241
|
+
}, {
|
|
242
|
+
title: '折叠块',
|
|
243
|
+
icon: /*#__PURE__*/React.createElement(MenuFold2FillIcon, {
|
|
244
|
+
sx: {
|
|
245
|
+
fontSize: '1rem'
|
|
246
|
+
}
|
|
247
|
+
}),
|
|
248
|
+
command: function command(_ref19) {
|
|
249
|
+
var editor = _ref19.editor,
|
|
250
|
+
range = _ref19.range;
|
|
251
|
+
editor.chain().focus().deleteRange(range).setDetails().run();
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
title: '代码块',
|
|
255
|
+
icon: /*#__PURE__*/React.createElement(CodeBoxLineIcon, {
|
|
256
|
+
sx: {
|
|
257
|
+
fontSize: '1rem'
|
|
258
|
+
}
|
|
259
|
+
}),
|
|
260
|
+
command: function command(_ref20) {
|
|
261
|
+
var editor = _ref20.editor,
|
|
262
|
+
range = _ref20.range;
|
|
263
|
+
editor.chain().focus().deleteRange(range).toggleCodeBlock().run();
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
title: '行内数学公式',
|
|
267
|
+
icon: /*#__PURE__*/React.createElement(SquareRootIcon, {
|
|
268
|
+
sx: {
|
|
269
|
+
fontSize: '1rem'
|
|
270
|
+
}
|
|
271
|
+
}),
|
|
272
|
+
command: function command(_ref21) {
|
|
273
|
+
var editor = _ref21.editor,
|
|
274
|
+
range = _ref21.range;
|
|
219
275
|
editor.chain().focus().deleteRange(range).setInlineMath({
|
|
220
276
|
latex: ''
|
|
221
277
|
}).run();
|
|
@@ -227,9 +283,9 @@ export var slashCommands = [{
|
|
|
227
283
|
fontSize: '1rem'
|
|
228
284
|
}
|
|
229
285
|
}),
|
|
230
|
-
command: function command(
|
|
231
|
-
var editor =
|
|
232
|
-
range =
|
|
286
|
+
command: function command(_ref22) {
|
|
287
|
+
var editor = _ref22.editor,
|
|
288
|
+
range = _ref22.range;
|
|
233
289
|
editor.chain().focus().deleteRange(range).setBlockMath({
|
|
234
290
|
latex: ''
|
|
235
291
|
}).run();
|
|
@@ -241,9 +297,9 @@ export var slashCommands = [{
|
|
|
241
297
|
fontSize: '1rem'
|
|
242
298
|
}
|
|
243
299
|
}),
|
|
244
|
-
command: function command(
|
|
245
|
-
var editor =
|
|
246
|
-
range =
|
|
300
|
+
command: function command(_ref23) {
|
|
301
|
+
var editor = _ref23.editor,
|
|
302
|
+
range = _ref23.range;
|
|
247
303
|
editor.chain().focus().deleteRange(range).insertTable({
|
|
248
304
|
rows: 3,
|
|
249
305
|
cols: 4,
|
|
@@ -257,9 +313,9 @@ export var slashCommands = [{
|
|
|
257
313
|
fontSize: '1rem'
|
|
258
314
|
}
|
|
259
315
|
}),
|
|
260
|
-
command: function command(
|
|
261
|
-
var editor =
|
|
262
|
-
range =
|
|
316
|
+
command: function command(_ref24) {
|
|
317
|
+
var editor = _ref24.editor,
|
|
318
|
+
range = _ref24.range;
|
|
263
319
|
editor.chain().focus().deleteRange(range).setImage({
|
|
264
320
|
src: '',
|
|
265
321
|
width: 760
|
|
@@ -272,9 +328,9 @@ export var slashCommands = [{
|
|
|
272
328
|
fontSize: '1rem'
|
|
273
329
|
}
|
|
274
330
|
}),
|
|
275
|
-
command: function command(
|
|
276
|
-
var editor =
|
|
277
|
-
range =
|
|
331
|
+
command: function command(_ref25) {
|
|
332
|
+
var editor = _ref25.editor,
|
|
333
|
+
range = _ref25.range;
|
|
278
334
|
editor.chain().focus().deleteRange(range).setVideo({
|
|
279
335
|
src: '',
|
|
280
336
|
width: 760
|
|
@@ -287,9 +343,9 @@ export var slashCommands = [{
|
|
|
287
343
|
fontSize: '1rem'
|
|
288
344
|
}
|
|
289
345
|
}),
|
|
290
|
-
command: function command(
|
|
291
|
-
var editor =
|
|
292
|
-
range =
|
|
346
|
+
command: function command(_ref26) {
|
|
347
|
+
var editor = _ref26.editor,
|
|
348
|
+
range = _ref26.range;
|
|
293
349
|
editor.chain().focus().deleteRange(range).setAudio({
|
|
294
350
|
src: ''
|
|
295
351
|
}).run();
|
|
@@ -301,9 +357,9 @@ export var slashCommands = [{
|
|
|
301
357
|
fontSize: '1rem'
|
|
302
358
|
}
|
|
303
359
|
}),
|
|
304
|
-
command: function command(
|
|
305
|
-
var editor =
|
|
306
|
-
range =
|
|
360
|
+
command: function command(_ref27) {
|
|
361
|
+
var editor = _ref27.editor,
|
|
362
|
+
range = _ref27.range;
|
|
307
363
|
editor.chain().focus().deleteRange(range).setInlineAttachment({
|
|
308
364
|
url: '',
|
|
309
365
|
title: '',
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import { NodeViewProps } from '@tiptap/react';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
interface
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
editor: any;
|
|
7
|
-
onUpload?: (file: File) => Promise<string>;
|
|
8
|
-
onError?: (error: string) => void;
|
|
3
|
+
export interface AlertAttributes {
|
|
4
|
+
id?: string;
|
|
5
|
+
variant?: 'info' | 'warning' | 'error' | 'success';
|
|
6
|
+
type?: 'text' | 'icon';
|
|
9
7
|
}
|
|
10
|
-
declare const
|
|
11
|
-
export default
|
|
8
|
+
declare const AlertView: React.FC<NodeViewProps>;
|
|
9
|
+
export default AlertView;
|
|
@@ -1,125 +1,202 @@
|
|
|
1
|
-
function
|
|
2
|
-
function
|
|
3
|
-
function
|
|
4
|
-
function
|
|
5
|
-
function
|
|
6
|
-
function
|
|
7
|
-
import {
|
|
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 "../../../component";
|
|
8
|
+
import { CheckboxCircleFillIcon, CloseCircleFillIcon, ErrorWarningFillIcon, Information2FillIcon, ScrollToBottomLineIcon, TextIcon } from "../../../component/Icons";
|
|
9
|
+
import { ToolbarItem } from "../../../component/Toolbar";
|
|
10
|
+
import { Box, Divider, Stack } from '@mui/material';
|
|
8
11
|
import { NodeViewContent, NodeViewWrapper } from '@tiptap/react';
|
|
9
|
-
import React from 'react';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
13
|
+
var VARIANT_DATA = {
|
|
14
|
+
info: {
|
|
15
|
+
icon: /*#__PURE__*/React.createElement(Information2FillIcon, {
|
|
16
|
+
sx: {
|
|
17
|
+
fontSize: '1.25rem'
|
|
18
|
+
}
|
|
19
|
+
}),
|
|
20
|
+
color: 'var(--mui-palette-primary-main)'
|
|
21
|
+
},
|
|
22
|
+
warning: {
|
|
23
|
+
icon: /*#__PURE__*/React.createElement(ErrorWarningFillIcon, {
|
|
24
|
+
sx: {
|
|
25
|
+
fontSize: '1.25rem'
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
color: 'var(--mui-palette-warning-main)'
|
|
29
|
+
},
|
|
30
|
+
error: {
|
|
31
|
+
icon: /*#__PURE__*/React.createElement(CloseCircleFillIcon, {
|
|
32
|
+
sx: {
|
|
33
|
+
fontSize: '1.25rem'
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
color: 'var(--mui-palette-error-main)'
|
|
37
|
+
},
|
|
38
|
+
success: {
|
|
39
|
+
icon: /*#__PURE__*/React.createElement(CheckboxCircleFillIcon, {
|
|
40
|
+
sx: {
|
|
41
|
+
fontSize: '1.25rem'
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
color: 'var(--mui-palette-success-main)'
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var AlertView = function AlertView(_ref) {
|
|
48
|
+
var editor = _ref.editor,
|
|
49
|
+
node = _ref.node,
|
|
13
50
|
updateAttributes = _ref.updateAttributes,
|
|
14
|
-
selected = _ref.selected
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
color: theme.palette.success.main,
|
|
31
|
-
backgroundColor: "".concat(theme.palette.success.main, "10"),
|
|
32
|
-
// 10% 透明度
|
|
33
|
-
icon: CheckboxCircleFillIcon
|
|
34
|
-
};
|
|
35
|
-
case 'warning':
|
|
36
|
-
return {
|
|
37
|
-
color: theme.palette.warning.main,
|
|
38
|
-
backgroundColor: "".concat(theme.palette.warning.main, "10"),
|
|
39
|
-
icon: ErrorWarningFillIcon
|
|
40
|
-
};
|
|
41
|
-
case 'error':
|
|
42
|
-
return {
|
|
43
|
-
color: theme.palette.error.main,
|
|
44
|
-
backgroundColor: "".concat(theme.palette.error.main, "10"),
|
|
45
|
-
icon: CloseCircleFillIcon
|
|
46
|
-
};
|
|
47
|
-
case 'info':
|
|
48
|
-
default:
|
|
49
|
-
return {
|
|
50
|
-
color: theme.palette.text.secondary,
|
|
51
|
-
backgroundColor: "".concat(theme.palette.text.secondary, "10"),
|
|
52
|
-
icon: Information2FillIcon
|
|
53
|
-
};
|
|
54
|
-
}
|
|
51
|
+
selected = _ref.selected;
|
|
52
|
+
var attrs = node.attrs;
|
|
53
|
+
var containerRef = useRef(null);
|
|
54
|
+
var _useState = useState(null),
|
|
55
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
56
|
+
anchorEl = _useState2[0],
|
|
57
|
+
setAnchorEl = _useState2[1];
|
|
58
|
+
var showIcon = attrs.type !== 'text';
|
|
59
|
+
var variantData = useMemo(function () {
|
|
60
|
+
return VARIANT_DATA[attrs.variant || 'info'];
|
|
61
|
+
}, [attrs.variant]);
|
|
62
|
+
var handleShowOperationPopover = function handleShowOperationPopover(event) {
|
|
63
|
+
return setAnchorEl(event.currentTarget);
|
|
64
|
+
};
|
|
65
|
+
var handleCloseOperationPopover = function handleCloseOperationPopover() {
|
|
66
|
+
return setAnchorEl(null);
|
|
55
67
|
};
|
|
56
|
-
var config = getAlertConfig(type);
|
|
57
|
-
var IconComponent = config.icon;
|
|
58
68
|
return /*#__PURE__*/React.createElement(NodeViewWrapper, {
|
|
59
|
-
|
|
69
|
+
ref: containerRef,
|
|
70
|
+
className: "alert-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
|
|
71
|
+
"data-drag-handle": true,
|
|
72
|
+
as: 'div',
|
|
60
73
|
style: {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
border: '1px solid',
|
|
75
|
+
borderColor: variantData.color,
|
|
76
|
+
color: variantData.color,
|
|
77
|
+
borderRadius: '10px',
|
|
78
|
+
padding: '12px 16px',
|
|
79
|
+
lineHeight: 1.625,
|
|
66
80
|
display: 'flex',
|
|
67
81
|
alignItems: 'flex-start',
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, selected && {
|
|
74
|
-
outline: "2px solid ".concat(theme.palette.primary.main),
|
|
75
|
-
outlineOffset: '2px'
|
|
76
|
-
})
|
|
77
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
82
|
+
gap: '16px',
|
|
83
|
+
background: "color-mix(in srgb, ".concat(variantData.color, " 10%, transparent)")
|
|
84
|
+
},
|
|
85
|
+
onClick: handleShowOperationPopover
|
|
86
|
+
}, showIcon && /*#__PURE__*/React.createElement(Box, {
|
|
78
87
|
sx: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
marginRight: '12px',
|
|
82
|
-
marginTop: '2px',
|
|
83
|
-
flexShrink: 0
|
|
84
|
-
}
|
|
85
|
-
}, /*#__PURE__*/React.createElement(IconComponent, {
|
|
86
|
-
style: {
|
|
87
|
-
fontSize: '20px',
|
|
88
|
-
color: config.color
|
|
88
|
+
pt: '2px',
|
|
89
|
+
lineHeight: 1
|
|
89
90
|
}
|
|
90
|
-
})
|
|
91
|
+
}, variantData.icon), /*#__PURE__*/React.createElement(Box, {
|
|
91
92
|
sx: {
|
|
92
|
-
flex: 1
|
|
93
|
-
minWidth: 0
|
|
93
|
+
flex: 1
|
|
94
94
|
}
|
|
95
|
-
},
|
|
96
|
-
|
|
95
|
+
}, /*#__PURE__*/React.createElement(NodeViewContent, {
|
|
96
|
+
as: 'div'
|
|
97
|
+
})), editor.isEditable && /*#__PURE__*/React.createElement(FloatingPopover, {
|
|
98
|
+
open: Boolean(anchorEl),
|
|
99
|
+
anchorEl: anchorEl,
|
|
100
|
+
onClose: handleCloseOperationPopover,
|
|
101
|
+
placement: "top"
|
|
102
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
103
|
+
direction: 'row',
|
|
104
|
+
alignItems: 'center',
|
|
97
105
|
sx: {
|
|
98
|
-
|
|
99
|
-
fontWeight: 600,
|
|
100
|
-
marginBottom: '4px',
|
|
101
|
-
fontSize: '14px',
|
|
102
|
-
lineHeight: '20px'
|
|
106
|
+
p: 0.5
|
|
103
107
|
}
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
108
|
+
}, /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
109
|
+
icon: /*#__PURE__*/React.createElement(Information2FillIcon, {
|
|
110
|
+
sx: {
|
|
111
|
+
fontSize: '1rem',
|
|
112
|
+
color: 'primary.main'
|
|
113
|
+
}
|
|
114
|
+
}),
|
|
115
|
+
tip: "\u4FE1\u606F",
|
|
116
|
+
onClick: function onClick() {
|
|
117
|
+
return updateAttributes({
|
|
118
|
+
variant: 'info'
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
className: attrs.variant === 'info' ? 'tool-active' : ''
|
|
122
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
123
|
+
icon: /*#__PURE__*/React.createElement(ErrorWarningFillIcon, {
|
|
124
|
+
sx: {
|
|
125
|
+
fontSize: '1rem',
|
|
126
|
+
color: 'warning.main'
|
|
121
127
|
}
|
|
128
|
+
}),
|
|
129
|
+
tip: "\u8B66\u544A",
|
|
130
|
+
onClick: function onClick() {
|
|
131
|
+
return updateAttributes({
|
|
132
|
+
variant: 'warning'
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
className: attrs.variant === 'warning' ? 'tool-active' : ''
|
|
136
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
137
|
+
icon: /*#__PURE__*/React.createElement(CloseCircleFillIcon, {
|
|
138
|
+
sx: {
|
|
139
|
+
fontSize: '1rem',
|
|
140
|
+
color: 'error.main'
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
tip: "\u9519\u8BEF",
|
|
144
|
+
onClick: function onClick() {
|
|
145
|
+
return updateAttributes({
|
|
146
|
+
variant: 'error'
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
className: attrs.variant === 'error' ? 'tool-active' : ''
|
|
150
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
151
|
+
icon: /*#__PURE__*/React.createElement(CheckboxCircleFillIcon, {
|
|
152
|
+
sx: {
|
|
153
|
+
fontSize: '1rem',
|
|
154
|
+
color: 'success.main'
|
|
155
|
+
}
|
|
156
|
+
}),
|
|
157
|
+
tip: "\u6210\u529F",
|
|
158
|
+
onClick: function onClick() {
|
|
159
|
+
return updateAttributes({
|
|
160
|
+
variant: 'success'
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
className: attrs.variant === 'success' ? 'tool-active' : ''
|
|
164
|
+
}), /*#__PURE__*/React.createElement(Divider, {
|
|
165
|
+
orientation: "vertical",
|
|
166
|
+
flexItem: true,
|
|
167
|
+
sx: {
|
|
168
|
+
height: '1rem',
|
|
169
|
+
mx: 0.5,
|
|
170
|
+
alignSelf: 'center',
|
|
171
|
+
borderColor: 'divider'
|
|
122
172
|
}
|
|
123
|
-
}, /*#__PURE__*/React.createElement(
|
|
173
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
174
|
+
icon: /*#__PURE__*/React.createElement(TextIcon, {
|
|
175
|
+
sx: {
|
|
176
|
+
fontSize: '1rem'
|
|
177
|
+
}
|
|
178
|
+
}),
|
|
179
|
+
tip: "\u7EAF\u6587\u5B57",
|
|
180
|
+
onClick: function onClick() {
|
|
181
|
+
return updateAttributes({
|
|
182
|
+
type: 'text'
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
className: attrs.type === 'text' ? 'tool-active' : ''
|
|
186
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
187
|
+
icon: /*#__PURE__*/React.createElement(ScrollToBottomLineIcon, {
|
|
188
|
+
sx: {
|
|
189
|
+
transform: 'rotate(90deg)',
|
|
190
|
+
fontSize: '1rem'
|
|
191
|
+
}
|
|
192
|
+
}),
|
|
193
|
+
tip: "\u56FE\u6807\u6587\u5B57",
|
|
194
|
+
onClick: function onClick() {
|
|
195
|
+
return updateAttributes({
|
|
196
|
+
type: 'icon'
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
className: attrs.type === 'icon' ? 'tool-active' : ''
|
|
200
|
+
}))));
|
|
124
201
|
};
|
|
125
|
-
export default
|
|
202
|
+
export default AlertView;
|