@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.
- package/dist/Editor/demo.js +19 -1
- package/dist/EditorMarkdown/demo.js +7 -8
- package/dist/asset/css/index.css +2 -2
- package/dist/component/Icons/index.d.ts +5 -0
- package/dist/component/Icons/index.js +5 -0
- package/dist/component/Icons/skip-down-icon.d.ts +6 -0
- package/dist/component/Icons/skip-down-icon.js +13 -0
- package/dist/component/Icons/skip-left-icon.d.ts +6 -0
- package/dist/component/Icons/skip-left-icon.js +13 -0
- package/dist/component/Icons/skip-right-icon.d.ts +6 -0
- package/dist/component/Icons/skip-right-icon.js +13 -0
- package/dist/component/Icons/skip-up-icon.d.ts +6 -0
- package/dist/component/Icons/skip-up-icon.js +13 -0
- package/dist/component/Icons/volume-down-line-icon.d.ts +6 -0
- package/dist/component/Icons/volume-down-line-icon.js +13 -0
- package/dist/extension/component/Attachment/AttachmentContent.d.ts +0 -1
- package/dist/extension/component/Attachment/AttachmentContent.js +33 -8
- package/dist/extension/component/Attachment/index.js +21 -12
- package/dist/extension/component/Audio/AudioPlayer.d.ts +8 -0
- package/dist/extension/component/Audio/{Readonly.js → AudioPlayer.js} +129 -175
- package/dist/extension/component/Audio/index.js +93 -462
- package/dist/extension/component/Image/index.js +25 -9
- package/dist/extension/component/Link/LinkContent.js +2 -0
- package/dist/extension/component/TableHandle/TableHandleAddButton.d.ts +14 -0
- package/dist/extension/component/TableHandle/TableHandleAddButton.js +87 -0
- package/dist/extension/component/TableHandle/TableHandleMenu.css +0 -1
- package/dist/extension/component/TableHandle/TableHandleMenu.js +6 -5
- package/dist/extension/component/TableHandle/index.js +53 -3
- package/dist/extension/component/TableSelectionOverlay/index.js +1 -2
- package/dist/extension/component/Video/index.js +9 -0
- package/dist/extension/node/CodeBlockLowlight.js +3 -2
- package/dist/index.css +1 -1
- package/package.json +1 -1
- package/dist/extension/component/Audio/Readonly.d.ts +0 -8
|
@@ -1,9 +1,4 @@
|
|
|
1
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
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
4
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -13,17 +8,18 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
13
8
|
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; }
|
|
14
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; } }
|
|
15
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
import { FloatingPopover } from "../../../component";
|
|
17
|
-
import { DeleteLineIcon, DownloadLineIcon,
|
|
18
|
-
import {
|
|
11
|
+
import { FloatingPopover, HoverPopover } from "../../../component";
|
|
12
|
+
import { DeleteLineIcon, DownloadLineIcon, EditLineIcon, UploadCloud2LineIcon } from "../../../component/Icons";
|
|
13
|
+
import { ToolbarItem } from "../../../component/Toolbar";
|
|
14
|
+
import { Button, CircularProgress, Divider, IconButton, Stack, TextField } from "@mui/material";
|
|
19
15
|
import { NodeViewWrapper } from '@tiptap/react';
|
|
20
|
-
import React, {
|
|
21
|
-
import
|
|
16
|
+
import React, { useRef, useState } from "react";
|
|
17
|
+
import AudioPlayer from "./AudioPlayer";
|
|
22
18
|
import InsertAudio from "./Insert";
|
|
23
|
-
import ReadonlyAudio from "./Readonly";
|
|
24
19
|
var EditAudioDialog = function EditAudioDialog(_ref) {
|
|
25
20
|
var attrs = _ref.attrs,
|
|
26
21
|
onSave = _ref.onSave,
|
|
22
|
+
onClose = _ref.onClose,
|
|
27
23
|
onUpload = _ref.onUpload,
|
|
28
24
|
onError = _ref.onError,
|
|
29
25
|
onValidateUrl = _ref.onValidateUrl;
|
|
@@ -252,12 +248,25 @@ var EditAudioDialog = function EditAudioDialog(_ref) {
|
|
|
252
248
|
multiple: false,
|
|
253
249
|
accept: "image/*",
|
|
254
250
|
onChange: handleUploadPoster
|
|
255
|
-
}), /*#__PURE__*/React.createElement(
|
|
251
|
+
}), /*#__PURE__*/React.createElement(Stack, {
|
|
252
|
+
direction: 'row',
|
|
253
|
+
gap: 1,
|
|
254
|
+
alignItems: 'center',
|
|
255
|
+
sx: {
|
|
256
|
+
mt: 1
|
|
257
|
+
}
|
|
258
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
259
|
+
variant: "outlined",
|
|
260
|
+
size: "small",
|
|
261
|
+
fullWidth: true,
|
|
262
|
+
onClick: onClose
|
|
263
|
+
}, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
|
|
256
264
|
variant: "contained",
|
|
257
|
-
|
|
265
|
+
size: "small",
|
|
258
266
|
fullWidth: true,
|
|
259
|
-
onClick: handleSave
|
|
260
|
-
|
|
267
|
+
onClick: handleSave,
|
|
268
|
+
disabled: uploadingPoster || uploading || !src.trim()
|
|
269
|
+
}, "\u4FDD\u5B58")));
|
|
261
270
|
};
|
|
262
271
|
var AudioViewWrapper = function AudioViewWrapper(_ref5) {
|
|
263
272
|
var editor = _ref5.editor,
|
|
@@ -266,123 +275,25 @@ var AudioViewWrapper = function AudioViewWrapper(_ref5) {
|
|
|
266
275
|
deleteNode = _ref5.deleteNode,
|
|
267
276
|
selected = _ref5.selected,
|
|
268
277
|
onUpload = _ref5.onUpload,
|
|
269
|
-
|
|
278
|
+
onError = _ref5.onError,
|
|
270
279
|
onValidateUrl = _ref5.onValidateUrl;
|
|
271
280
|
var attrs = node.attrs;
|
|
272
|
-
var
|
|
273
|
-
var _useState11 = useState(
|
|
281
|
+
var editButtonRef = useRef(null);
|
|
282
|
+
var _useState11 = useState(null),
|
|
274
283
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
275
|
-
|
|
276
|
-
|
|
284
|
+
anchorElEdit = _useState12[0],
|
|
285
|
+
setAnchorElEdit = _useState12[1];
|
|
277
286
|
var _useState13 = useState(false),
|
|
278
287
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
var
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
setIsMuted = _useState16[1];
|
|
285
|
-
var _useState17 = useState(0),
|
|
286
|
-
_useState18 = _slicedToArray(_useState17, 2),
|
|
287
|
-
currentTime = _useState18[0],
|
|
288
|
-
setCurrentTime = _useState18[1];
|
|
289
|
-
var _useState19 = useState(0),
|
|
290
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
291
|
-
duration = _useState20[0],
|
|
292
|
-
setDuration = _useState20[1];
|
|
293
|
-
var _useState21 = useState(0.5),
|
|
294
|
-
_useState22 = _slicedToArray(_useState21, 2),
|
|
295
|
-
volume = _useState22[0],
|
|
296
|
-
setVolume = _useState22[1];
|
|
297
|
-
var _useState23 = useState(1),
|
|
298
|
-
_useState24 = _slicedToArray(_useState23, 2),
|
|
299
|
-
playbackRate = _useState24[0],
|
|
300
|
-
setPlaybackRate = _useState24[1];
|
|
301
|
-
var _useState25 = useState(null),
|
|
302
|
-
_useState26 = _slicedToArray(_useState25, 2),
|
|
303
|
-
anchorElEdit = _useState26[0],
|
|
304
|
-
setAnchorElEdit = _useState26[1];
|
|
305
|
-
var handleCloseEditPopover = function handleCloseEditPopover() {
|
|
306
|
-
return setAnchorElEdit(null);
|
|
307
|
-
};
|
|
308
|
-
var handleShowEditPopover = function handleShowEditPopover(event) {
|
|
309
|
-
if (anchorElEdit) {
|
|
310
|
-
handleCloseEditPopover();
|
|
311
|
-
} else {
|
|
312
|
-
setAnchorElEdit(event.currentTarget);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
var _useState27 = useState(null),
|
|
316
|
-
_useState28 = _slicedToArray(_useState27, 2),
|
|
317
|
-
anchorElSpeed = _useState28[0],
|
|
318
|
-
setAnchorElSpeed = _useState28[1];
|
|
319
|
-
var handleCloseSpeedPopover = function handleCloseSpeedPopover() {
|
|
320
|
-
return setAnchorElSpeed(null);
|
|
321
|
-
};
|
|
322
|
-
var handleShowSpeedPopover = function handleShowSpeedPopover(event) {
|
|
323
|
-
if (anchorElSpeed) {
|
|
324
|
-
handleCloseSpeedPopover();
|
|
325
|
-
} else {
|
|
326
|
-
setAnchorElSpeed(event.currentTarget);
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
// 格式化时间
|
|
331
|
-
var formatTime = function formatTime(time) {
|
|
332
|
-
var minutes = Math.floor(time / 60);
|
|
333
|
-
var seconds = Math.floor(time % 60);
|
|
334
|
-
return "".concat(minutes, ":").concat(seconds < 10 ? '0' : '').concat(seconds);
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
// 处理声音
|
|
338
|
-
var toogleMute = function toogleMute() {
|
|
339
|
-
if (audioRef.current) {
|
|
340
|
-
if (isMuted) {
|
|
341
|
-
audioRef.current.muted = false;
|
|
342
|
-
} else {
|
|
343
|
-
audioRef.current.muted = true;
|
|
344
|
-
}
|
|
345
|
-
setIsMuted(!isMuted);
|
|
346
|
-
}
|
|
288
|
+
keepHoverPopoverOpen = _useState14[0],
|
|
289
|
+
setKeepHoverPopoverOpen = _useState14[1];
|
|
290
|
+
var handleShowPopover = function handleShowPopover() {
|
|
291
|
+
setKeepHoverPopoverOpen(true);
|
|
292
|
+
setAnchorElEdit(editButtonRef.current);
|
|
347
293
|
};
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
if (audioRef.current) {
|
|
352
|
-
if (isPlaying) {
|
|
353
|
-
audioRef.current.pause();
|
|
354
|
-
} else {
|
|
355
|
-
audioRef.current.play();
|
|
356
|
-
}
|
|
357
|
-
setIsPlaying(!isPlaying);
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
// 处理进度条变化
|
|
362
|
-
var handleProgressChange = function handleProgressChange(event, newValue) {
|
|
363
|
-
var newTime = newValue;
|
|
364
|
-
if (audioRef.current) {
|
|
365
|
-
audioRef.current.currentTime = newTime;
|
|
366
|
-
setCurrentTime(newTime);
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
// 处理音量变化
|
|
371
|
-
var handleVolumeChange = function handleVolumeChange(event, newValue) {
|
|
372
|
-
var newVolume = newValue;
|
|
373
|
-
setVolume(newVolume);
|
|
374
|
-
if (audioRef.current) {
|
|
375
|
-
audioRef.current.volume = newVolume;
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
// 处理播放速度变化
|
|
380
|
-
var handlePlaybackRateChange = function handlePlaybackRateChange(rate) {
|
|
381
|
-
setPlaybackRate(rate);
|
|
382
|
-
if (audioRef.current) {
|
|
383
|
-
audioRef.current.playbackRate = rate;
|
|
384
|
-
}
|
|
385
|
-
handleCloseSpeedPopover();
|
|
294
|
+
var handleClosePopover = function handleClosePopover() {
|
|
295
|
+
setAnchorElEdit(null);
|
|
296
|
+
setKeepHoverPopoverOpen(false);
|
|
386
297
|
};
|
|
387
298
|
|
|
388
299
|
// 处理下载
|
|
@@ -408,368 +319,88 @@ var AudioViewWrapper = function AudioViewWrapper(_ref5) {
|
|
|
408
319
|
loop: attrs.loop,
|
|
409
320
|
muted: attrs.muted
|
|
410
321
|
});
|
|
411
|
-
|
|
322
|
+
handleClosePopover();
|
|
412
323
|
};
|
|
413
|
-
|
|
414
|
-
// 音频事件处理
|
|
415
|
-
useEffect(function () {
|
|
416
|
-
var audio = audioRef.current;
|
|
417
|
-
if (!audio) return;
|
|
418
|
-
var handleLoadedMetadata = function handleLoadedMetadata() {
|
|
419
|
-
setDuration(audio.duration);
|
|
420
|
-
};
|
|
421
|
-
var handleTimeUpdate = function handleTimeUpdate() {
|
|
422
|
-
setCurrentTime(audio.currentTime);
|
|
423
|
-
};
|
|
424
|
-
var handlePlay = function handlePlay() {
|
|
425
|
-
setIsPlaying(true);
|
|
426
|
-
};
|
|
427
|
-
var handlePause = function handlePause() {
|
|
428
|
-
setIsPlaying(false);
|
|
429
|
-
};
|
|
430
|
-
var handleError = function handleError(e) {
|
|
431
|
-
_onError === null || _onError === void 0 || _onError(e.error);
|
|
432
|
-
};
|
|
433
|
-
audio.addEventListener('loadedmetadata', handleLoadedMetadata);
|
|
434
|
-
audio.addEventListener('timeupdate', handleTimeUpdate);
|
|
435
|
-
audio.addEventListener('play', handlePlay);
|
|
436
|
-
audio.addEventListener('pause', handlePause);
|
|
437
|
-
audio.addEventListener('error', handleError);
|
|
438
|
-
return function () {
|
|
439
|
-
audio.removeEventListener('loadedmetadata', handleLoadedMetadata);
|
|
440
|
-
audio.removeEventListener('timeupdate', handleTimeUpdate);
|
|
441
|
-
audio.removeEventListener('play', handlePlay);
|
|
442
|
-
audio.removeEventListener('pause', handlePause);
|
|
443
|
-
audio.removeEventListener('error', handleError);
|
|
444
|
-
};
|
|
445
|
-
}, [attrs.src, _onError]);
|
|
446
324
|
if (!attrs.src && !editor.isEditable) {
|
|
447
325
|
return null;
|
|
448
326
|
}
|
|
449
|
-
if (!editor.isEditable) {
|
|
450
|
-
return /*#__PURE__*/React.createElement(ReadonlyAudio, {
|
|
451
|
-
attrs: attrs,
|
|
452
|
-
onError: _onError
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
327
|
if (!attrs.src) {
|
|
456
328
|
return /*#__PURE__*/React.createElement(InsertAudio, {
|
|
457
329
|
selected: selected,
|
|
458
330
|
attrs: attrs,
|
|
459
331
|
updateAttributes: updateAttributes,
|
|
460
332
|
onUpload: onUpload,
|
|
461
|
-
onError:
|
|
333
|
+
onError: onError,
|
|
462
334
|
onValidateUrl: onValidateUrl
|
|
463
335
|
});
|
|
464
336
|
}
|
|
337
|
+
var isEditable = editor.isEditable;
|
|
465
338
|
return /*#__PURE__*/React.createElement(NodeViewWrapper, {
|
|
466
339
|
className: "audio-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
|
|
467
340
|
"data-drag-handle": true
|
|
468
|
-
}, /*#__PURE__*/React.createElement(
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
341
|
+
}, isEditable ? /*#__PURE__*/React.createElement(HoverPopover, {
|
|
342
|
+
keepOpen: keepHoverPopoverOpen,
|
|
343
|
+
placement: "top",
|
|
344
|
+
offset: 4,
|
|
345
|
+
actions: /*#__PURE__*/React.createElement(Stack, {
|
|
346
|
+
direction: 'row',
|
|
347
|
+
alignItems: 'center',
|
|
348
|
+
sx: {
|
|
349
|
+
p: 0.5
|
|
350
|
+
}
|
|
351
|
+
}, /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
352
|
+
ref: editButtonRef,
|
|
353
|
+
icon: /*#__PURE__*/React.createElement(EditLineIcon, {
|
|
354
|
+
sx: {
|
|
355
|
+
fontSize: '1rem'
|
|
356
|
+
}
|
|
357
|
+
}),
|
|
358
|
+
tip: "\u7F16\u8F91\u97F3\u9891",
|
|
359
|
+
onClick: handleShowPopover
|
|
360
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
361
|
+
icon: /*#__PURE__*/React.createElement(DownloadLineIcon, {
|
|
362
|
+
sx: {
|
|
363
|
+
fontSize: '1rem'
|
|
481
364
|
}
|
|
365
|
+
}),
|
|
366
|
+
tip: "\u4E0B\u8F7D\u97F3\u9891",
|
|
367
|
+
onClick: handleDownload
|
|
368
|
+
}), /*#__PURE__*/React.createElement(Divider, {
|
|
369
|
+
orientation: "vertical",
|
|
370
|
+
flexItem: true,
|
|
371
|
+
sx: {
|
|
372
|
+
height: '1rem',
|
|
373
|
+
mx: 0.5,
|
|
374
|
+
alignSelf: 'center',
|
|
375
|
+
borderColor: 'divider'
|
|
482
376
|
}
|
|
483
|
-
},
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
onMouseLeave: function onMouseLeave() {
|
|
488
|
-
return setIsHovering(false);
|
|
489
|
-
}
|
|
490
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
491
|
-
sx: {
|
|
492
|
-
height: 100,
|
|
493
|
-
minWidth: 100,
|
|
494
|
-
cursor: 'pointer',
|
|
495
|
-
position: 'relative',
|
|
496
|
-
flexShrink: 0,
|
|
497
|
-
display: 'flex',
|
|
498
|
-
alignItems: 'center',
|
|
499
|
-
justifyContent: 'center',
|
|
500
|
-
borderRadius: 'var(--mui-shape-borderRadius) 0 0 var(--mui-shape-borderRadius)',
|
|
501
|
-
backgroundSize: 'cover',
|
|
502
|
-
backgroundImage: "url(".concat(Disk, ")")
|
|
503
|
-
},
|
|
504
|
-
onClick: togglePlay
|
|
505
|
-
}, attrs.poster && /*#__PURE__*/React.createElement("img", {
|
|
506
|
-
src: attrs.poster,
|
|
507
|
-
alt: "\u97F3\u9891\u6D77\u62A5",
|
|
508
|
-
style: _objectSpread({
|
|
509
|
-
width: 48,
|
|
510
|
-
height: 48,
|
|
511
|
-
objectFit: 'cover',
|
|
512
|
-
borderRadius: '50%'
|
|
513
|
-
}, isPlaying && {
|
|
514
|
-
animation: 'rotate-icon infinite 20s linear'
|
|
515
|
-
})
|
|
516
|
-
}), /*#__PURE__*/React.createElement(Box, {
|
|
517
|
-
sx: {
|
|
518
|
-
position: 'absolute',
|
|
519
|
-
top: 0,
|
|
520
|
-
left: 0,
|
|
521
|
-
width: '100%',
|
|
522
|
-
height: '100%',
|
|
523
|
-
display: 'flex',
|
|
524
|
-
alignItems: 'center',
|
|
525
|
-
justifyContent: 'center',
|
|
526
|
-
opacity: isHovering ? 1 : 0,
|
|
527
|
-
transition: 'opacity 0.2s',
|
|
528
|
-
borderRadius: '50%'
|
|
529
|
-
}
|
|
530
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
531
|
-
sx: {
|
|
532
|
-
width: 32,
|
|
533
|
-
height: 32,
|
|
534
|
-
borderRadius: '50%',
|
|
535
|
-
display: 'flex',
|
|
536
|
-
alignItems: 'center',
|
|
537
|
-
justifyContent: 'center'
|
|
538
|
-
}
|
|
539
|
-
}, /*#__PURE__*/React.createElement(IconButton, null, isPlaying ? /*#__PURE__*/React.createElement(PauseLineIcon, {
|
|
540
|
-
sx: {
|
|
541
|
-
fontSize: '1.5rem',
|
|
542
|
-
color: 'text.primary'
|
|
543
|
-
}
|
|
544
|
-
}) : /*#__PURE__*/React.createElement(PlayLineIcon, {
|
|
545
|
-
sx: {
|
|
546
|
-
fontSize: '1.5rem',
|
|
547
|
-
color: 'text.primary'
|
|
548
|
-
}
|
|
549
|
-
}))))), /*#__PURE__*/React.createElement(Box, {
|
|
550
|
-
sx: {
|
|
551
|
-
flex: 1,
|
|
552
|
-
pr: 2,
|
|
553
|
-
pl: 4,
|
|
554
|
-
position: 'relative'
|
|
555
|
-
}
|
|
556
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
557
|
-
variant: "subtitle1",
|
|
558
|
-
sx: {
|
|
559
|
-
fontWeight: 500,
|
|
560
|
-
mb: 1
|
|
561
|
-
}
|
|
562
|
-
}, attrs.title || '音频'), /*#__PURE__*/React.createElement(Stack, {
|
|
563
|
-
direction: "row",
|
|
564
|
-
alignItems: "center",
|
|
565
|
-
spacing: 1
|
|
566
|
-
}, /*#__PURE__*/React.createElement(Stack, {
|
|
567
|
-
direction: "row",
|
|
568
|
-
alignItems: "center",
|
|
569
|
-
spacing: 1,
|
|
570
|
-
sx: {
|
|
571
|
-
flex: 1
|
|
572
|
-
}
|
|
573
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
574
|
-
variant: "caption",
|
|
575
|
-
sx: {
|
|
576
|
-
minWidth: 40
|
|
577
|
-
}
|
|
578
|
-
}, formatTime(currentTime)), /*#__PURE__*/React.createElement(Slider, {
|
|
579
|
-
value: currentTime,
|
|
580
|
-
min: 0,
|
|
581
|
-
max: duration || 100,
|
|
582
|
-
onChange: handleProgressChange,
|
|
583
|
-
size: "small",
|
|
584
|
-
sx: {
|
|
585
|
-
flex: 1
|
|
586
|
-
}
|
|
587
|
-
}), /*#__PURE__*/React.createElement(Typography, {
|
|
588
|
-
variant: "caption",
|
|
589
|
-
sx: {
|
|
590
|
-
minWidth: 40
|
|
591
|
-
}
|
|
592
|
-
}, formatTime(duration))), /*#__PURE__*/React.createElement(Stack, {
|
|
593
|
-
direction: "row",
|
|
594
|
-
alignItems: "center",
|
|
595
|
-
sx: {
|
|
596
|
-
flexShrink: 0
|
|
597
|
-
}
|
|
598
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
599
|
-
size: "small",
|
|
600
|
-
onClick: toogleMute,
|
|
601
|
-
sx: {
|
|
602
|
-
flexShrink: 0
|
|
603
|
-
}
|
|
604
|
-
}, !isMuted ? /*#__PURE__*/React.createElement(VolumeUpLineIcon, {
|
|
605
|
-
sx: {
|
|
606
|
-
fontSize: '1rem'
|
|
607
|
-
}
|
|
608
|
-
}) : /*#__PURE__*/React.createElement(VolumeMuteLineIcon, {
|
|
609
|
-
sx: {
|
|
610
|
-
fontSize: '1rem'
|
|
611
|
-
}
|
|
612
|
-
})), /*#__PURE__*/React.createElement(Slider, {
|
|
613
|
-
value: volume,
|
|
614
|
-
min: 0,
|
|
615
|
-
max: 1,
|
|
616
|
-
step: 0.01,
|
|
617
|
-
onChange: handleVolumeChange,
|
|
618
|
-
size: "small",
|
|
619
|
-
color: "error",
|
|
620
|
-
disabled: isMuted,
|
|
621
|
-
sx: function sx(t) {
|
|
622
|
-
return _objectSpread({
|
|
623
|
-
width: 80,
|
|
624
|
-
color: 'rgba(0,0,0,0.87)',
|
|
625
|
-
'& .MuiSlider-track': {
|
|
626
|
-
border: 'none'
|
|
627
|
-
},
|
|
628
|
-
'& .MuiSlider-thumb': {
|
|
629
|
-
width: 12,
|
|
630
|
-
height: 12,
|
|
631
|
-
backgroundColor: '#fff',
|
|
632
|
-
'&::before': {
|
|
633
|
-
boxShadow: '0 4px 8px rgba(0,0,0,0.4)'
|
|
634
|
-
},
|
|
635
|
-
'&:hover, &.Mui-focusVisible, &.Mui-active': {
|
|
636
|
-
boxShadow: 'none'
|
|
637
|
-
}
|
|
377
|
+
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
378
|
+
icon: /*#__PURE__*/React.createElement(DeleteLineIcon, {
|
|
379
|
+
sx: {
|
|
380
|
+
fontSize: '1rem'
|
|
638
381
|
}
|
|
639
|
-
},
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
flexShrink: 0,
|
|
651
|
-
pr: 1
|
|
652
|
-
},
|
|
653
|
-
onClick: handleShowSpeedPopover
|
|
654
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
655
|
-
size: "small",
|
|
656
|
-
sx: {
|
|
657
|
-
color: anchorElSpeed ? 'primary.main' : ''
|
|
658
|
-
}
|
|
659
|
-
}, /*#__PURE__*/React.createElement(SpeedLineIcon, {
|
|
660
|
-
sx: {
|
|
661
|
-
fontSize: '1rem'
|
|
662
|
-
}
|
|
663
|
-
})), /*#__PURE__*/React.createElement(Box, {
|
|
664
|
-
sx: {
|
|
665
|
-
color: 'text.secondary',
|
|
666
|
-
fontSize: '0.75rem'
|
|
667
|
-
}
|
|
668
|
-
}, playbackRate, "x"))))), (isHovering || !!anchorElEdit) && /*#__PURE__*/React.createElement(Box, {
|
|
669
|
-
className: "audio-controls",
|
|
670
|
-
sx: {
|
|
671
|
-
position: 'absolute',
|
|
672
|
-
top: '0.5rem',
|
|
673
|
-
right: '0.5rem',
|
|
674
|
-
display: 'flex',
|
|
675
|
-
gap: '0.25rem'
|
|
676
|
-
}
|
|
677
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
678
|
-
arrow: true,
|
|
679
|
-
title: "\u7F16\u8F91\u97F3\u9891"
|
|
680
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
681
|
-
size: "small",
|
|
682
|
-
onClick: handleShowEditPopover,
|
|
683
|
-
sx: {
|
|
684
|
-
color: 'text.primary',
|
|
685
|
-
bgcolor: 'background.paper'
|
|
686
|
-
}
|
|
687
|
-
}, /*#__PURE__*/React.createElement(EditBoxLineIcon, {
|
|
688
|
-
sx: {
|
|
689
|
-
fontSize: '1rem'
|
|
690
|
-
}
|
|
691
|
-
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
692
|
-
arrow: true,
|
|
693
|
-
title: "\u4E0B\u8F7D\u97F3\u9891"
|
|
694
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
695
|
-
size: "small",
|
|
696
|
-
onClick: handleDownload,
|
|
697
|
-
sx: {
|
|
698
|
-
color: 'text.primary',
|
|
699
|
-
bgcolor: 'background.paper'
|
|
700
|
-
}
|
|
701
|
-
}, /*#__PURE__*/React.createElement(DownloadLineIcon, {
|
|
702
|
-
sx: {
|
|
703
|
-
fontSize: '1rem'
|
|
704
|
-
}
|
|
705
|
-
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
706
|
-
arrow: true,
|
|
707
|
-
title: "\u5220\u9664\u97F3\u9891"
|
|
708
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
709
|
-
size: "small",
|
|
710
|
-
onClick: deleteNode,
|
|
711
|
-
sx: {
|
|
712
|
-
color: 'text.primary',
|
|
713
|
-
bgcolor: 'background.paper'
|
|
714
|
-
}
|
|
715
|
-
}, /*#__PURE__*/React.createElement(DeleteLineIcon, {
|
|
716
|
-
sx: {
|
|
717
|
-
fontSize: '1rem'
|
|
718
|
-
}
|
|
719
|
-
}))))), /*#__PURE__*/React.createElement("audio", {
|
|
720
|
-
ref: audioRef,
|
|
721
|
-
src: attrs.src,
|
|
722
|
-
style: {
|
|
723
|
-
display: 'none'
|
|
724
|
-
},
|
|
725
|
-
onError: function onError(e) {
|
|
726
|
-
_onError === null || _onError === void 0 || _onError(e);
|
|
727
|
-
}
|
|
728
|
-
}), /*#__PURE__*/React.createElement(FloatingPopover, {
|
|
382
|
+
}),
|
|
383
|
+
tip: "\u5220\u9664\u97F3\u9891",
|
|
384
|
+
onClick: deleteNode
|
|
385
|
+
}))
|
|
386
|
+
}, /*#__PURE__*/React.createElement(AudioPlayer, {
|
|
387
|
+
attrs: attrs,
|
|
388
|
+
onError: onError
|
|
389
|
+
})) : /*#__PURE__*/React.createElement(AudioPlayer, {
|
|
390
|
+
attrs: attrs,
|
|
391
|
+
onError: onError
|
|
392
|
+
}), isEditable && /*#__PURE__*/React.createElement(FloatingPopover, {
|
|
729
393
|
open: Boolean(anchorElEdit),
|
|
730
394
|
anchorEl: anchorElEdit,
|
|
731
|
-
onClose:
|
|
395
|
+
onClose: handleClosePopover,
|
|
732
396
|
placement: "bottom"
|
|
733
397
|
}, /*#__PURE__*/React.createElement(EditAudioDialog, {
|
|
734
398
|
attrs: attrs,
|
|
735
399
|
onSave: updateAudioSource,
|
|
400
|
+
onClose: handleClosePopover,
|
|
736
401
|
onUpload: onUpload,
|
|
737
|
-
onError:
|
|
402
|
+
onError: onError,
|
|
738
403
|
onValidateUrl: onValidateUrl
|
|
739
|
-
}))
|
|
740
|
-
open: Boolean(anchorElSpeed),
|
|
741
|
-
anchorEl: anchorElSpeed,
|
|
742
|
-
onClose: handleCloseSpeedPopover,
|
|
743
|
-
placement: "bottom"
|
|
744
|
-
}, /*#__PURE__*/React.createElement(Paper, {
|
|
745
|
-
sx: {
|
|
746
|
-
p: 0.5,
|
|
747
|
-
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
748
|
-
'.MuiList-root': {
|
|
749
|
-
p: '0px !important',
|
|
750
|
-
m: '0px !important'
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
}, /*#__PURE__*/React.createElement(MenuList, null, [0.5, 0.75, 1, 1.25, 1.5, 2].map(function (rate, index) {
|
|
754
|
-
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
755
|
-
key: index,
|
|
756
|
-
selected: rate === playbackRate,
|
|
757
|
-
onClick: function onClick() {
|
|
758
|
-
return handlePlaybackRateChange(rate);
|
|
759
|
-
},
|
|
760
|
-
sx: {
|
|
761
|
-
py: 1,
|
|
762
|
-
px: 2,
|
|
763
|
-
fontSize: '0.875rem',
|
|
764
|
-
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
765
|
-
'&:hover:not(.Mui-selected)': {
|
|
766
|
-
backgroundColor: 'action.hover'
|
|
767
|
-
},
|
|
768
|
-
'&.Mui-selected': {
|
|
769
|
-
backgroundColor: 'action.selected'
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
}, /*#__PURE__*/React.createElement(Box, null, rate, "x"));
|
|
773
|
-
})))));
|
|
404
|
+
})));
|
|
774
405
|
};
|
|
775
406
|
export default AudioViewWrapper;
|