@ctzhian/tiptap 1.12.16 → 1.12.18

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.
@@ -4,7 +4,9 @@ import { UploadFunction } from "../type";
4
4
  interface EditorMarkdownToolbarProps {
5
5
  aceEditorRef: React.RefObject<AceEditor>;
6
6
  isExpend?: boolean;
7
+ loading?: boolean;
7
8
  onUpload?: UploadFunction;
9
+ setLoading?: (loading: boolean) => void;
8
10
  }
9
- declare const EditorMarkdownToolbar: ({ aceEditorRef, isExpend, onUpload }: EditorMarkdownToolbarProps) => React.JSX.Element;
11
+ declare const EditorMarkdownToolbar: ({ aceEditorRef, isExpend, loading, onUpload, setLoading }: EditorMarkdownToolbarProps) => React.JSX.Element;
10
12
  export default EditorMarkdownToolbar;
@@ -1,15 +1,19 @@
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
2
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
3
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
4
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
- 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; }
8
6
  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; }
9
7
  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); } }
10
8
  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); }); }; }
11
- import { Box, Divider, Stack, Typography } from "@mui/material";
12
- import React from "react";
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+ 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; }
13
+ 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; } }
14
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
+ import { alpha, Box, Divider, Paper, Stack, Typography, useTheme } from "@mui/material";
16
+ import React, { useState } from "react";
13
17
  import { AddCircleFillIcon, ArrowDownSLineIcon, AttachmentLineIcon, BoldIcon, CheckboxCircleFillIcon, CloseCircleFillIcon, CodeBoxLineIcon, CodeLineIcon, CodeSSlashLineIcon, DoubleQuotesLIcon, ErrorWarningFillIcon, Folder2LineIcon, FormulaIcon, FunctionsIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, H6Icon, ImageLineIcon, Information2FillIcon, Information2LineIcon, ItalicIcon, LinkIcon, ListCheck3Icon, ListOrdered2Icon, ListUnorderedIcon, MarkPenLineIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, Table2Icon, UnderlineIcon, UserSmileFillIcon } from "../component/Icons";
14
18
  import Menu from "../component/Menu";
15
19
  import { ToolbarItem } from "../component/Toolbar";
