@ctzhian/tiptap 1.12.17 → 1.12.19
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 +1 -1
- package/dist/EditorMarkdown/Toolbar.d.ts +3 -1
- package/dist/EditorMarkdown/Toolbar.js +68 -18
- package/dist/EditorMarkdown/demo.js +5 -1
- package/dist/EditorMarkdown/index.d.ts +5 -0
- package/dist/EditorMarkdown/index.js +20 -6
- package/dist/component/Icons/download-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/download-2-line-icon.js +13 -0
- package/dist/component/Icons/index.d.ts +1 -0
- package/dist/component/Icons/index.js +1 -0
- package/dist/extension/component/Link/Markdown.js +7 -3
- package/dist/extension/component/UploadProgress/index.d.ts +1 -1
- package/dist/extension/node/FileHandler.d.ts +1 -1
- package/dist/index.css +3 -2
- package/package.json +33 -33
package/dist/Editor/demo.js
CHANGED
|
@@ -152,7 +152,7 @@ var Reader = function Reader() {
|
|
|
152
152
|
}
|
|
153
153
|
return onUpload;
|
|
154
154
|
}(),
|
|
155
|
-
content: "<ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>jfdlsaf</p></li><li><p>sadfsa</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>fjasldkfj</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>fasd</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>fasdjklf</p></li></ol></li><li><p>fjdslkf</p></li><li><p>sjfsadlf</p></li></ol></li></ol></li></ol><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>fsldjakfjlksd</p></li><li><p>fsadfasd</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>fajsdlkfj</p></li><li><p>fasdjklf</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>fjasldfsa</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>fsadlkj</p></li></ul></li></ul></li></ul></li></ul><p></p>"
|
|
155
|
+
content: "<ul data-type=\"taskList\"><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>\u653E\u5047\u963F\u65AF\u5229\u5EB7\u90FD\u653E\u5047\u4E86\u770B\u6C99\u53D1</p></div></li><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>\u53D1\u94FE\u63A5 sd \u5361\u653E\u5047\u963F\u65AF\u5229\u5EB7\u6253\u98DE\u673A\u4E86</p></div></li></ul><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>jfdlsaf</p></li><li><p>sadfsa</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>fjasldkfj</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>fasd</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>fasdjklf</p></li></ol></li><li><p>fjdslkf</p></li><li><p>sjfsadlf</p></li></ol></li></ol></li></ol><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>fsldjakfjlksd</p></li><li><p>fsadfasd</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>fajsdlkfj</p></li><li><p>fasdjklf</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>fjasldfsa</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>fsadlkj</p></li></ul></li></ul></li></ul></li></ul><p></p>"
|
|
156
156
|
}),
|
|
157
157
|
editor = _useTiptap.editor;
|
|
158
158
|
return /*#__PURE__*/React.createElement(EditorThemeProvider, {
|
|
@@ -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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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(url, ")");
|
|
135
154
|
} else if (expectedType === 'video') {
|
|
136
|
-
content = "<
|
|
155
|
+
content = "<video src=\"".concat(url, "\" controls=\"true\"></video>");
|
|
137
156
|
} else if (expectedType === 'audio') {
|
|
138
|
-
content = "<
|
|
157
|
+
content = "<audio src=\"".concat(url, "\" controls=\"true\"></audio>");
|
|
139
158
|
} else {
|
|
140
|
-
content = "<
|
|
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 =
|
|
166
|
+
_context.next = 16;
|
|
148
167
|
break;
|
|
149
|
-
case
|
|
150
|
-
_context.prev =
|
|
168
|
+
case 13:
|
|
169
|
+
_context.prev = 13;
|
|
151
170
|
_context.t0 = _context["catch"](2);
|
|
152
171
|
console.error('文件上传失败:', _context.t0);
|
|
153
|
-
case
|
|
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,
|
|
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(
|
|
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() *
|
|
28
|
+
progress += Math.random() * 2;
|
|
29
29
|
if (progress >= 100) {
|
|
30
30
|
progress = 100;
|
|
31
31
|
onProgress === null || onProgress === void 0 || onProgress({
|
|
@@ -155,6 +155,10 @@ var Reader = function Reader() {
|
|
|
155
155
|
editor: editor,
|
|
156
156
|
height: '500px',
|
|
157
157
|
value: mdContent,
|
|
158
|
+
splitMode: true,
|
|
159
|
+
showToolbar: false,
|
|
160
|
+
defaultDisplayMode: "edit",
|
|
161
|
+
placeholder: "\u8BF7\u8F93\u5165\u5185\u5BB9",
|
|
158
162
|
onUpload: onUpload,
|
|
159
163
|
onAceChange: setMdContent
|
|
160
164
|
})));
|
|
@@ -12,13 +12,18 @@ import 'ace-builds/src-noconflict/theme-github';
|
|
|
12
12
|
interface EditorMarkdownProps {
|
|
13
13
|
editor: Editor;
|
|
14
14
|
value?: string;
|
|
15
|
+
placeholder?: string;
|
|
15
16
|
height: number | string;
|
|
16
17
|
onUpload?: UploadFunction;
|
|
18
|
+
defaultDisplayMode?: DisplayMode;
|
|
19
|
+
splitMode?: boolean;
|
|
20
|
+
showToolbar?: boolean;
|
|
17
21
|
onAceChange?: (value: string) => void;
|
|
18
22
|
onTiptapChange?: (value: string) => void;
|
|
19
23
|
}
|
|
20
24
|
export interface MarkdownEditorRef {
|
|
21
25
|
scrollToHeading: (headingText: string) => void;
|
|
22
26
|
}
|
|
27
|
+
type DisplayMode = 'edit' | 'preview' | 'split';
|
|
23
28
|
declare const EditorMarkdown: React.ForwardRefExoticComponent<EditorMarkdownProps & React.RefAttributes<MarkdownEditorRef>>;
|
|
24
29
|
export default EditorMarkdown;
|
|
@@ -23,12 +23,19 @@ import 'ace-builds/src-noconflict/theme-github';
|
|
|
23
23
|
var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
24
24
|
var editor = _ref.editor,
|
|
25
25
|
value = _ref.value,
|
|
26
|
+
placeholder = _ref.placeholder,
|
|
26
27
|
onAceChange = _ref.onAceChange,
|
|
27
28
|
height = _ref.height,
|
|
28
|
-
onUpload = _ref.onUpload
|
|
29
|
+
onUpload = _ref.onUpload,
|
|
30
|
+
_ref$splitMode = _ref.splitMode,
|
|
31
|
+
splitMode = _ref$splitMode === void 0 ? false : _ref$splitMode,
|
|
32
|
+
_ref$defaultDisplayMo = _ref.defaultDisplayMode,
|
|
33
|
+
defaultDisplayMode = _ref$defaultDisplayMo === void 0 ? 'edit' : _ref$defaultDisplayMo,
|
|
34
|
+
_ref$showToolbar = _ref.showToolbar,
|
|
35
|
+
showToolbar = _ref$showToolbar === void 0 ? true : _ref$showToolbar;
|
|
29
36
|
var theme = useTheme();
|
|
30
37
|
var aceEditorRef = useRef(null);
|
|
31
|
-
var _useState = useState(
|
|
38
|
+
var _useState = useState(defaultDisplayMode),
|
|
32
39
|
_useState2 = _slicedToArray(_useState, 2),
|
|
33
40
|
displayMode = _useState2[0],
|
|
34
41
|
setDisplayMode = _useState2[1];
|
|
@@ -36,6 +43,10 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
36
43
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
37
44
|
isExpend = _useState4[0],
|
|
38
45
|
setIsExpend = _useState4[1];
|
|
46
|
+
var _useState5 = useState(false),
|
|
47
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
48
|
+
loading = _useState6[0],
|
|
49
|
+
setLoading = _useState6[1];
|
|
39
50
|
var EditorHeight = useMemo(function () {
|
|
40
51
|
return isExpend ? 'calc(100vh - 45px)' : height;
|
|
41
52
|
}, [isExpend, height]);
|
|
@@ -81,7 +92,7 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
81
92
|
right: 0,
|
|
82
93
|
zIndex: 2000
|
|
83
94
|
})
|
|
84
|
-
}, /*#__PURE__*/React.createElement(Stack, {
|
|
95
|
+
}, showToolbar && /*#__PURE__*/React.createElement(Stack, {
|
|
85
96
|
direction: "row",
|
|
86
97
|
alignItems: 'center',
|
|
87
98
|
justifyContent: 'space-between',
|
|
@@ -106,7 +117,9 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
106
117
|
}, /*#__PURE__*/React.createElement(EditorMarkdownToolbar, {
|
|
107
118
|
aceEditorRef: aceEditorRef,
|
|
108
119
|
isExpend: isExpend,
|
|
109
|
-
onUpload: onUpload
|
|
120
|
+
onUpload: onUpload,
|
|
121
|
+
loading: loading,
|
|
122
|
+
setLoading: setLoading
|
|
110
123
|
}), /*#__PURE__*/React.createElement(Stack, {
|
|
111
124
|
direction: 'row',
|
|
112
125
|
alignItems: 'center',
|
|
@@ -155,7 +168,7 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
155
168
|
onClick: function onClick() {
|
|
156
169
|
return setDisplayMode('preview');
|
|
157
170
|
}
|
|
158
|
-
}, "\u9884\u89C8\u6A21\u5F0F"), /*#__PURE__*/React.createElement(Box, {
|
|
171
|
+
}, "\u9884\u89C8\u6A21\u5F0F"), splitMode && /*#__PURE__*/React.createElement(Box, {
|
|
159
172
|
className: displayMode === 'split' ? 'md-display-mode-active' : 'md-display-mode',
|
|
160
173
|
sx: {
|
|
161
174
|
px: 1,
|
|
@@ -194,8 +207,9 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
194
207
|
onChange: onChange,
|
|
195
208
|
name: "project-doc-editor",
|
|
196
209
|
wrapEnabled: true,
|
|
210
|
+
readOnly: loading,
|
|
197
211
|
showPrintMargin: false,
|
|
198
|
-
placeholder: MARKDOWN_EDITOR_PLACEHOLDER,
|
|
212
|
+
placeholder: placeholder || MARKDOWN_EDITOR_PLACEHOLDER,
|
|
199
213
|
fontSize: 16,
|
|
200
214
|
editorProps: {
|
|
201
215
|
$blockScrolling: true
|
|
@@ -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(
|
|
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;
|
|
@@ -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, "
|
|
4
|
+
}) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "key" | "editor">, any>;
|
package/dist/index.css
CHANGED
|
@@ -179,10 +179,11 @@
|
|
|
179
179
|
.tiptap.ProseMirror ul[data-type='taskList'] li {
|
|
180
180
|
align-items: flex-start;
|
|
181
181
|
display: flex;
|
|
182
|
+
flex-direction: row;
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
.tiptap.ProseMirror ul[data-type='taskList'] li>label {
|
|
185
|
-
flex: 0
|
|
186
|
+
flex-shrink: 0;
|
|
186
187
|
user-select: none;
|
|
187
188
|
margin-right: 8px;
|
|
188
189
|
height: 28px;
|
|
@@ -192,7 +193,7 @@
|
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
.tiptap.ProseMirror ul[data-type='taskList'] li>div {
|
|
195
|
-
flex: 1
|
|
196
|
+
flex-grow: 1;
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
.tiptap.ProseMirror ul[data-type='taskList'] li[data-checked='true']>div {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctzhian/tiptap",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.19",
|
|
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.
|
|
85
|
-
"@tiptap/extension-bubble-menu": "^3.10.
|
|
86
|
-
"@tiptap/extension-code": "^3.10.
|
|
87
|
-
"@tiptap/extension-code-block-lowlight": "^3.10.
|
|
88
|
-
"@tiptap/extension-details": "^3.10.
|
|
89
|
-
"@tiptap/extension-drag-handle-react": "^3.10.
|
|
90
|
-
"@tiptap/extension-emoji": "^3.10.
|
|
91
|
-
"@tiptap/extension-file-handler": "^3.10.
|
|
92
|
-
"@tiptap/extension-highlight": "^3.10.
|
|
93
|
-
"@tiptap/extension-horizontal-rule": "^3.10.
|
|
94
|
-
"@tiptap/extension-image": "^3.10.
|
|
95
|
-
"@tiptap/extension-invisible-characters": "^3.10.
|
|
96
|
-
"@tiptap/extension-link": "^3.10.
|
|
97
|
-
"@tiptap/extension-list": "^3.10.
|
|
98
|
-
"@tiptap/extension-mathematics": "^3.10.
|
|
99
|
-
"@tiptap/extension-mention": "^3.10.
|
|
100
|
-
"@tiptap/extension-subscript": "^3.10.
|
|
101
|
-
"@tiptap/extension-superscript": "^3.10.
|
|
102
|
-
"@tiptap/extension-table": "^3.10.
|
|
103
|
-
"@tiptap/extension-table-of-contents": "^3.10.
|
|
104
|
-
"@tiptap/extension-text-align": "^3.10.
|
|
105
|
-
"@tiptap/extension-text-style": "^3.10.
|
|
106
|
-
"@tiptap/extension-unique-id": "^3.10.
|
|
107
|
-
"@tiptap/extension-youtube": "^3.10.
|
|
108
|
-
"@tiptap/extensions": "^3.10.
|
|
109
|
-
"@tiptap/html": "^3.10.
|
|
110
|
-
"@tiptap/markdown": "^3.10.
|
|
111
|
-
"@tiptap/pm": "^3.10.
|
|
112
|
-
"@tiptap/react": "^3.10.
|
|
113
|
-
"@tiptap/starter-kit": "^3.10.
|
|
114
|
-
"@tiptap/static-renderer": "^3.10.
|
|
115
|
-
"@tiptap/suggestion": "^3.10.
|
|
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",
|