@ctzhian/tiptap 1.12.21 → 1.12.23

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.
@@ -1,7 +1,7 @@
1
1
  import { getShortcutKeyText } from "../../../util";
2
2
  import { Typography } from '@mui/material';
3
3
  import React from 'react';
4
- import { AddCircleFillIcon, ArrowDownSLineIcon, AttachmentLineIcon, CheckboxCircleFillIcon, CloseCircleFillIcon, CodeBoxLineIcon, CodeLineIcon, CodeSSlashLineIcon, DoubleQuotesLIcon, ErrorWarningFillIcon, Folder2LineIcon, FormulaIcon, FunctionsIcon, ImageLineIcon, Information2FillIcon, Information2LineIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, Table2Icon, UserSmileFillIcon, WindowFillIcon } from "../../Icons";
4
+ import { AddCircleFillIcon, ArrowDownSLineIcon, AttachmentLineIcon, CheckboxCircleFillIcon, CloseCircleFillIcon, CodeBoxLineIcon, CodeLineIcon, CodeSSlashLineIcon, DoubleQuotesLIcon, EmotionLineIcon, ErrorWarningFillIcon, FormulaIcon, FunctionsIcon, ImageLineIcon, Information2FillIcon, Information2LineIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, Table2Icon, UserSmileFillIcon, WindowFillIcon } from "../../Icons";
5
5
  import Menu from "../../Menu";
6
6
  import ToolbarItem from "../Item";
7
7
  import TableSizePicker from "../TableSizePicker";
@@ -9,6 +9,7 @@ var EditorInsert = function EditorInsert(_ref) {
9
9
  var editor = _ref.editor;
10
10
  return /*#__PURE__*/React.createElement(Menu, {
11
11
  width: 224,
12
+ maxHeight: 'calc(100vh - 312px)',
12
13
  context: /*#__PURE__*/React.createElement(ToolbarItem, {
13
14
  tip: '插入',
14
15
  text: '插入',
@@ -36,12 +37,30 @@ var EditorInsert = function EditorInsert(_ref) {
36
37
  customLabel: /*#__PURE__*/React.createElement(Typography, {
37
38
  sx: {
38
39
  px: 1,
39
- pt: 2,
40
+ pt: 1,
40
41
  fontSize: '12px',
41
42
  color: 'text.disabled'
42
43
  }
43
44
  }, "\u901A\u7528"),
44
45
  key: 'current-node'
46
+ }, {
47
+ label: '表情',
48
+ key: 'emotion',
49
+ icon: /*#__PURE__*/React.createElement(EmotionLineIcon, {
50
+ sx: {
51
+ fontSize: '1rem'
52
+ }
53
+ }),
54
+ extra: /*#__PURE__*/React.createElement(Typography, {
55
+ sx: {
56
+ fontSize: '12px',
57
+ color: 'text.disabled'
58
+ }
59
+ }, ":"),
60
+ onClick: function onClick() {
61
+ var pos = editor.state.selection.from;
62
+ editor.chain().insertContentAt(pos, ' : ').focus(pos + 2).run();
63
+ }
45
64
  }, {
46
65
  label: '图片',
47
66
  key: 'image',
@@ -62,6 +81,70 @@ var EditorInsert = function EditorInsert(_ref) {
62
81
  width: 760
63
82
  });
64
83
  }
84
+ }, {
85
+ label: '视频',
86
+ key: 'video',
87
+ extra: /*#__PURE__*/React.createElement(Typography, {
88
+ sx: {
89
+ fontSize: '12px',
90
+ color: 'text.disabled'
91
+ }
92
+ }, getShortcutKeyText(['ctrl', '3'], '+')),
93
+ icon: /*#__PURE__*/React.createElement(MovieLineIcon, {
94
+ sx: {
95
+ fontSize: '1rem'
96
+ }
97
+ }),
98
+ onClick: function onClick() {
99
+ return editor.commands.setVideo({
100
+ src: '',
101
+ width: 760,
102
+ controls: true,
103
+ autoplay: false
104
+ });
105
+ }
106
+ }, {
107
+ label: '音频',
108
+ key: 'audio',
109
+ extra: /*#__PURE__*/React.createElement(Typography, {
110
+ sx: {
111
+ fontSize: '12px',
112
+ color: 'text.disabled'
113
+ }
114
+ }, getShortcutKeyText(['ctrl', '4'], '+')),
115
+ icon: /*#__PURE__*/React.createElement(Music2LineIcon, {
116
+ sx: {
117
+ fontSize: '1rem'
118
+ }
119
+ }),
120
+ onClick: function onClick() {
121
+ return editor.commands.setAudio({
122
+ src: '',
123
+ controls: true,
124
+ autoplay: false
125
+ });
126
+ }
127
+ }, {
128
+ label: '附件',
129
+ key: 'attachment',
130
+ extra: /*#__PURE__*/React.createElement(Typography, {
131
+ sx: {
132
+ fontSize: '12px',
133
+ color: 'text.disabled'
134
+ }
135
+ }, getShortcutKeyText(['ctrl', '5'], '+')),
136
+ icon: /*#__PURE__*/React.createElement(AttachmentLineIcon, {
137
+ sx: {
138
+ fontSize: '1rem'
139
+ }
140
+ }),
141
+ onClick: function onClick() {
142
+ return editor.commands.setInlineAttachment({
143
+ url: '',
144
+ title: '',
145
+ size: '0'
146
+ });
147
+ }
65
148
  }, {
66
149
  label: '表格',
67
150
  key: 'table',
@@ -88,88 +171,15 @@ var EditorInsert = function EditorInsert(_ref) {
88
171
  }
89
172
  })
90
173
  }]