@@ -17,11 +21,22 @@ import TableSizePicker from "../component/Toolbar/TableSizePicker";
17
21
  var EditorMarkdownToolbar = function EditorMarkdownToolbar(_ref) {
18
22
  var aceEditorRef = _ref.aceEditorRef,
19
23
  isExpend = _ref.isExpend,
20
- onUpload = _ref.onUpload;
24
+ loading = _ref.loading,
25
+ onUpload = _ref.onUpload,
26
+ setLoading = _ref.setLoading;
27
+ var theme = useTheme();
21
28
  var imageInputRef = React.useRef(null);
22
29
  var videoInputRef = React.useRef(null);
23
30
  var audioInputRef = React.useRef(null);
24
31
  var attachmentInputRef = React.useRef(null);
32
+ var _useState = useState(0),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ uplaodProgress = _useState2[0],
35
+ setUplaodProgress = _useState2[1];
36
+ var _useState3 = useState(''),
37
+ _useState4 = _slicedToArray(_useState3, 2),
38
+ fileUploadingName = _useState4[0],
39
+ setFileUploadingName = _useState4[1];
25
40
  var insertBlockTool = function insertBlockTool(options) {
26
41
  var _aceEditorRef$current;
27
42
  var editor = (_aceEditorRef$current = aceEditorRef.current) === null || _aceEditorRef$current === void 0 ? void 0 : _aceEditorRef$current.editor;
@@ -125,36 +140,46 @@ var EditorMarkdownToolbar = function EditorMarkdownToolbar(_ref) {
125
140
  return _context.abrupt("return");
126
141
  case 2:
127
142
  _context.prev = 2;
128
- _context.next = 5;
129
- return onUpload(file);
130
- case 5:
143
+ setLoading === null || setLoading === void 0 || setLoading(true);
144
+ setFileUploadingName(file.name);
145
+ _context.next = 7;
146
+ return onUpload(file, function (progress) {
147
+ setUplaodProgress(Math.round(progress.progress * 100));
148
+ });
149
+ case 7:
131
150
  url = _context.sent;
132
151
  content = '';
133
152
  if (expectedType === 'image') {
134
153
  content = "![".concat(file.name, "](").concat(url, ")");
135
154
  } else if (expectedType === 'video') {
136
- content = "<p>\n<video src=\"".concat(url, "\" controls=\"true\"></video>\n</p>");
155
+ content = "<video src=\"".concat(url, "\" controls=\"true\"></video>");
137
156
  } else if (expectedType === 'audio') {
138
- content = "<p>\n<audio src=\"".concat(url, "\" controls=\"true\"></audio>\n</p>");
157
+ content = "<audio src=\"".concat(url, "\" controls=\"true\"></audio>");
139
158
  } else {
140
- content = "<p>\n<a href=\"".concat(url, "\" download=\"").concat(file.name, "\">").concat(file.name, "</a>\n</p>");
159
+ content = "<a href=\"".concat(url, "\" download=\"").concat(file.name, "\">").concat(file.name, "</a>");
141
160
  }
142
161
  insertBlockTool({
143
162
  text: content,
144
163
  row: 1,
145
164
  position: 1000
146
165
  });
147
- _context.next = 14;
166
+ _context.next = 16;
148
167
  break;
149
- case 11:
150
- _context.prev = 11;
168
+ case 13:
169
+ _context.prev = 13;
151
170
  _context.t0 = _context["catch"](2);
152
171
  console.error('文件上传失败:', _context.t0);
153
- case 14:
172
+ case 16:
173
+ _context.prev = 16;
174
+ setLoading === null || setLoading === void 0 || setLoading(false);
175
+ setFileUploadingName('');
176
+ setUplaodProgress(0);
177
+ return _context.finish(16);
178
+ case 21:
154
179
  case "end":
155
180
  return _context.stop();
156
181
  }
157
- }, _callee, null, [[2, 11]]);
182
+ }, _callee, null, [[2, 13, 16, 21]]);
158
183
  }));
159
184
  return function handleFileUpload(_x, _x2) {
160
185
  return _ref2.apply(this, arguments);
@@ -529,7 +554,32 @@ var EditorMarkdownToolbar = function EditorMarkdownToolbar(_ref) {
529
554
  });
530
555
  }
531
556
  }]);
532
- return /*#__PURE__*/React.createElement(Stack, {
557
+ return /*#__PURE__*/React.createElement(React.Fragment, null, loading && /*#__PURE__*/React.createElement(Paper, {
558
+ sx: {
559
+ position: 'absolute',
560
+ left: '50%',
561
+ top: 45,
562
+ overflow: 'hidden',
563
+ px: 2,
564
+ py: 1,
565
+ transform: 'translateX(-50%)',
566
+ bgcolor: 'background.default',
567
+ zIndex: 10,
568
+ border: '1px solid',
569
+ borderColor: 'primary.main',
570
+ color: 'text.disabled',
571
+ '&::before': {
572
+ content: '""',
573
+ position: 'absolute',
574
+ top: 0,
575
+ left: 0,
576
+ width: "".concat(uplaodProgress, "%"),
577
+ height: '100%',
578
+ bgcolor: alpha(theme.palette.primary.main, 0.1),
579
+ transition: 'width 0.3s ease'
580
+ }
581
+ }
582
+ }, "\u6B63\u5728\u4E0A\u4F20\u6587\u4EF6\uFF1A", fileUploadingName), /*#__PURE__*/React.createElement(Stack, {
533
583
  direction: 'row',
534
584
  alignItems: 'center'
535
585
  }, /*#__PURE__*/React.createElement(Menu, {
@@ -1061,6 +1111,6 @@ var EditorMarkdownToolbar = function EditorMarkdownToolbar(_ref) {
1061
1111
  onChange: function onChange(e) {
1062
1112
  return handleFileSelect(e, 'attachment');
1063
1113
  }
1064
- }));
1114
+ })));
1065
1115
  };
