@ctzhian/tiptap 2.1.11 → 2.1.13
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 +2 -2
- package/dist/asset/css/index.css +3 -1
- package/dist/component/Icons/bilibili-line-icon.d.ts +6 -0
- package/dist/component/Icons/bilibili-line-icon.js +13 -0
- package/dist/component/Icons/index.d.ts +1 -0
- package/dist/component/Icons/index.js +1 -0
- package/dist/component/Toolbar/EditorInsert/index.js +20 -3
- package/dist/contants/enums.d.ts +5 -0
- package/dist/contants/enums.js +24 -0
- package/dist/contants/slash-commands.js +117 -119
- package/dist/extension/component/Iframe/Insert.d.ts +4 -2
- package/dist/extension/component/Iframe/Insert.js +12 -14
- package/dist/extension/component/Iframe/Readonly.d.ts +2 -1
- package/dist/extension/component/Iframe/Readonly.js +14 -5
- package/dist/extension/component/Iframe/index.js +389 -171
- package/dist/extension/component/SlashCommandsList/index.js +1 -1
- package/dist/extension/component/TableCellHandleMenu/index.js +13 -1
- package/dist/extension/component/TableExtendButton/index.js +2 -2
- package/dist/extension/component/TableHandle/TableHandleMenu.js +13 -1
- package/dist/extension/component/TableSelectionOverlay/index.js +1 -1
- package/dist/extension/node/CodeBlockLowlight.js +0 -1
- package/dist/extension/node/FileHandler.d.ts +1 -1
- package/dist/extension/node/Iframe.d.ts +3 -1
- package/dist/extension/node/Iframe.js +51 -8
- package/dist/extension/node/Table.js +18 -22
- package/dist/extension/node/TableHandler/plugin.js +1 -1
- package/dist/index.css +1 -1
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.js +8 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { AttachmentLineIcon, CodeBoxLineIcon, CodeLineIcon, DoubleQuotesLIcon, EmotionLineIcon, FlowChartIcon, FunctionsIcon, H1Icon, H2Icon, H3Icon,
|
|
2
|
+
import { AttachmentLineIcon, BilibiliLineIcon, CodeBoxLineIcon, CodeLineIcon, DoubleQuotesLIcon, EmotionLineIcon, FlowChartIcon, FunctionsIcon, H1Icon, H2Icon, H3Icon, ImageLineIcon, Information2LineIcon, LinkIcon, ListCheck2Icon, ListOrdered2Icon, ListUnorderedIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, Table2Icon, WindowFillIcon } from "../component/Icons";
|
|
3
3
|
export var slashCommands = [{
|
|
4
4
|
title: '标题1',
|
|
5
5
|
shortcutKey: ['ctrl', 'alt', '1'],
|
|
@@ -45,10 +45,35 @@ export var slashCommands = [{
|
|
|
45
45
|
level: 3
|
|
46
46
|
}).run();
|
|
47
47
|
}
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
},
|
|
49
|
+
// {
|
|
50
|
+
// title: '标题4',
|
|
51
|
+
// shortcutKey: ['ctrl', 'alt', '4'],
|
|
52
|
+
// icon: <H4Icon sx={{ fontSize: '1rem' }} />,
|
|
53
|
+
// command: ({ editor, range }: { editor: Editor; range: { from: number; to: number } }) => {
|
|
54
|
+
// editor.chain().focus().deleteRange(range).setNode('heading', { level: 4 }).run()
|
|
55
|
+
// }
|
|
56
|
+
// },
|
|
57
|
+
// {
|
|
58
|
+
// title: '标题5',
|
|
59
|
+
// shortcutKey: ['ctrl', 'alt', '5'],
|
|
60
|
+
// icon: <H5Icon sx={{ fontSize: '1rem' }} />,
|
|
61
|
+
// command: ({ editor, range }: { editor: Editor; range: { from: number; to: number } }) => {
|
|
62
|
+
// editor.chain().focus().deleteRange(range).setNode('heading', { level: 5 }).run()
|
|
63
|
+
// }
|
|
64
|
+
// },
|
|
65
|
+
// {
|
|
66
|
+
// title: '标题6',
|
|
67
|
+
// shortcutKey: ['ctrl', 'alt', '6'],
|
|
68
|
+
// icon: <H6Icon sx={{ fontSize: '1rem' }} />,
|
|
69
|
+
// command: ({ editor, range }: { editor: Editor; range: { from: number; to: number } }) => {
|
|
70
|
+
// editor.chain().focus().deleteRange(range).setNode('heading', { level: 6 }).run()
|
|
71
|
+
// }
|
|
72
|
+
// },
|
|
73
|
+
{
|
|
74
|
+
title: '有序列表',
|
|
75
|
+
shortcutKey: ['ctrl', 'shift', '7'],
|
|
76
|
+
icon: /*#__PURE__*/React.createElement(ListOrdered2Icon, {
|
|
52
77
|
sx: {
|
|
53
78
|
fontSize: '1rem'
|
|
54
79
|
}
|
|
@@ -56,14 +81,12 @@ export var slashCommands = [{
|
|
|
56
81
|
command: function command(_ref4) {
|
|
57
82
|
var editor = _ref4.editor,
|
|
58
83
|
range = _ref4.range;
|
|
59
|
-
editor.chain().focus().deleteRange(range).
|
|
60
|
-
level: 4
|
|
61
|
-
}).run();
|
|
84
|
+
editor.chain().focus().deleteRange(range).toggleOrderedList().run();
|
|
62
85
|
}
|
|
63
86
|
}, {
|
|
64
|
-
title: '
|
|
65
|
-
shortcutKey: ['ctrl', '
|
|
66
|
-
icon: /*#__PURE__*/React.createElement(
|
|
87
|
+
title: '无序列表',
|
|
88
|
+
shortcutKey: ['ctrl', 'shift', '8'],
|
|
89
|
+
icon: /*#__PURE__*/React.createElement(ListUnorderedIcon, {
|
|
67
90
|
sx: {
|
|
68
91
|
fontSize: '1rem'
|
|
69
92
|
}
|
|
@@ -71,14 +94,12 @@ export var slashCommands = [{
|
|
|
71
94
|
command: function command(_ref5) {
|
|
72
95
|
var editor = _ref5.editor,
|
|
73
96
|
range = _ref5.range;
|
|
74
|
-
editor.chain().focus().deleteRange(range).
|
|
75
|
-
level: 5
|
|
76
|
-
}).run();
|
|
97
|
+
editor.chain().focus().deleteRange(range).toggleBulletList().run();
|
|
77
98
|
}
|
|
78
99
|
}, {
|
|
79
|
-
title: '
|
|
80
|
-
shortcutKey: ['ctrl', '
|
|
81
|
-
icon: /*#__PURE__*/React.createElement(
|
|
100
|
+
title: '任务列表',
|
|
101
|
+
shortcutKey: ['ctrl', 'shift', '9'],
|
|
102
|
+
icon: /*#__PURE__*/React.createElement(ListCheck2Icon, {
|
|
82
103
|
sx: {
|
|
83
104
|
fontSize: '1rem'
|
|
84
105
|
}
|
|
@@ -86,14 +107,12 @@ export var slashCommands = [{
|
|
|
86
107
|
command: function command(_ref6) {
|
|
87
108
|
var editor = _ref6.editor,
|
|
88
109
|
range = _ref6.range;
|
|
89
|
-
editor.chain().focus().deleteRange(range).
|
|
90
|
-
level: 6
|
|
91
|
-
}).run();
|
|
110
|
+
editor.chain().focus().deleteRange(range).toggleTaskList().run();
|
|
92
111
|
}
|
|
93
112
|
}, {
|
|
94
|
-
title: '
|
|
95
|
-
shortcutKey: ['ctrl', '
|
|
96
|
-
icon: /*#__PURE__*/React.createElement(
|
|
113
|
+
title: '链接',
|
|
114
|
+
shortcutKey: ['ctrl', '1'],
|
|
115
|
+
icon: /*#__PURE__*/React.createElement(LinkIcon, {
|
|
97
116
|
sx: {
|
|
98
117
|
fontSize: '1rem'
|
|
99
118
|
}
|
|
@@ -101,12 +120,14 @@ export var slashCommands = [{
|
|
|
101
120
|
command: function command(_ref7) {
|
|
102
121
|
var editor = _ref7.editor,
|
|
103
122
|
range = _ref7.range;
|
|
104
|
-
editor.chain().focus().deleteRange(range).
|
|
123
|
+
editor.chain().focus().deleteRange(range).setInlineLink({
|
|
124
|
+
href: ''
|
|
125
|
+
}).run();
|
|
105
126
|
}
|
|
106
127
|
}, {
|
|
107
|
-
title: '
|
|
108
|
-
shortcutKey: ['ctrl', '
|
|
109
|
-
icon: /*#__PURE__*/React.createElement(
|
|
128
|
+
title: '行内代码',
|
|
129
|
+
shortcutKey: ['ctrl', 'E'],
|
|
130
|
+
icon: /*#__PURE__*/React.createElement(CodeLineIcon, {
|
|
110
131
|
sx: {
|
|
111
132
|
fontSize: '1rem'
|
|
112
133
|
}
|
|
@@ -114,12 +135,12 @@ export var slashCommands = [{
|
|
|
114
135
|
command: function command(_ref8) {
|
|
115
136
|
var editor = _ref8.editor,
|
|
116
137
|
range = _ref8.range;
|
|
117
|
-
editor.chain().focus().deleteRange(range).
|
|
138
|
+
editor.chain().focus().deleteRange(range).setMark('code').run();
|
|
118
139
|
}
|
|
119
140
|
}, {
|
|
120
|
-
title: '
|
|
121
|
-
shortcutKey: ['ctrl', '
|
|
122
|
-
icon: /*#__PURE__*/React.createElement(
|
|
141
|
+
title: '代码块',
|
|
142
|
+
shortcutKey: ['ctrl', 'alt', 'C'],
|
|
143
|
+
icon: /*#__PURE__*/React.createElement(CodeBoxLineIcon, {
|
|
123
144
|
sx: {
|
|
124
145
|
fontSize: '1rem'
|
|
125
146
|
}
|
|
@@ -127,11 +148,12 @@ export var slashCommands = [{
|
|
|
127
148
|
command: function command(_ref9) {
|
|
128
149
|
var editor = _ref9.editor,
|
|
129
150
|
range = _ref9.range;
|
|
130
|
-
editor.chain().focus().deleteRange(range).
|
|
151
|
+
editor.chain().focus().deleteRange(range).toggleCodeBlock().run();
|
|
131
152
|
}
|
|
132
153
|
}, {
|
|
133
|
-
title: '
|
|
134
|
-
|
|
154
|
+
title: '折叠面板',
|
|
155
|
+
shortcutKey: ['ctrl', '8'],
|
|
156
|
+
icon: /*#__PURE__*/React.createElement(MenuFold2FillIcon, {
|
|
135
157
|
sx: {
|
|
136
158
|
fontSize: '1rem'
|
|
137
159
|
}
|
|
@@ -139,11 +161,12 @@ export var slashCommands = [{
|
|
|
139
161
|
command: function command(_ref10) {
|
|
140
162
|
var editor = _ref10.editor,
|
|
141
163
|
range = _ref10.range;
|
|
142
|
-
editor.chain().
|
|
164
|
+
editor.chain().focus().deleteRange(range).setDetails().run();
|
|
143
165
|
}
|
|
144
166
|
}, {
|
|
145
|
-
title: '
|
|
146
|
-
|
|
167
|
+
title: '引用',
|
|
168
|
+
shortcutKey: ['ctrl', 'shift', 'B'],
|
|
169
|
+
icon: /*#__PURE__*/React.createElement(DoubleQuotesLIcon, {
|
|
147
170
|
sx: {
|
|
148
171
|
fontSize: '1rem'
|
|
149
172
|
}
|
|
@@ -151,12 +174,11 @@ export var slashCommands = [{
|
|
|
151
174
|
command: function command(_ref11) {
|
|
152
175
|
var editor = _ref11.editor,
|
|
153
176
|
range = _ref11.range;
|
|
154
|
-
editor.chain().focus().deleteRange(range).
|
|
177
|
+
editor.chain().focus().deleteRange(range).toggleBlockquote().run();
|
|
155
178
|
}
|
|
156
179
|
}, {
|
|
157
|
-
title: '
|
|
158
|
-
|
|
159
|
-
icon: /*#__PURE__*/React.createElement(DoubleQuotesLIcon, {
|
|
180
|
+
title: '流程图',
|
|
181
|
+
icon: /*#__PURE__*/React.createElement(FlowChartIcon, {
|
|
160
182
|
sx: {
|
|
161
183
|
fontSize: '1rem'
|
|
162
184
|
}
|
|
@@ -164,12 +186,14 @@ export var slashCommands = [{
|
|
|
164
186
|
command: function command(_ref12) {
|
|
165
187
|
var editor = _ref12.editor,
|
|
166
188
|
range = _ref12.range;
|
|
167
|
-
editor.chain().focus().deleteRange(range).
|
|
189
|
+
editor.chain().focus().deleteRange(range).setFlow({
|
|
190
|
+
code: '',
|
|
191
|
+
width: '100%'
|
|
192
|
+
}).run();
|
|
168
193
|
}
|
|
169
194
|
}, {
|
|
170
|
-
title: '
|
|
171
|
-
|
|
172
|
-
icon: /*#__PURE__*/React.createElement(CodeLineIcon, {
|
|
195
|
+
title: '表情',
|
|
196
|
+
icon: /*#__PURE__*/React.createElement(EmotionLineIcon, {
|
|
173
197
|
sx: {
|
|
174
198
|
fontSize: '1rem'
|
|
175
199
|
}
|
|
@@ -177,12 +201,11 @@ export var slashCommands = [{
|
|
|
177
201
|
command: function command(_ref13) {
|
|
178
202
|
var editor = _ref13.editor,
|
|
179
203
|
range = _ref13.range;
|
|
180
|
-
editor.chain().
|
|
204
|
+
editor.chain().deleteRange(range).insertContentAt(range.from, ' : ').focus(range.from + 2).run();
|
|
181
205
|
}
|
|
182
206
|
}, {
|
|
183
|
-
title: '
|
|
184
|
-
|
|
185
|
-
icon: /*#__PURE__*/React.createElement(CodeBoxLineIcon, {
|
|
207
|
+
title: '分割线',
|
|
208
|
+
icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
|
|
186
209
|
sx: {
|
|
187
210
|
fontSize: '1rem'
|
|
188
211
|
}
|
|
@@ -190,12 +213,11 @@ export var slashCommands = [{
|
|
|
190
213
|
command: function command(_ref14) {
|
|
191
214
|
var editor = _ref14.editor,
|
|
192
215
|
range = _ref14.range;
|
|
193
|
-
editor.chain().focus().deleteRange(range).
|
|
216
|
+
editor.chain().focus().deleteRange(range).setHorizontalRule().run();
|
|
194
217
|
}
|
|
195
218
|
}, {
|
|
196
|
-
title: '
|
|
197
|
-
|
|
198
|
-
icon: /*#__PURE__*/React.createElement(LinkIcon, {
|
|
219
|
+
title: 'Bilibili 视频',
|
|
220
|
+
icon: /*#__PURE__*/React.createElement(BilibiliLineIcon, {
|
|
199
221
|
sx: {
|
|
200
222
|
fontSize: '1rem'
|
|
201
223
|
}
|
|
@@ -203,14 +225,16 @@ export var slashCommands = [{
|
|
|
203
225
|
command: function command(_ref15) {
|
|
204
226
|
var editor = _ref15.editor,
|
|
205
227
|
range = _ref15.range;
|
|
206
|
-
editor.chain().focus().deleteRange(range).
|
|
207
|
-
|
|
228
|
+
editor.chain().focus().deleteRange(range).setIframe({
|
|
229
|
+
src: '',
|
|
230
|
+
width: '100%',
|
|
231
|
+
height: 400,
|
|
232
|
+
type: 'bilibili'
|
|
208
233
|
}).run();
|
|
209
234
|
}
|
|
210
235
|
}, {
|
|
211
|
-
title: '
|
|
212
|
-
|
|
213
|
-
icon: /*#__PURE__*/React.createElement(MenuFold2FillIcon, {
|
|
236
|
+
title: 'Iframe',
|
|
237
|
+
icon: /*#__PURE__*/React.createElement(WindowFillIcon, {
|
|
214
238
|
sx: {
|
|
215
239
|
fontSize: '1rem'
|
|
216
240
|
}
|
|
@@ -218,37 +242,11 @@ export var slashCommands = [{
|
|
|
218
242
|
command: function command(_ref16) {
|
|
219
243
|
var editor = _ref16.editor,
|
|
220
244
|
range = _ref16.range;
|
|
221
|
-
editor.chain().focus().deleteRange(range).setDetails().run();
|
|
222
|
-
}
|
|
223
|
-
}, {
|
|
224
|
-
title: '流程图',
|
|
225
|
-
icon: /*#__PURE__*/React.createElement(FlowChartIcon, {
|
|
226
|
-
sx: {
|
|
227
|
-
fontSize: '1rem'
|
|
228
|
-
}
|
|
229
|
-
}),
|
|
230
|
-
command: function command(_ref17) {
|
|
231
|
-
var editor = _ref17.editor,
|
|
232
|
-
range = _ref17.range;
|
|
233
|
-
editor.chain().focus().deleteRange(range).setFlow({
|
|
234
|
-
code: '',
|
|
235
|
-
width: '100%'
|
|
236
|
-
}).run();
|
|
237
|
-
}
|
|
238
|
-
}, {
|
|
239
|
-
title: 'iframe',
|
|
240
|
-
icon: /*#__PURE__*/React.createElement(WindowFillIcon, {
|
|
241
|
-
sx: {
|
|
242
|
-
fontSize: '1rem'
|
|
243
|
-
}
|
|
244
|
-
}),
|
|
245
|
-
command: function command(_ref18) {
|
|
246
|
-
var editor = _ref18.editor,
|
|
247
|
-
range = _ref18.range;
|
|
248
245
|
editor.chain().focus().deleteRange(range).setIframe({
|
|
249
246
|
src: '',
|
|
250
|
-
width:
|
|
251
|
-
height: 400
|
|
247
|
+
width: '100%',
|
|
248
|
+
height: 400,
|
|
249
|
+
type: 'iframe'
|
|
252
250
|
}).run();
|
|
253
251
|
}
|
|
254
252
|
}, {
|
|
@@ -259,10 +257,10 @@ export var slashCommands = [{
|
|
|
259
257
|
fontSize: '1rem'
|
|
260
258
|
}
|
|
261
259
|
}),
|
|
262
|
-
command: function command(
|
|
263
|
-
var editor =
|
|
264
|
-
range =
|
|
265
|
-
attrs =
|
|
260
|
+
command: function command(_ref17) {
|
|
261
|
+
var editor = _ref17.editor,
|
|
262
|
+
range = _ref17.range,
|
|
263
|
+
attrs = _ref17.attrs;
|
|
266
264
|
editor.chain().focus().deleteRange(range).insertTable({
|
|
267
265
|
rows: attrs.rows || 3,
|
|
268
266
|
cols: attrs.cols || 4,
|
|
@@ -276,10 +274,10 @@ export var slashCommands = [{
|
|
|
276
274
|
fontSize: '1rem'
|
|
277
275
|
}
|
|
278
276
|
}),
|
|
279
|
-
command: function command(
|
|
280
|
-
var editor =
|
|
281
|
-
range =
|
|
282
|
-
attrs =
|
|
277
|
+
command: function command(_ref18) {
|
|
278
|
+
var editor = _ref18.editor,
|
|
279
|
+
range = _ref18.range,
|
|
280
|
+
attrs = _ref18.attrs;
|
|
283
281
|
editor.chain().focus().deleteRange(range).toggleAlert({
|
|
284
282
|
type: (attrs === null || attrs === void 0 ? void 0 : attrs.type) || 'icon',
|
|
285
283
|
variant: (attrs === null || attrs === void 0 ? void 0 : attrs.variant) || 'info'
|
|
@@ -292,9 +290,9 @@ export var slashCommands = [{
|
|
|
292
290
|
fontSize: '1rem'
|
|
293
291
|
}
|
|
294
292
|
}),
|
|
295
|
-
command: function command(
|
|
296
|
-
var editor =
|
|
297
|
-
range =
|
|
293
|
+
command: function command(_ref19) {
|
|
294
|
+
var editor = _ref19.editor,
|
|
295
|
+
range = _ref19.range;
|
|
298
296
|
editor.chain().focus().deleteRange(range).setDetails().run();
|
|
299
297
|
}
|
|
300
298
|
}, {
|
|
@@ -304,9 +302,9 @@ export var slashCommands = [{
|
|
|
304
302
|
fontSize: '1rem'
|
|
305
303
|
}
|
|
306
304
|
}),
|
|
307
|
-
command: function command(
|
|
308
|
-
var editor =
|
|
309
|
-
range =
|
|
305
|
+
command: function command(_ref20) {
|
|
306
|
+
var editor = _ref20.editor,
|
|
307
|
+
range = _ref20.range;
|
|
310
308
|
editor.chain().focus().deleteRange(range).toggleCodeBlock().run();
|
|
311
309
|
}
|
|
312
310
|
}, {
|
|
@@ -316,9 +314,9 @@ export var slashCommands = [{
|
|
|
316
314
|
fontSize: '1rem'
|
|
317
315
|
}
|
|
318
316
|
}),
|
|
319
|
-
command: function command(
|
|
320
|
-
var editor =
|
|
321
|
-
range =
|
|
317
|
+
command: function command(_ref21) {
|
|
318
|
+
var editor = _ref21.editor,
|
|
319
|
+
range = _ref21.range;
|
|
322
320
|
editor.chain().focus().deleteRange(range).setInlineMath({
|
|
323
321
|
latex: ''
|
|
324
322
|
}).run();
|
|
@@ -330,9 +328,9 @@ export var slashCommands = [{
|
|
|
330
328
|
fontSize: '1rem'
|
|
331
329
|
}
|
|
332
330
|
}),
|
|
333
|
-
command: function command(
|
|
334
|
-
var editor =
|
|
335
|
-
range =
|
|
331
|
+
command: function command(_ref22) {
|
|
332
|
+
var editor = _ref22.editor,
|
|
333
|
+
range = _ref22.range;
|
|
336
334
|
editor.chain().focus().deleteRange(range).setBlockMath({
|
|
337
335
|
latex: ''
|
|
338
336
|
}).run();
|
|
@@ -344,9 +342,9 @@ export var slashCommands = [{
|
|
|
344
342
|
fontSize: '1rem'
|
|
345
343
|
}
|
|
346
344
|
}),
|
|
347
|
-
command: function command(
|
|
348
|
-
var editor =
|
|
349
|
-
range =
|
|
345
|
+
command: function command(_ref23) {
|
|
346
|
+
var editor = _ref23.editor,
|
|
347
|
+
range = _ref23.range;
|
|
350
348
|
editor.chain().focus().deleteRange(range).setImage({
|
|
351
349
|
src: '',
|
|
352
350
|
width: 760
|
|
@@ -359,9 +357,9 @@ export var slashCommands = [{
|
|
|
359
357
|
fontSize: '1rem'
|
|
360
358
|
}
|
|
361
359
|
}),
|
|
362
|
-
command: function command(
|
|
363
|
-
var editor =
|
|
364
|
-
range =
|
|
360
|
+
command: function command(_ref24) {
|
|
361
|
+
var editor = _ref24.editor,
|
|
362
|
+
range = _ref24.range;
|
|
365
363
|
editor.chain().focus().deleteRange(range).setVideo({
|
|
366
364
|
src: '',
|
|
367
365
|
width: 760
|
|
@@ -374,9 +372,9 @@ export var slashCommands = [{
|
|
|
374
372
|
fontSize: '1rem'
|
|
375
373
|
}
|
|
376
374
|
}),
|
|
377
|
-
command: function command(
|
|
378
|
-
var editor =
|
|
379
|
-
range =
|
|
375
|
+
command: function command(_ref25) {
|
|
376
|
+
var editor = _ref25.editor,
|
|
377
|
+
range = _ref25.range;
|
|
380
378
|
editor.chain().focus().deleteRange(range).setAudio({
|
|
381
379
|
src: ''
|
|
382
380
|
}).run();
|
|
@@ -388,9 +386,9 @@ export var slashCommands = [{
|
|
|
388
386
|
fontSize: '1rem'
|
|
389
387
|
}
|
|
390
388
|
}),
|
|
391
|
-
command: function command(
|
|
392
|
-
var editor =
|
|
393
|
-
range =
|
|
389
|
+
command: function command(_ref26) {
|
|
390
|
+
var editor = _ref26.editor,
|
|
391
|
+
range = _ref26.range;
|
|
394
392
|
editor.chain().focus().deleteRange(range).setInlineAttachment({
|
|
395
393
|
url: '',
|
|
396
394
|
title: '',
|
|
@@ -2,13 +2,15 @@ import { EditorFnProps } from "../../../type";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
export type IframeAttributes = {
|
|
4
4
|
src: string;
|
|
5
|
-
width: number;
|
|
5
|
+
width: number | string;
|
|
6
6
|
height: number;
|
|
7
|
+
align: 'left' | 'center' | 'right' | null;
|
|
8
|
+
type: 'iframe' | 'bilibili';
|
|
7
9
|
};
|
|
8
10
|
type InsertIframeProps = {
|
|
9
11
|
selected: boolean;
|
|
10
12
|
attrs: IframeAttributes;
|
|
11
13
|
updateAttributes: (attrs: IframeAttributes) => void;
|
|
12
14
|
} & EditorFnProps;
|
|
13
|
-
declare const InsertIframe: ({
|
|
15
|
+
declare const InsertIframe: ({ attrs, updateAttributes, onValidateUrl }: InsertIframeProps) => React.JSX.Element;
|
|
14
16
|
export default InsertIframe;
|
|
@@ -9,13 +9,13 @@ 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/FloatingPopover";
|
|
12
|
-
import {
|
|
12
|
+
import { IframeTypeEnums } from "../../../contants/enums";
|
|
13
|
+
import { extractSrcFromIframe } from "../../../util";
|
|
13
14
|
import { Box, Button, Stack, TextField } from "@mui/material";
|
|
14
15
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
15
16
|
import React, { useState } from "react";
|
|
16
17
|
var InsertIframe = function InsertIframe(_ref) {
|
|
17
|
-
var
|
|
18
|
-
attrs = _ref.attrs,
|
|
18
|
+
var attrs = _ref.attrs,
|
|
19
19
|
updateAttributes = _ref.updateAttributes,
|
|
20
20
|
onValidateUrl = _ref.onValidateUrl;
|
|
21
21
|
var _useState = useState(attrs.src || ''),
|
|
@@ -45,7 +45,7 @@ var InsertIframe = function InsertIframe(_ref) {
|
|
|
45
45
|
return _context.abrupt("return");
|
|
46
46
|
case 2:
|
|
47
47
|
_context.prev = 2;
|
|
48
|
-
validatedUrl = editUrl
|
|
48
|
+
validatedUrl = extractSrcFromIframe(editUrl);
|
|
49
49
|
if (!onValidateUrl) {
|
|
50
50
|
_context.next = 8;
|
|
51
51
|
break;
|
|
@@ -58,7 +58,9 @@ var InsertIframe = function InsertIframe(_ref) {
|
|
|
58
58
|
updateAttributes({
|
|
59
59
|
src: validatedUrl,
|
|
60
60
|
width: attrs.width,
|
|
61
|
-
height: attrs.height
|
|
61
|
+
height: attrs.height,
|
|
62
|
+
align: attrs.align,
|
|
63
|
+
type: attrs.type
|
|
62
64
|
});
|
|
63
65
|
handleClosePopover();
|
|
64
66
|
_context.next = 14;
|
|
@@ -104,20 +106,14 @@ var InsertIframe = function InsertIframe(_ref) {
|
|
|
104
106
|
bgcolor: 'action.selected'
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
|
-
}, /*#__PURE__*/React.createElement(
|
|
108
|
-
sx: {
|
|
109
|
-
fontSize: '1rem',
|
|
110
|
-
position: 'relative',
|
|
111
|
-
flexShrink: 0
|
|
112
|
-
}
|
|
113
|
-
}), /*#__PURE__*/React.createElement(Box, {
|
|
109
|
+
}, IframeTypeEnums[attrs.type].icon, /*#__PURE__*/React.createElement(Box, {
|
|
114
110
|
sx: {
|
|
115
111
|
fontSize: '0.875rem',
|
|
116
112
|
position: 'relative',
|
|
117
113
|
flexGrow: 1,
|
|
118
114
|
textAlign: 'left'
|
|
119
115
|
}
|
|
120
|
-
}, "\u70B9\u51FB\u6B64\u5904\u5D4C\u5165
|
|
116
|
+
}, "\u70B9\u51FB\u6B64\u5904\u5D4C\u5165 ", IframeTypeEnums[attrs.type].label)), /*#__PURE__*/React.createElement(FloatingPopover, {
|
|
121
117
|
open: Boolean(anchorEl),
|
|
122
118
|
anchorEl: anchorEl,
|
|
123
119
|
onClose: handleClosePopover,
|
|
@@ -130,12 +126,14 @@ var InsertIframe = function InsertIframe(_ref) {
|
|
|
130
126
|
}
|
|
131
127
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
132
128
|
fullWidth: true,
|
|
129
|
+
multiline: true,
|
|
130
|
+
rows: 5,
|
|
133
131
|
size: "small",
|
|
134
132
|
value: editUrl,
|
|
135
133
|
onChange: function onChange(e) {
|
|
136
134
|
return setEditUrl(e.target.value);
|
|
137
135
|
},
|
|
138
|
-
placeholder: "\u8F93\u5165\u8981\u5D4C\u5165\u7684 URL"
|
|
136
|
+
placeholder: "\u8F93\u5165/\u7C98\u8D34\u8981\u5D4C\u5165\u7684 URL"
|
|
139
137
|
}), /*#__PURE__*/React.createElement(Stack, {
|
|
140
138
|
direction: 'row',
|
|
141
139
|
gap: 1
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
+
import { Box } from '@mui/material';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
var ReadonlyIframe = function ReadonlyIframe(_ref) {
|
|
3
4
|
var attrs = _ref.attrs;
|
|
4
|
-
return /*#__PURE__*/React.createElement(
|
|
5
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
6
|
+
sx: {
|
|
7
|
+
textAlign: attrs.align || undefined
|
|
8
|
+
}
|
|
9
|
+
}, /*#__PURE__*/React.createElement("iframe", {
|
|
5
10
|
src: attrs.src,
|
|
6
|
-
width: attrs.width,
|
|
11
|
+
width: typeof attrs.width === 'number' ? attrs.width : undefined,
|
|
7
12
|
height: attrs.height,
|
|
8
13
|
style: {
|
|
9
14
|
display: 'block',
|
|
10
|
-
border: 0
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
border: 0,
|
|
16
|
+
width: typeof attrs.width === 'string' && attrs.width.endsWith('%') ? attrs.width : undefined,
|
|
17
|
+
maxWidth: '100%'
|
|
18
|
+
},
|
|
19
|
+
frameBorder: "0",
|
|
20
|
+
allowFullScreen: true
|
|
21
|
+
}));
|
|
13
22
|
};
|
|
14
23
|
export default ReadonlyIframe;
|