91
- }, {
92
- label: '文件',
93
- key: 'file',
94
- icon: /*#__PURE__*/React.createElement(Folder2LineIcon, {
95
- sx: {
96
- fontSize: '1rem'
97
- }
98
- }),
99
- children: [{
100
- label: '附件',
101
- key: 'attachment',
102
- extra: /*#__PURE__*/React.createElement(Typography, {
103
- sx: {
104
- fontSize: '12px',
105
- color: 'text.disabled'
106
- }
107
- }, getShortcutKeyText(['ctrl', '5'], '+')),
108
- icon: /*#__PURE__*/React.createElement(AttachmentLineIcon, {
109
- sx: {
110
- fontSize: '1rem'
111
- }
112
- }),
113
- onClick: function onClick() {
114
- return editor.commands.setInlineAttachment({
115
- url: '',
116
- title: '',
117
- size: '0'
118
- });
119
- }
120
- }, {
121
- label: '音频',
122
- key: 'audio',
123
- extra: /*#__PURE__*/React.createElement(Typography, {
124
- sx: {
125
- fontSize: '12px',
126
- color: 'text.disabled'
127
- }
128
- }, getShortcutKeyText(['ctrl', '4'], '+')),
129
- icon: /*#__PURE__*/React.createElement(Music2LineIcon, {
130
- sx: {
131
- fontSize: '1rem'
132
- }
133
- }),
134
- onClick: function onClick() {
135
- return editor.commands.setAudio({
136
- src: '',
137
- controls: true,
138
- autoplay: false
139
- });
140
- }
141
- }, {
142
- label: '视频',
143
- key: 'video',
144
- extra: /*#__PURE__*/React.createElement(Typography, {
145
- sx: {
146
- fontSize: '12px',
147
- color: 'text.disabled'
148
- }
149
- }, getShortcutKeyText(['ctrl', '3'], '+')),
150
- icon: /*#__PURE__*/React.createElement(MovieLineIcon, {
151
- sx: {
152
- fontSize: '1rem'
153
- }
154
- }),
155
- onClick: function onClick() {
156
- return editor.commands.setVideo({
157
- src: '',
158
- width: 760,
159
- controls: true,
160
- autoplay: false
161
- });
162
- }
163
- }]
164
174
  }, {
165
175
  customLabel: /*#__PURE__*/React.createElement(Typography, {
166
176
  sx: {
167
177
  px: 1,
168
- pt: 2,
178
+ pt: 1,
169
179
  fontSize: '12px',
170
180
  color: 'text.disabled'
171
181
  }
172
- }, "\u6837\u5F0F\u5E03\u5C40"),
182
+ }, "\u6A21\u5757"),
173
183
  key: 'style'
174
184
  }, {
175
185
  label: '分割线',
@@ -304,11 +314,11 @@ var EditorInsert = function EditorInsert(_ref) {
304
314
  customLabel: /*#__PURE__*/React.createElement(Typography, {
305
315
  sx: {
306
316
  px: 1,
307
- pt: 2,
317
+ pt: 1,
308
318
  fontSize: '12px',
309
319
  color: 'text.disabled'
310
320
  }
311
- }, "\u7A0B\u5E8F\u5458\u4E13\u7528"),
321
+ }, "\u4E13\u4E1A"),
312
322
  key: 'programmer'