1066
1116
  export default EditorMarkdownToolbar;
@@ -25,7 +25,7 @@ var Reader = function Reader() {
25
25
  return _context.abrupt("return", new Promise(function (resolve) {
26
26
  var progress = 0;
27
27
  var interval = setInterval(function () {
28
- progress += Math.random() * 20;
28
+ progress += Math.random() * 2;
29
29
  if (progress >= 100) {
30
30
  progress = 100;
31
31
  onProgress === null || onProgress === void 0 || onProgress({
@@ -36,6 +36,10 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
36
36
  _useState4 = _slicedToArray(_useState3, 2),
37
37
  isExpend = _useState4[0],
38
38
  setIsExpend = _useState4[1];
39
+ var _useState5 = useState(false),
40
+ _useState6 = _slicedToArray(_useState5, 2),
41
+ loading = _useState6[0],
42
+ setLoading = _useState6[1];
39
43
  var EditorHeight = useMemo(function () {
40
44
  return isExpend ? 'calc(100vh - 45px)' : height;
41
45
  }, [isExpend, height]);
@@ -106,7 +110,9 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
106
110
  }, /*#__PURE__*/React.createElement(EditorMarkdownToolbar, {
107
111
  aceEditorRef: aceEditorRef,
108
112
  isExpend: isExpend,
109
- onUpload: onUpload
113
+ onUpload: onUpload,
114
+ loading: loading,
115
+ setLoading: setLoading
110
116
  }), /*#__PURE__*/React.createElement(Stack, {
111
117
  direction: 'row',
112
118
  alignItems: 'center',
@@ -194,6 +200,7 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
194
200
  onChange: onChange,
195
201
  name: "project-doc-editor",
196
202
  wrapEnabled: true,
203
+ readOnly: loading,
197
204
  showPrintMargin: false,
198
205
  placeholder: MARKDOWN_EDITOR_PLACEHOLDER,
199
206
  fontSize: 16,
@@ -0,0 +1,6 @@
1
+ import { SvgIconProps } from "@mui/material";
2
+ import * as React from "react";
3
+ export declare const Download2LineIcon: {
4
+ (props: SvgIconProps): React.JSX.Element;
5
+ displayName: string;
6
+ };
@@ -0,0 +1,13 @@
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 { SvgIcon } from "@mui/material";
3
+ import * as React from "react";
4
+ export var Download2LineIcon = function Download2LineIcon(props) {
5
+ return /*#__PURE__*/React.createElement(SvgIcon, _extends({
6
+ viewBox: "0 0 24 24",
7
+ version: "1.1",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, props), /*#__PURE__*/React.createElement("path", {
10
+ d: "M13 10H18L12 16L6 10H11V3H13V10ZM4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19Z"
11
+ }));
12
+ };
13
+ Download2LineIcon.displayName = 'icon-download-2-line';
@@ -37,6 +37,7 @@ export { DeleteColumnIcon } from './delete-column-icon';
37
37
  export { DeleteLineIcon } from './delete-line-icon';
38
38
  export { DeleteRowIcon } from './delete-row-icon';
39
39
  export { DoubleQuotesLIcon } from './double-quotes-l-icon';
40
+ export { Download2LineIcon } from './download-2-line-icon';
40
41
  export { DownloadLineIcon } from './download-line-icon';
41
42
  export { DraggableIcon } from './draggable-icon';
42
43
  export { EditBoxLineIcon } from './edit-box-line-icon';
@@ -40,6 +40,7 @@ export { DeleteColumnIcon } from "./delete-column-icon";
40
40
  export { DeleteLineIcon } from "./delete-line-icon";
41
41
  export { DeleteRowIcon } from "./delete-row-icon";
42
42
  export { DoubleQuotesLIcon } from "./double-quotes-l-icon";
43
+ export { Download2LineIcon } from "./download-2-line-icon";
43
44
  export { DownloadLineIcon } from "./download-line-icon";
44
45
  export { DraggableIcon } from "./draggable-icon";
45
46
  export { EditBoxLineIcon } from "./edit-box-line-icon";
@@ -1,4 +1,4 @@
1
- import { ChromeIcon } from "../../../component/Icons";
1
+ import { ChromeIcon, Download2LineIcon } from "../../../component/Icons";
2
2
  import { Avatar } from "@mui/material";
3
3
  import { useTheme } from "@mui/material/styles";
4
4
  import { MarkViewContent } from "@tiptap/react";
@@ -51,12 +51,16 @@ var LinkViewWrapper = function LinkViewWrapper(_ref) {
51
51
  verticalAlign: '-0.125em',
52
52
  marginRight: '2px'
53
53
  },
54
- src: favicon
55
- }, /*#__PURE__*/React.createElement(ChromeIcon, {
54
+ src: download ? undefined : favicon
55
+ }, download ? /*#__PURE__*/React.createElement(Download2LineIcon, {
56
56
  sx: {
57
57
  fontSize: '1rem',
58
58
  color: 'primary.main'
59
59
  }
60
+ }) : /*#__PURE__*/React.createElement(ChromeIcon, {
61
+ sx: {
62
+ fontSize: '1rem'
63
+ }
60
64
  })));
61
65
  };
62
66
  export default LinkViewWrapper;
@@ -7,6 +7,6 @@ export interface UploadProgressAttributes {
7
7
  tempId: string;
8
8
  }
9
9
  export declare const getFileIcon: (fileType: string) => React.JSX.Element;
10
- export declare const getFileTypeText: (fileType: string) => "视频" | "音频" | "图片" | "文件";
10
+ export declare const getFileTypeText: (fileType: string) => "图片" | "视频" | "音频" | "文件";
11
11
  declare const UploadProgressView: React.FC<NodeViewProps>;
12
12
  export default UploadProgressView;
@@ -59,9 +59,6 @@ export var getExtensions = function getExtensions(_ref) {
59
59
  editable: editable
60
60
  })), [TableOfContents({
61
61
  onTocUpdate: onTocUpdate
62
- }), InlineAttachmentExtension({
63
- onUpload: onUpload,
64
- onError: onError
65
62
  }), ImageExtension({
66
63
  onUpload: onUpload,
67
64
  onError: onError,
@@ -119,7 +116,10 @@ export var getExtensions = function getExtensions(_ref) {
119
116
  }
120
117
  }));
121
118
  } else {
122
- defaultExtensions.push.apply(defaultExtensions, [InlineLinkExtension, BlockLinkExtension, BlockAttachmentExtension({
119
+ defaultExtensions.push.apply(defaultExtensions, [InlineLinkExtension, BlockLinkExtension, InlineAttachmentExtension({
120
+ onUpload: onUpload,
121
+ onError: onError
122
+ }), BlockAttachmentExtension({
123
123
  onUpload: onUpload,
124
124
  onError: onError
125
125
  })]);
@@ -81,11 +81,11 @@ export var InlineAttachmentExtension = function InlineAttachmentExtension(props)
81
81
  'data-tag': 'attachment'
82
82
  }, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes))];
83
83
  },
84
- renderMarkdown: function renderMarkdown(_ref2) {
85
- var HTMLAttributes = _ref2.HTMLAttributes;
86
- var _ref3 = HTMLAttributes,
87
- url = _ref3.url,
88
- title = _ref3.title;
84
+ renderMarkdown: function renderMarkdown(node) {
85
+ var _ref2 = node.attrs,
86
+ url = _ref2.url,
87
+ title = _ref2.title;
88
+ if (!url) return '';
89
89
  return "<a href=\"".concat(url, "\" target=\"_blank\" download=\"").concat(title, "\">").concat(title, "</a>");
90
90
  },
91
91
  addKeyboardShortcuts: function addKeyboardShortcuts() {
@@ -104,8 +104,8 @@ export var InlineAttachmentExtension = function InlineAttachmentExtension(props)
104
104
  var _this2 = this;
105
105
  return {
106
106
  setInlineAttachment: function setInlineAttachment(options) {
107
- return function (_ref4) {
108
- var commands = _ref4.commands;
107
+ return function (_ref3) {
108
+ var commands = _ref3.commands;
109
109
  return commands.insertContent({
110
110
  type: _this2.name,
111
111
  attrs: {
@@ -197,8 +197,8 @@ export var BlockAttachmentExtension = function BlockAttachmentExtension(props) {
197
197
  }
198
198
  }];
199
199
  },
200
- renderHTML: function renderHTML(_ref5) {
201
- var HTMLAttributes = _ref5.HTMLAttributes;
200
+ renderHTML: function renderHTML(_ref4) {
201
+ var HTMLAttributes = _ref4.HTMLAttributes;
202
202
  return ['div', _objectSpread({
203
203
  'data-tag': 'attachment'
204
204
  }, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes))];
@@ -207,8 +207,8 @@ export var BlockAttachmentExtension = function BlockAttachmentExtension(props) {
207
207
  var _this3 = this;
208
208
  return {
209
209
  setBlockAttachment: function setBlockAttachment(options) {
210
- return function (_ref6) {
211
- var commands = _ref6.commands;
210
+ return function (_ref5) {
211
+ var commands = _ref5.commands;
212
212
  return commands.insertContent({
213
213
  type: _this3.name,
214
214
  attrs: {
@@ -137,9 +137,17 @@ export var AudioExtension = function AudioExtension(props) {
137
137
  var HTMLAttributes = _ref.HTMLAttributes;
138
138
  return ['audio', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
139
139
  },
140
- renderMarkdown: function renderMarkdown(_ref2) {
141
- var HTMLAttributes = _ref2.HTMLAttributes;
142
- return "<audio ".concat(HTMLAttributes.src ? "src=\"".concat(HTMLAttributes.src, "\"") : '', " ").concat(HTMLAttributes.title ? "title=\"".concat(HTMLAttributes.title, "\"") : '', " ").concat(HTMLAttributes.poster ? "poster=\"".concat(HTMLAttributes.poster, "\"") : '', " ").concat(HTMLAttributes.controls ? 'controls' : '', " ").concat(HTMLAttributes.autoplay ? 'autoplay' : '', " ").concat(HTMLAttributes.loop ? 'loop' : '', " ").concat(HTMLAttributes.muted ? 'muted' : '', "></audio>");
140
+ renderMarkdown: function renderMarkdown(node) {
141
+ var _ref2 = node.attrs,
142
+ src = _ref2.src,
143
+ title = _ref2.title,
144
+ poster = _ref2.poster,
145
+ controls = _ref2.controls,
146
+ autoplay = _ref2.autoplay,
147
+ loop = _ref2.loop,
148
+ muted = _ref2.muted;
149
+ if (!src) return '';
150
+ return "<audio src=\"".concat(src, "\" ").concat(title ? "title=\"".concat(title, "\"") : '', " ").concat(poster ? "poster=\"".concat(poster, "\"") : '', " ").concat(controls ? 'controls' : '', " ").concat(autoplay ? 'autoplay' : '', " ").concat(loop ? 'loop' : '', " ").concat(muted ? 'muted' : '', "></audio>");
143
151
  },
144
152
  addCommands: function addCommands() {
145
153
  var _this2 = this;
@@ -1,4 +1,4 @@
1
1
  import { UploadFunction } from "../../type";
2
2
  export declare const FileHandlerExtension: (props: {
3
3
  onUpload?: UploadFunction;
4
- }) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "editor" | "key">, any>;
4
+ }) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "key" | "editor">, any>;
@@ -1,6 +1,5 @@
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
- var _excluded = ["src"],
3
- _excluded2 = ["src"];
2
+ var _excluded = ["src"];
4
3
  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; }
5
4
  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; }
6
5
  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; }
@@ -91,19 +90,20 @@ export var IframeExtension = function IframeExtension(props) {
91
90
  loop: '0'
92
91
  }))];
93
92
  },
94
- renderMarkdown: function renderMarkdown(_ref3) {
95
- var HTMLAttributes = _ref3.HTMLAttributes;
96
- var _ref4 = HTMLAttributes,
97
- src = _ref4.src,
98
- rest = _objectWithoutProperties(_ref4, _excluded2);
99
- return "<iframe ".concat(rest.src ? "src=\"".concat(rest.src, "\"") : '', " ").concat(rest.width ? "width=\"".concat(rest.width, "\"") : '', " ").concat(rest.height ? "height=\"".concat(rest.height, "\"") : '', " frameborder=\"0\" allowfullscreen=\"true\" autoplay=\"0\" loop=\"0\"></iframe>");
93
+ renderMarkdown: function renderMarkdown(node) {
94
+ var _ref3 = node.attrs,
95
+ src = _ref3.src,
96
+ width = _ref3.width,
97
+ height = _ref3.height;
98
+ if (!src || src.trim() === '') return '';
99
+ return "<iframe src=\"".concat(src, "\" ").concat(width ? "width=\"".concat(width, "\"") : '', " ").concat(height ? "height=\"".concat(height, "\"") : '', " frameborder=\"0\" allowfullscreen=\"true\" autoplay=\"0\" loop=\"0\"></iframe>");
100
100
  },
101
101
  addCommands: function addCommands() {
102
102
  var _this = this;
103
103
  return {
104
104
  setIframe: function setIframe(options) {
105
- return function (_ref5) {
106
- var commands = _ref5.commands;
105
+ return function (_ref4) {
106
+ var commands = _ref4.commands;
107
107
  return commands.insertContent({
108
108
  type: _this.name,
109
109
  attrs: {
@@ -143,9 +143,17 @@ export var VideoExtension = function VideoExtension(props) {
143
143
  var HTMLAttributes = _ref.HTMLAttributes;
144
144
  return ['video', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
145
145
  },
146
- renderMarkdown: function renderMarkdown(_ref2) {
147
- var HTMLAttributes = _ref2.HTMLAttributes;
148
- return "<video ".concat(HTMLAttributes.src ? "src=\"".concat(HTMLAttributes.src, "\"") : '', " ").concat(HTMLAttributes.width ? "width=\"".concat(HTMLAttributes.width, "\"") : '', " ").concat(HTMLAttributes.controls ? 'controls' : '', " ").concat(HTMLAttributes.autoplay ? 'autoplay' : '', " ").concat(HTMLAttributes.loop ? 'loop' : '', " ").concat(HTMLAttributes.muted ? 'muted' : '', " ").concat(HTMLAttributes.poster ? "poster=\"".concat(HTMLAttributes.poster, "\"") : '', "></video>");
146
+ renderMarkdown: function renderMarkdown(node) {
147
+ var _ref2 = node.attrs,
148
+ src = _ref2.src,
149
+ width = _ref2.width,
150
+ controls = _ref2.controls,
151
+ autoplay = _ref2.autoplay,
152
+ loop = _ref2.loop,
153
+ muted = _ref2.muted,
154
+ poster = _ref2.poster;
155
+ if (!src) return '';
156
+ return "<video src=\"".concat(src, "\" ").concat(width ? "width=\"".concat(width, "\"") : '', " ").concat(controls ? 'controls' : '', " ").concat(autoplay ? 'autoplay' : '', " ").concat(loop ? 'loop' : '', " ").concat(muted ? 'muted' : '', " ").concat(poster ? "poster=\"".concat(poster, "\"") : '', "></video>");
149
157
  },
150
158
  addCommands: function addCommands() {
151
159
  var _this2 = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "1.12.16",
3
+ "version": "1.12.18",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -81,38 +81,38 @@
81
81
  },
82
82
  "dependencies": {
83
83
  "@floating-ui/dom": "^1.7.2",
84
- "@tiptap/core": "^3.10.1",
85
- "@tiptap/extension-bubble-menu": "^3.10.1",
86
- "@tiptap/extension-code": "^3.10.1",
87
- "@tiptap/extension-code-block-lowlight": "^3.10.1",
88
- "@tiptap/extension-details": "^3.10.1",
89
- "@tiptap/extension-drag-handle-react": "^3.10.1",
90
- "@tiptap/extension-emoji": "^3.10.1",
91
- "@tiptap/extension-file-handler": "^3.10.1",
92
- "@tiptap/extension-highlight": "^3.10.1",
93
- "@tiptap/extension-horizontal-rule": "^3.10.1",
94
- "@tiptap/extension-image": "^3.10.1",
95
- "@tiptap/extension-invisible-characters": "^3.10.1",
96
- "@tiptap/extension-link": "^3.10.1",
97
- "@tiptap/extension-list": "^3.10.1",
98
- "@tiptap/extension-mathematics": "^3.10.1",
99
- "@tiptap/extension-mention": "^3.10.1",
100
- "@tiptap/extension-subscript": "^3.10.1",
101
- "@tiptap/extension-superscript": "^3.10.1",
102
- "@tiptap/extension-table": "^3.10.1",
103
- "@tiptap/extension-table-of-contents": "^3.10.1",
104
- "@tiptap/extension-text-align": "^3.10.1",
105
- "@tiptap/extension-text-style": "^3.10.1",
106
- "@tiptap/extension-unique-id": "^3.10.1",
107
- "@tiptap/extension-youtube": "^3.10.1",
108
- "@tiptap/extensions": "^3.10.1",
109
- "@tiptap/html": "^3.10.1",
110
- "@tiptap/markdown": "^3.10.1",
111
- "@tiptap/pm": "^3.10.1",
112
- "@tiptap/react": "^3.10.1",
113
- "@tiptap/starter-kit": "^3.10.1",
114
- "@tiptap/static-renderer": "^3.10.1",
115
- "@tiptap/suggestion": "^3.10.1",
84
+ "@tiptap/core": "^3.10.5",
85
+ "@tiptap/extension-bubble-menu": "^3.10.5",
86
+ "@tiptap/extension-code": "^3.10.5",
87
+ "@tiptap/extension-code-block-lowlight": "^3.10.5",
88
+ "@tiptap/extension-details": "^3.10.5",
89
+ "@tiptap/extension-drag-handle-react": "^3.10.5",
90
+ "@tiptap/extension-emoji": "^3.10.5",
91
+ "@tiptap/extension-file-handler": "^3.10.5",
92
+ "@tiptap/extension-highlight": "^3.10.5",
93
+ "@tiptap/extension-horizontal-rule": "^3.10.5",
94
+ "@tiptap/extension-image": "^3.10.5",
95
+ "@tiptap/extension-invisible-characters": "^3.10.5",
96
+ "@tiptap/extension-link": "^3.10.5",
97
+ "@tiptap/extension-list": "^3.10.5",
98
+ "@tiptap/extension-mathematics": "^3.10.5",
99
+ "@tiptap/extension-mention": "^3.10.5",
100
+ "@tiptap/extension-subscript": "^3.10.5",
101
+ "@tiptap/extension-superscript": "^3.10.5",
102
+ "@tiptap/extension-table": "^3.10.5",
103
+ "@tiptap/extension-table-of-contents": "^3.10.5",
104
+ "@tiptap/extension-text-align": "^3.10.5",
105
+ "@tiptap/extension-text-style": "^3.10.5",
106
+ "@tiptap/extension-unique-id": "^3.10.5",
107
+ "@tiptap/extension-youtube": "^3.10.5",
108
+ "@tiptap/extensions": "^3.10.5",
109
+ "@tiptap/html": "^3.10.5",
110
+ "@tiptap/markdown": "^3.10.5",
111
+ "@tiptap/pm": "^3.10.5",
112
+ "@tiptap/react": "^3.10.5",
113
+ "@tiptap/starter-kit": "^3.10.5",
114
+ "@tiptap/static-renderer": "^3.10.5",
115
+ "@tiptap/suggestion": "^3.10.5",
116
116
  "ace-builds": "^1.43.4",
117
117
  "core-js": "^3.46.0",
118
118
  "diff-match-patch": "^1.0.5",