@ctzhian/tiptap 2.1.0 → 2.1.2

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.
Files changed (34) hide show
  1. package/dist/Editor/demo.js +19 -1
  2. package/dist/EditorMarkdown/demo.js +7 -8
  3. package/dist/asset/css/index.css +2 -2
  4. package/dist/component/Icons/index.d.ts +5 -0
  5. package/dist/component/Icons/index.js +5 -0
  6. package/dist/component/Icons/skip-down-icon.d.ts +6 -0
  7. package/dist/component/Icons/skip-down-icon.js +13 -0
  8. package/dist/component/Icons/skip-left-icon.d.ts +6 -0
  9. package/dist/component/Icons/skip-left-icon.js +13 -0
  10. package/dist/component/Icons/skip-right-icon.d.ts +6 -0
  11. package/dist/component/Icons/skip-right-icon.js +13 -0
  12. package/dist/component/Icons/skip-up-icon.d.ts +6 -0
  13. package/dist/component/Icons/skip-up-icon.js +13 -0
  14. package/dist/component/Icons/volume-down-line-icon.d.ts +6 -0
  15. package/dist/component/Icons/volume-down-line-icon.js +13 -0
  16. package/dist/extension/component/Attachment/AttachmentContent.d.ts +0 -1
  17. package/dist/extension/component/Attachment/AttachmentContent.js +33 -8
  18. package/dist/extension/component/Attachment/index.js +21 -12
  19. package/dist/extension/component/Audio/AudioPlayer.d.ts +8 -0
  20. package/dist/extension/component/Audio/{Readonly.js → AudioPlayer.js} +129 -175
  21. package/dist/extension/component/Audio/index.js +93 -462
  22. package/dist/extension/component/Image/index.js +25 -9
  23. package/dist/extension/component/Link/LinkContent.js +2 -0
  24. package/dist/extension/component/TableHandle/TableHandleAddButton.d.ts +14 -0
  25. package/dist/extension/component/TableHandle/TableHandleAddButton.js +87 -0
  26. package/dist/extension/component/TableHandle/TableHandleMenu.css +0 -1
  27. package/dist/extension/component/TableHandle/TableHandleMenu.js +6 -5
  28. package/dist/extension/component/TableHandle/index.js +53 -3
  29. package/dist/extension/component/TableSelectionOverlay/index.js +1 -2
  30. package/dist/extension/component/Video/index.js +9 -0
  31. package/dist/extension/node/CodeBlockLowlight.js +3 -2
  32. package/dist/index.css +1 -1
  33. package/package.json +1 -1
  34. package/dist/extension/component/Audio/Readonly.d.ts +0 -8
@@ -11,47 +11,42 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
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
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { FloatingPopover } from "../../../component";
14
- import { DownloadLineIcon, PauseLineIcon, PlayLineIcon, SpeedLineIcon, VolumeMuteLineIcon, VolumeUpLineIcon } from "../../../component/Icons";
15
- import { Box, IconButton, MenuItem, MenuList, Paper, Slider, Stack, Typography } from "@mui/material";
16
- import { NodeViewWrapper } from "@tiptap/react";
14
+ import { PauseLineIcon, PlayLineIcon, SpeedLineIcon, VolumeDownLineIcon, VolumeMuteLineIcon, VolumeUpLineIcon } from "../../../component/Icons";
15
+ import { Box, Divider, IconButton, MenuItem, MenuList, Paper, Slider, Stack, Tooltip, Typography } from "@mui/material";
17
16
  import React, { useEffect, useRef, useState } from "react";
18
17
  import Disk from "../../../asset/images/disk.png";