313
323
  }, {
314
324
  label: '代码',
@@ -404,7 +414,7 @@ var EditorInsert = function EditorInsert(_ref) {
404
414
  customLabel: /*#__PURE__*/React.createElement(Typography, {
405
415
  sx: {
406
416
  px: 1,
407
- pt: 2,
417
+ pt: 1,
408
418
  fontSize: '12px',
409
419
  color: 'text.disabled'
410
420
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
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, WindowFillIcon } from "../component/Icons";
2
+ import { AttachmentLineIcon, CodeBoxLineIcon, CodeLineIcon, DoubleQuotesLIcon, EmotionLineIcon, FunctionsIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, H6Icon, ImageLineIcon, Information2LineIcon, LinkIcon, ListCheck2Icon, ListOrdered2Icon, ListUnorderedIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, Table2Icon, TextWrapIcon, WindowFillIcon } from "../component/Icons";
3
3
  export var slashCommands = [{
4
4
  title: '标题1',
5
5
  shortcutKey: ['ctrl', 'alt', '1'],
@@ -142,8 +142,8 @@ export var slashCommands = [{
142
142
  editor.chain().focus().deleteRange(range).insertContent('<br />').run();
143
143
  }
144
144
  }, {
145
- title: '分割线',
146
- icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
145
+ title: '表情',
146
+ icon: /*#__PURE__*/React.createElement(EmotionLineIcon, {
147
147
  sx: {
148
148
  fontSize: '1rem'
149
149
  }
@@ -151,6 +151,18 @@ export var slashCommands = [{
151
151
  command: function command(_ref11) {
152
152
  var editor = _ref11.editor,
153
153
  range = _ref11.range;
154
+ editor.chain().deleteRange(range).insertContentAt(range.from, ' : ').focus(range.from + 2).run();
155
+ }
156
+ }, {
157
+ title: '分割线',
158
+ icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
159
+ sx: {
160
+ fontSize: '1rem'
161
+ }
162
+ }),
163
+ command: function command(_ref12) {
164
+ var editor = _ref12.editor,
165
+ range = _ref12.range;
154
166
  editor.chain().focus().deleteRange(range).setHorizontalRule().run();
155
167
  }
156
168
  }, {
@@ -161,9 +173,9 @@ export var slashCommands = [{
161
173
  fontSize: '1rem'
162
174
  }
163
175
  }),
164
- command: function command(_ref12) {
165
- var editor = _ref12.editor,
166
- range = _ref12.range;
176
+ command: function command(_ref13) {
177
+ var editor = _ref13.editor,
178
+ range = _ref13.range;
167
179
  editor.chain().focus().deleteRange(range).toggleBlockquote().run();
168
180
  }
169
181
  }, {
@@ -174,9 +186,9 @@ export var slashCommands = [{
174
186
  fontSize: '1rem'
175
187
  }
176
188
  }),
177
- command: function command(_ref13) {
178
- var editor = _ref13.editor,
179
- range = _ref13.range;
189
+ command: function command(_ref14) {
190
+ var editor = _ref14.editor,
191
+ range = _ref14.range;
180
192
  editor.chain().focus().deleteRange(range).setMark('code').run();
181
193
  }
182
194
  }, {
@@ -187,9 +199,9 @@ export var slashCommands = [{
187
199
  fontSize: '1rem'
188
200
  }
189
201
  }),
190
- command: function command(_ref14) {
191
- var editor = _ref14.editor,
192
- range = _ref14.range;
202
+ command: function command(_ref15) {
203
+ var editor = _ref15.editor,
204
+ range = _ref15.range;
193
205
  editor.chain().focus().deleteRange(range).toggleCodeBlock().run();
194
206
  }
195
207
  }, {
@@ -200,9 +212,9 @@ export var slashCommands = [{
200
212
  fontSize: '1rem'
201
213
  }
202
214
  }),
203
- command: function command(_ref15) {
204
- var editor = _ref15.editor,
205
- range = _ref15.range;
215
+ command: function command(_ref16) {
216
+ var editor = _ref16.editor,
217
+ range = _ref16.range;
206
218
  editor.chain().focus().deleteRange(range).setInlineLink({
207
219
  href: ''
208
220
  }).run();
@@ -215,9 +227,9 @@ export var slashCommands = [{
215
227
  fontSize: '1rem'
216
228
  }
217
229
  }),
218
- command: function command(_ref16) {
219
- var editor = _ref16.editor,
220
- range = _ref16.range;
230
+ command: function command(_ref17) {
231
+ var editor = _ref17.editor,
232
+ range = _ref17.range;
221
233
  editor.chain().focus().deleteRange(range).setDetails().run();
222
234
  }
223
235
  }, {
@@ -227,9 +239,9 @@ export var slashCommands = [{
227
239
  fontSize: '1rem'
228
240
  }
229
241
  }),
230
- command: function command(_ref17) {
231
- var editor = _ref17.editor,
232
- range = _ref17.range;
242
+ command: function command(_ref18) {
243
+ var editor = _ref18.editor,
244
+ range = _ref18.range;
233
245
  editor.chain().focus().deleteRange(range).setIframe({
234
246
  src: '',
235
247
  width: 760,
@@ -244,10 +256,10 @@ export var slashCommands = [{
244
256
  fontSize: '1rem'
245
257
  }
246
258
  }),
247
- command: function command(_ref18) {
248
- var editor = _ref18.editor,
249
- range = _ref18.range,
250
- attrs = _ref18.attrs;
259
+ command: function command(_ref19) {
260
+ var editor = _ref19.editor,
261
+ range = _ref19.range,
262
+ attrs = _ref19.attrs;
251
263
  editor.chain().focus().deleteRange(range).insertTable({
252
264
  rows: attrs.rows || 3,
253
265
  cols: attrs.cols || 4,
@@ -261,10 +273,10 @@ export var slashCommands = [{
261
273
  fontSize: '1rem'
262
274
  }
263
275
  }),
264
- command: function command(_ref19) {
265
- var editor = _ref19.editor,
266
- range = _ref19.range,
267
- attrs = _ref19.attrs;
276
+ command: function command(_ref20) {
277
+ var editor = _ref20.editor,
278
+ range = _ref20.range,
279
+ attrs = _ref20.attrs;
268
280
  editor.chain().focus().deleteRange(range).toggleAlert({
269
281
  type: (attrs === null || attrs === void 0 ? void 0 : attrs.type) || 'icon',
270
282
  variant: (attrs === null || attrs === void 0 ? void 0 : attrs.variant) || 'info'
@@ -277,9 +289,9 @@ export var slashCommands = [{
277
289
  fontSize: '1rem'
278
290
  }
279
291
  }),
280
- command: function command(_ref20) {
281
- var editor = _ref20.editor,
282
- range = _ref20.range;
292
+ command: function command(_ref21) {
293
+ var editor = _ref21.editor,
294
+ range = _ref21.range;
283
295
  editor.chain().focus().deleteRange(range).setDetails().run();
284
296
  }
285
297
  }, {
@@ -289,9 +301,9 @@ export var slashCommands = [{
289
301
  fontSize: '1rem'
290
302
  }
291
303
  }),
292
- command: function command(_ref21) {
293
- var editor = _ref21.editor,
294
- range = _ref21.range;
304
+ command: function command(_ref22) {
305
+ var editor = _ref22.editor,
306
+ range = _ref22.range;
295
307
  editor.chain().focus().deleteRange(range).toggleCodeBlock().run();
296
308
  }
297
309
  }, {
@@ -301,9 +313,9 @@ export var slashCommands = [{
301
313
  fontSize: '1rem'
302
314
  }
303
315
  }),
304
- command: function command(_ref22) {
305
- var editor = _ref22.editor,
306
- range = _ref22.range;
316
+ command: function command(_ref23) {
317
+ var editor = _ref23.editor,
318
+ range = _ref23.range;
307
319
  editor.chain().focus().deleteRange(range).setInlineMath({
308
320
  latex: ''
309
321
  }).run();
@@ -315,9 +327,9 @@ export var slashCommands = [{
315
327
  fontSize: '1rem'
316
328
  }
317
329
  }),
318
- command: function command(_ref23) {
319
- var editor = _ref23.editor,
320
- range = _ref23.range;
330
+ command: function command(_ref24) {
331
+ var editor = _ref24.editor,
332
+ range = _ref24.range;
321
333
  editor.chain().focus().deleteRange(range).setBlockMath({
322
334
  latex: ''
323
335
  }).run();
@@ -329,9 +341,9 @@ export var slashCommands = [{
329
341
  fontSize: '1rem'
330
342
  }
331
343
  }),
332
- command: function command(_ref24) {
333
- var editor = _ref24.editor,
334
- range = _ref24.range;
344
+ command: function command(_ref25) {
345
+ var editor = _ref25.editor,
346
+ range = _ref25.range;
335
347
  editor.chain().focus().deleteRange(range).setImage({
336
348
  src: '',
337
349
  width: 760
@@ -344,9 +356,9 @@ export var slashCommands = [{
344
356
  fontSize: '1rem'
345
357
  }
346
358
  }),
347
- command: function command(_ref25) {
348
- var editor = _ref25.editor,
349
- range = _ref25.range;
359
+ command: function command(_ref26) {
360
+ var editor = _ref26.editor,
361
+ range = _ref26.range;
350
362
  editor.chain().focus().deleteRange(range).setVideo({
351
363
  src: '',
352
364
  width: 760
@@ -359,9 +371,9 @@ export var slashCommands = [{
359
371
  fontSize: '1rem'
360
372
  }
361
373
  }),
362
- command: function command(_ref26) {
363
- var editor = _ref26.editor,
364
- range = _ref26.range;
374
+ command: function command(_ref27) {
375
+ var editor = _ref27.editor,
376
+ range = _ref27.range;
365
377
  editor.chain().focus().deleteRange(range).setAudio({
366
378
  src: ''
367
379
  }).run();
@@ -373,9 +385,9 @@ export var slashCommands = [{
373
385
  fontSize: '1rem'
374
386
  }
375
387
  }),
376
- command: function command(_ref27) {
377
- var editor = _ref27.editor,
378
- range = _ref27.range;
388
+ command: function command(_ref28) {
389
+ var editor = _ref28.editor,
390
+ range = _ref28.range;
379
391
  editor.chain().focus().deleteRange(range).setInlineAttachment({
380
392
  url: '',
381
393
  title: '',
@@ -1,5 +1,5 @@
1
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 { FileIcon } from "../../../component/Icons";
2
+ import { Download2LineIcon } from "../../../component/Icons";
3
3
  import { Box, Stack } from "@mui/material";
4
4
  import React from "react";
5
5
  /**
@@ -75,15 +75,11 @@ export var AttachmentContent = function AttachmentContent(_ref) {
75
75
  }, !editable && {
76
76
  'data-title': attrs.title,
77
77
  'data-type': type
78
- }), /*#__PURE__*/React.createElement(FileIcon, {
78
+ }), /*#__PURE__*/React.createElement(Download2LineIcon, {
79
79
  sx: {
80
80
  fontSize: '2rem',
81
- cursor: 'grab',
82
81
  color: attrs.url === 'error' ? 'error.main' : 'primary.main',
83
- alignSelf: 'center',
84
- ':active': {
85
- cursor: 'grabbing'
86
- }
82
+ alignSelf: 'center'
87
83
  }
88
84
  }), /*#__PURE__*/React.createElement(Stack, {
89
85
  sx: {
@@ -117,7 +113,7 @@ export var AttachmentContent = function AttachmentContent(_ref) {
117
113
  alignItems: 'center',
118
114
  gap: 0.5
119
115
  }
120
- }, /*#__PURE__*/React.createElement(FileIcon, {
116
+ }, /*#__PURE__*/React.createElement(Download2LineIcon, {
121
117
  sx: {
122
118
  fontSize: '0.875rem',
123
119
  cursor: 'grab',
@@ -127,7 +123,7 @@ export var AttachmentContent = function AttachmentContent(_ref) {
127
123
  cursor: 'grabbing'
128
124
  }
129
125
  }
130
- }), attrs.title) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FileIcon, {
126
+ }), attrs.title) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Download2LineIcon, {
131
127
  sx: {
132
128
  fontSize: '0.875rem',
133
129
  cursor: 'grab',
@@ -1,3 +1,4 @@
1
+ import { Editor } from '@tiptap/core';
1
2
  import { EmojiItem } from '@tiptap/extension-emoji';
2
3
  import React from 'react';
3
4
  export type EmojiListProps = {
@@ -5,6 +6,8 @@ export type EmojiListProps = {
5
6
  command: (props: {
6
7
  name: string;
7
8
  }) => void;
9
+ query?: string;
10
+ editor?: Editor;
8
11
  };
9
12
  export type EmojiListRef = {
10
13
  onKeyDown: (props: {