19
- var ReadonlyAudio = function ReadonlyAudio(_ref) {
18
+ var AudioPlayer = function AudioPlayer(_ref) {
20
19
  var attrs = _ref.attrs,
21
20
  _onError = _ref.onError;
22
21
  var audioRef = useRef(null);
23
22
  var _useState = useState(false),
24
23
  _useState2 = _slicedToArray(_useState, 2),
25
- isHovering = _useState2[0],
26
- setIsHovering = _useState2[1];
24
+ isPlaying = _useState2[0],
25
+ setIsPlaying = _useState2[1];
27
26
  var _useState3 = useState(false),
28
27
  _useState4 = _slicedToArray(_useState3, 2),
29
- isPlaying = _useState4[0],
30
- setIsPlaying = _useState4[1];
31
- var _useState5 = useState(false),
28
+ isMuted = _useState4[0],
29
+ setIsMuted = _useState4[1];
30
+ var _useState5 = useState(0),
32
31
  _useState6 = _slicedToArray(_useState5, 2),
33
- isMuted = _useState6[0],
34
- setIsMuted = _useState6[1];
32
+ currentTime = _useState6[0],
33
+ setCurrentTime = _useState6[1];
35
34
  var _useState7 = useState(0),
36
35
  _useState8 = _slicedToArray(_useState7, 2),
37
- currentTime = _useState8[0],
38
- setCurrentTime = _useState8[1];
39
- var _useState9 = useState(0),
36
+ duration = _useState8[0],
37
+ setDuration = _useState8[1];
38
+ var _useState9 = useState(0.5),
40
39
  _useState10 = _slicedToArray(_useState9, 2),
41
- duration = _useState10[0],
42
- setDuration = _useState10[1];
43
- var _useState11 = useState(0.5),
40
+ volume = _useState10[0],
41
+ setVolume = _useState10[1];
42
+ var _useState11 = useState(1),
44
43
  _useState12 = _slicedToArray(_useState11, 2),
45
- volume = _useState12[0],
46
- setVolume = _useState12[1];
47
- var _useState13 = useState(1),
44
+ playbackRate = _useState12[0],
45
+ setPlaybackRate = _useState12[1];
46
+ var _useState13 = useState(null),
48
47
  _useState14 = _slicedToArray(_useState13, 2),
49
- playbackRate = _useState14[0],
50
- setPlaybackRate = _useState14[1];
51
- var _useState15 = useState(null),
52
- _useState16 = _slicedToArray(_useState15, 2),
53
- anchorElSpeed = _useState16[0],
54
- setAnchorElSpeed = _useState16[1];
48
+ anchorElSpeed = _useState14[0],
49
+ setAnchorElSpeed = _useState14[1];
55
50
  var handleCloseSpeedPopover = function handleCloseSpeedPopover() {
56
51
  return setAnchorElSpeed(null);
57
52
  };
@@ -121,18 +116,6 @@ var ReadonlyAudio = function ReadonlyAudio(_ref) {
121
116
  handleCloseSpeedPopover();
122
117
  };
123
118
 
124
- // 处理下载
125
- var handleDownload = function handleDownload() {
126
- if (attrs.src) {
127
- var link = document.createElement('a');
128
- link.href = attrs.src;
129
- link.download = attrs.src.split('/').pop() || 'audio.mp3';
130
- document.body.appendChild(link);
131
- link.click();
132
- document.body.removeChild(link);
133
- }
134
- };
135
-
136
119
  // 音频事件处理
137
120
  useEffect(function () {
138
121
  var audio = audioRef.current;
@@ -165,39 +148,22 @@ var ReadonlyAudio = function ReadonlyAudio(_ref) {
165
148
  audio.removeEventListener('error', handleError);
166
149
  };
167
150
  }, [attrs.src, _onError]);
168
- return /*#__PURE__*/React.createElement(NodeViewWrapper, {
169
- className: "audio-wrapper",
170
- "data-drag-handle": true
171
- }, /*#__PURE__*/React.createElement("audio", {
172
- ref: audioRef,
173
- src: attrs.src,
174
- style: {
175
- display: 'none'
176
- },
177
- onError: function onError(e) {
178
- _onError === null || _onError === void 0 || _onError(e);
179
- }
180
- }), /*#__PURE__*/React.createElement(Stack, {
151
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Stack, {
181
152
  direction: 'row',
182
153
  alignItems: 'center',
154
+ flexWrap: 'wrap',
155
+ gap: 1.5,
183
156
  sx: {
184
157
  position: 'relative',
185
- '&:hover': {
186
- '.audio-controls': {
187
- opacity: 1
188
- }
189
- }
190
- },
191
- onMouseEnter: function onMouseEnter() {
192
- return setIsHovering(true);
193
- },
194
- onMouseLeave: function onMouseLeave() {
195
- return setIsHovering(false);
158
+ borderRadius: 'var(--mui-shape-borderRadius)',
159
+ p: '0.5rem 1rem',
160
+ bgcolor: 'background.paper3'
196
161
  }
197
162
  }, /*#__PURE__*/React.createElement(Box, {
198
163
  sx: {
199
- height: 100,
200
- minWidth: 100,
164
+ height: 48,
165
+ minWidth: 48,
166
+ objectFit: 'cover',
201
167
  cursor: 'pointer',
202
168
  position: 'relative',
203
169
  flexShrink: 0,
@@ -206,109 +172,106 @@ var ReadonlyAudio = function ReadonlyAudio(_ref) {
206
172
  justifyContent: 'center',
207
173
  borderRadius: 'var(--mui-shape-borderRadius) 0 0 var(--mui-shape-borderRadius)',
208
174
  backgroundSize: 'cover',
209
- backgroundImage: "url(".concat(Disk, ")")
175
+ backgroundImage: "url(".concat(attrs.poster || Disk, ")")
210
176
  },
211
177
  onClick: togglePlay
212
- }, attrs.poster && /*#__PURE__*/React.createElement("img", {
213
- src: attrs.poster,
214
- alt: "\u97F3\u9891\u6D77\u62A5",
215
- style: _objectSpread({
216
- width: 48,
217
- height: 48,
218
- objectFit: 'cover',
219
- borderRadius: '50%'
220
- }, isPlaying && {
221
- animation: 'rotate-icon infinite 20s linear'
222
- })
223
178
  }), /*#__PURE__*/React.createElement(Box, {
224
179
  sx: {
225
- position: 'absolute',
226
- top: 0,
227
- left: 0,
228
- width: '100%',
229
- height: '100%',
230
- display: 'flex',
231
- alignItems: 'center',
232
- justifyContent: 'center',
233
- opacity: isHovering ? 1 : 0,
234
- transition: 'opacity 0.2s',
235
- borderRadius: '50%'
236
- }
237
- }, /*#__PURE__*/React.createElement(Box, {
238
- sx: {
239
- width: 32,
240
- height: 32,
241
- borderRadius: '50%',
242
- display: 'flex',
243
- alignItems: 'center',
244
- justifyContent: 'center'
180
+ flex: 1,
181
+ minWidth: 180
245
182
  }
246
- }, /*#__PURE__*/React.createElement(IconButton, null, isPlaying ? /*#__PURE__*/React.createElement(PauseLineIcon, {
183
+ }, /*#__PURE__*/React.createElement(Stack, {
184
+ direction: "row",
185
+ alignItems: "center",
186
+ justifyContent: 'space-between',
247
187
  sx: {
248
- fontSize: '1.5rem',
249
- color: 'text.primary'
188
+ mb: 0.5
250
189
  }
251
- }) : /*#__PURE__*/React.createElement(PlayLineIcon, {
190
+ }, /*#__PURE__*/React.createElement(Box, {
252
191
  sx: {
253
- fontSize: '1.5rem',
254
- color: 'text.primary'
192
+ fontWeight: '500',
193
+ fontSize: 14
255
194
  }
256
- }))))), /*#__PURE__*/React.createElement(Box, {
195
+ }, attrs.title || '音频'), /*#__PURE__*/React.createElement(Stack, {
196
+ direction: "row",
197
+ alignItems: "center",
198
+ spacing: 1,
257
199
  sx: {
258
- flex: 1,
259
- pr: 2,
260
- pl: 4,
261
- position: 'relative'
200
+ color: 'text.tertiary'
262
201
  }
263
202
  }, /*#__PURE__*/React.createElement(Typography, {
264
- variant: "subtitle1",
203
+ variant: "caption"
204
+ }, formatTime(currentTime)), /*#__PURE__*/React.createElement(Divider, {
205
+ orientation: "vertical",
206
+ flexItem: true,
265
207
  sx: {
266
- fontWeight: 500,
267
- mb: 1
208
+ height: '1rem',
209
+ mx: 0.5,
210
+ alignSelf: 'center',
211
+ borderColor: 'divider'
268
212
  }
269
- }, attrs.title || '音频'), /*#__PURE__*/React.createElement(Stack, {
270
- direction: "row",
271
- alignItems: "center",
272
- spacing: 1
273
- }, /*#__PURE__*/React.createElement(Stack, {
213
+ }), /*#__PURE__*/React.createElement(Typography, {
214
+ variant: "caption"
215
+ }, formatTime(duration)))), /*#__PURE__*/React.createElement(Stack, {
274
216
  direction: "row",
275
217
  alignItems: "center",
276
- spacing: 1,
218
+ spacing: 2
219
+ }, /*#__PURE__*/React.createElement(Box, {
277
220
  sx: {
278
- flex: 1
221
+ cursor: 'pointer',
222
+ color: 'text.disabled',
223
+ px: 1,
224
+ py: 0.5,
225
+ borderRadius: 'var(--mui-shape-borderRadius)',
226
+ backgroundColor: 'action.hover',
227
+ '&:hover': {
228
+ backgroundColor: 'action.selected',
229
+ color: 'text.primary'
230
+ }
279
231
  }
280
- }, /*#__PURE__*/React.createElement(Typography, {
281
- variant: "caption",
232
+ }, isPlaying ? /*#__PURE__*/React.createElement(PauseLineIcon, {
282
233
  sx: {
283
- minWidth: 40
284
- }
285
- }, formatTime(currentTime)), /*#__PURE__*/React.createElement(Slider, {
234
+ fontSize: '1rem'
235
+ },
236
+ onClick: togglePlay
237
+ }) : /*#__PURE__*/React.createElement(PlayLineIcon, {
238
+ sx: {
239
+ fontSize: '1rem'
240
+ },
241
+ onClick: togglePlay
242
+ })), /*#__PURE__*/React.createElement(Slider, {
286
243
  value: currentTime,
287
244
  min: 0,
288
245
  max: duration || 100,
289
246
  onChange: handleProgressChange,
290
247
  size: "small",
291
248
  sx: {
292
- flex: 1
293
- }
294
- }), /*#__PURE__*/React.createElement(Typography, {
295
- variant: "caption",
296
- sx: {
297
- minWidth: 40
249
+ py: '3px',
250
+ flex: 1,
251
+ '& .MuiSlider-track': {
252
+ border: 'none'
253
+ },
254
+ '& .MuiSlider-thumb': {
255
+ width: '10px',
256
+ height: '10px',
257
+ '&::after': {
258
+ width: '12px !important',
259
+ height: '12px !important'
260
+ },
261
+ '&:hover, &.Mui-focusVisible, &.Mui-active': {
262
+ boxShadow: 'none'
263
+ }
264
+ }
298
265
  }
299
- }, formatTime(duration))), /*#__PURE__*/React.createElement(Stack, {
266
+ }))), /*#__PURE__*/React.createElement(Stack, {
300
267
  direction: "row",
301
268
  alignItems: "center",
302
269
  sx: {
303
- flexShrink: 0
304
- }
305
- }, /*#__PURE__*/React.createElement(IconButton, {
306
- size: "small",
307
- onClick: toogleMute,
308
- sx: {
309
- flexShrink: 0
310
- }
311
- }, !isMuted ? /*#__PURE__*/React.createElement(VolumeUpLineIcon, {
270
+ flexShrink: 0,
271
+ color: 'text.disabled'
272
+ },
273
+ gap: 1
274
+ }, volume > 0 ? /*#__PURE__*/React.createElement(VolumeDownLineIcon, {
312
275
  sx: {
313
276
  fontSize: '1rem'
314
277
  }
@@ -316,7 +279,7 @@ var ReadonlyAudio = function ReadonlyAudio(_ref) {
316
279
  sx: {
317
280
  fontSize: '1rem'
318
281
  }
319
- })), /*#__PURE__*/React.createElement(Slider, {
282
+ }), /*#__PURE__*/React.createElement(Slider, {
320
283
  value: volume,
321
284
  min: 0,
322
285
  max: 1,
@@ -327,18 +290,23 @@ var ReadonlyAudio = function ReadonlyAudio(_ref) {
327
290
  disabled: isMuted,
328
291
  sx: function sx(t) {
329
292
  return _objectSpread({
330
- width: 80,
293
+ width: 64,
294
+ py: '3px',
331
295
  color: 'rgba(0,0,0,0.87)',
332
296
  '& .MuiSlider-track': {
333
297
  border: 'none'
334
298
  },
335
299
  '& .MuiSlider-thumb': {
336
- width: 12,
337
- height: 12,
300
+ width: '8px',
301
+ height: '8px',
338
302
  backgroundColor: '#fff',
339
303
  '&::before': {
340
304
  boxShadow: '0 4px 8px rgba(0,0,0,0.4)'
341
305
  },
306
+ '&::after': {
307
+ width: '12px !important',
308
+ height: '12px !important'
309
+ },
342
310
  '&:hover, &.Mui-focusVisible, &.Mui-active': {
343
311
  boxShadow: 'none'
344
312
  }
@@ -347,49 +315,35 @@ var ReadonlyAudio = function ReadonlyAudio(_ref) {
347
315
  color: '#fff'
348
316
  }));
349
317
  }
350
- })), /*#__PURE__*/React.createElement(Stack, {
351
- direction: 'row',
352
- alignItems: 'center',
318
+ }), /*#__PURE__*/React.createElement(VolumeUpLineIcon, {
353
319
  sx: {
354
- flexShrink: 0,
355
- pr: 1
356
- },
320
+ fontSize: '1rem'
321
+ }
322
+ })), /*#__PURE__*/React.createElement(Tooltip, {
323
+ arrow: true,
324
+ title: "\u500D\u901F\u64AD\u653E"
325
+ }, /*#__PURE__*/React.createElement(Box, {
357
326
  onClick: handleShowSpeedPopover
358
327
  }, /*#__PURE__*/React.createElement(IconButton, {
359
328
  size: "small",
360
329
  sx: {
361
- color: anchorElSpeed ? 'primary.main' : ''
330
+ flexShrink: 0,
331
+ color: playbackRate !== 1 ? 'primary.main' : 'text.tertiary'
362
332
  }
363
333
  }, /*#__PURE__*/React.createElement(SpeedLineIcon, {
364
334
  sx: {
365
335
  fontSize: '1rem'
366
336
  }
367
- })), /*#__PURE__*/React.createElement(Box, {
368
- sx: {
369
- color: 'text.secondary',
370
- fontSize: '0.75rem'
371
- }
372
- }, playbackRate, "x")))), isHovering && /*#__PURE__*/React.createElement(Box, {
373
- className: "audio-controls",
374
- sx: {
375
- position: 'absolute',
376
- top: '0.5rem',
377
- right: '0.5rem',
378
- display: 'flex',
379
- gap: '0.25rem'
380
- }
381
- }, /*#__PURE__*/React.createElement(IconButton, {
382
- size: "small",
383
- onClick: handleDownload,
384
- sx: {
385
- color: 'text.primary',
386
- bgcolor: 'background.paper'
387
- }
388
- }, /*#__PURE__*/React.createElement(DownloadLineIcon, {
389
- sx: {
390
- fontSize: '1rem'
337
+ }))))), /*#__PURE__*/React.createElement("audio", {
338
+ ref: audioRef,
339
+ src: attrs.src,
340
+ style: {
341
+ display: 'none'
342
+ },
343
+ onError: function onError(e) {
344
+ _onError === null || _onError === void 0 || _onError(e);
391
345
  }
392
- })))), /*#__PURE__*/React.createElement(FloatingPopover, {
346
+ }), /*#__PURE__*/React.createElement(FloatingPopover, {
393
347
  open: Boolean(anchorElSpeed),
394
348
  anchorEl: anchorElSpeed,
395
349
  onClose: handleCloseSpeedPopover,
@@ -425,4 +379,4 @@ var ReadonlyAudio = function ReadonlyAudio(_ref) {
425
379
  }, /*#__PURE__*/React.createElement(Box, null, rate, "x"));
426
380
  })))));
427
381
  };
428
- export default ReadonlyAudio;
382
+ export default AudioPlayer;