@ctzhian/tiptap 1.6.2 → 1.6.3

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.
@@ -5,7 +5,6 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
5
5
  import { Editor, EditorThemeProvider, EditorToolbar, useTiptap } from "./..";
6
6
  import { Box } from '@mui/material';
7
7
  import React from 'react';
8
- import { AiGenerate2Icon } from "../component/Icons";
9
8
  import "../index.css";
10
9
  var Reader = function Reader() {
11
10
  var _useTiptap = useTiptap({
@@ -15,17 +14,13 @@ var Reader = function Reader() {
15
14
  console.log(editor.getHTML());
16
15
  editor.commands.setContent(editor.getHTML());
17
16
  },
18
- onCreate: function onCreate(_ref) {
19
- var currentEditor = _ref.editor;
20
- currentEditor.commands.setAiWriting(true);
21
- },
22
17
  onAiWritingGetSuggestion: function () {
23
- var _onAiWritingGetSuggestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
18
+ var _onAiWritingGetSuggestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
24
19
  var prefix, suffix;
25
20
  return _regeneratorRuntime().wrap(function _callee$(_context) {
26
21
  while (1) switch (_context.prev = _context.next) {
27
22
  case 0:
28
- prefix = _ref2.prefix, suffix = _ref2.suffix;
23
+ prefix = _ref.prefix, suffix = _ref.suffix;
29
24
  console.log('onAiWritingGetSuggestion', prefix, suffix);
30
25
  return _context.abrupt("return", new Promise(function (resolve) {
31
26
  resolve(['this is a default suggestion.', 'we are good.', 'what is your name?', 'how are you?', 'what is your favorite color?', 'what is your favorite food?', 'what is your favorite animal?', 'what is your favorite book?', 'what is your favorite movie?', 'what is your favorite song?', 'what is your favorite artist?', 'what is your favorite band?', 'what is your favorite city?', 'what is your favorite country?', 'what is your favorite sport?'][Math.floor(Math.random() * 10)]);
@@ -43,12 +38,12 @@ var Reader = function Reader() {
43
38
  }(),
44
39
  // onTocUpdate: handleTocUpdate,
45
40
  onMentionFilter: function () {
46
- var _onMentionFilter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
41
+ var _onMentionFilter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
47
42
  var query;
48
43
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
49
44
  while (1) switch (_context2.prev = _context2.next) {
50
45
  case 0:
51
- query = _ref3.query;
46
+ query = _ref2.query;
52
47
  return _context2.abrupt("return", new Promise(function (resolve) {
53
48
  resolve(['Winona Ryder', 'Molly Ringwald', 'Ally Sheedy', 'Debbie Harry', 'Olivia Newton-John', 'Elton John', 'Michael J. Fox', 'Axl Rose', 'Emilio Estevez', 'Ralph Macchio', 'Rob Lowe', 'Jennifer Grey'].filter(function (item) {
54
49
  return item.toLowerCase().startsWith(query.toLowerCase());
@@ -125,19 +120,7 @@ var Reader = function Reader() {
125
120
  marginBottom: '30px'
126
121
  }
127
122
  }, /*#__PURE__*/React.createElement(EditorToolbar, {
128
- editor: editor,
129
- menuInToolbarMore: [{
130
- id: 'ai',
131
- icon: /*#__PURE__*/React.createElement(AiGenerate2Icon, {
132
- sx: {
133
- fontSize: '1rem'
134
- }
135
- }),
136
- onClick: function onClick() {
137
- alert('ai');
138
- },
139
- label: 'AI 文本润色'
140
- }]
123
+ editor: editor
141
124
  })), /*#__PURE__*/React.createElement(Box, {
142
125
  sx: {
143
126
  '.tiptap': {
@@ -149,31 +132,7 @@ var Reader = function Reader() {
149
132
  }
150
133
  }
151
134
  }, /*#__PURE__*/React.createElement(Editor, {
152
- editor: editor,
153
- menuInDragHandle: [{
154
- label: '文本润色',
155
- key: 'ai',
156
- icon: /*#__PURE__*/React.createElement(AiGenerate2Icon, {
157
- sx: {
158
- fontSize: '1rem'
159
- }
160
- }),
161
- onClick: function onClick() {
162
- alert('ai');
163
- }
164
- }],
165
- menuInBubbleMenu: [{
166
- label: '文本润色',
167
- key: 'ai',
168
- icon: /*#__PURE__*/React.createElement(AiGenerate2Icon, {
169
- sx: {
170
- fontSize: '1rem'
171
- }
172
- }),
173
- onClick: function onClick() {
174
- alert('ai');
175
- }
176
- }]
135
+ editor: editor
177
136
  }))));
178
137
  };
179
138
  export default Reader;
@@ -1,3 +1,7 @@
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 _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; }
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); } }
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); }); }; }
1
5
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
6
  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."); }
3
7
  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); }
@@ -6,9 +10,8 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
11
  import { Box, Divider, Stack } from '@mui/material';
8
12
  import React, { useEffect, useState } from 'react';
9
- import { ArrowGoBackLineIcon, ArrowGoForwardLineIcon, BoldIcon, DoubleQuotesLIcon, Information2LineIcon, ItalicIcon, LinkIcon, MenuFold2FillIcon, StrikethroughIcon, Table2Icon, UnderlineIcon, WindowFillIcon } from "../component/Icons";
10
- import { EditorAlignSelect, EditorCode, EditorFontBgColor, EditorFontColor, EditorFontSize, EditorHeading, EditorInsert, EditorListSelect, EditorMath, EditorMore, EditorScript, EditorVerticalAlignSelect, ToolbarItem } from "../component/Toolbar";
11
- import TableSizePicker from "../component/Toolbar/TableSizePicker";
13
+ import { AiGenerate2Icon, ArrowGoBackLineIcon, ArrowGoForwardLineIcon, BoldIcon, EraserLineIcon, ItalicIcon, LinkIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, UnderlineIcon } from "../component/Icons";
14
+ import { EditorAlignSelect, EditorFontBgColor, EditorFontColor, EditorFontSize, EditorHeading, EditorInsert, EditorListSelect, EditorMore, EditorVerticalAlignSelect, ToolbarItem } from "../component/Toolbar";
12
15
  var EditorToolbar = function EditorToolbar(_ref) {
13
16
  var editor = _ref.editor,
14
17
  menuInToolbarMore = _ref.menuInToolbarMore;
@@ -26,7 +29,8 @@ var EditorToolbar = function EditorToolbar(_ref) {
26
29
  table: false,
27
30
  link: false,
28
31
  alert: false,
29
- iframe: false
32
+ iframe: false,
33
+ aiWriting: false
30
34
  }),
31
35
  _useState2 = _slicedToArray(_useState, 2),
32
36
  active = _useState2[0],
@@ -46,7 +50,8 @@ var EditorToolbar = function EditorToolbar(_ref) {
46
50
  table: editor.isActive('table'),
47
51
  link: editor.isActive('link'),
48
52
  alert: editor.isActive('alert'),
49
- iframe: editor.isActive('iframe')
53
+ iframe: editor.isActive('iframe'),
54
+ aiWriting: editor.storage.aiWriting.enabled
50
55
  });
51
56
  };
52
57
  useEffect(function () {
@@ -90,7 +95,30 @@ var EditorToolbar = function EditorToolbar(_ref) {
90
95
  }
91
96
  }
92
97
  }
93
- }, /*#__PURE__*/React.createElement(ToolbarItem, {
98
+ }, /*#__PURE__*/React.createElement(EditorInsert, {
99
+ editor: editor
100
+ }), editor.options.extensions.find(function (it) {
101
+ return it.name === 'aiWriting';
102
+ }) && /*#__PURE__*/React.createElement(ToolbarItem, {
103
+ text: 'AI 伴写',
104
+ icon: /*#__PURE__*/React.createElement(AiGenerate2Icon, {
105
+ sx: {
106
+ fontSize: '1rem'
107
+ }
108
+ }),
109
+ onClick: function onClick() {
110
+ return editor.commands.setAiWriting(!active.aiWriting);
111
+ },
112
+ className: active.aiWriting ? 'tool-active' : ''
113
+ }), /*#__PURE__*/React.createElement(Divider, {
114
+ orientation: "vertical",
115
+ flexItem: true,
116
+ sx: {
117
+ mx: 0.5,
118
+ height: 20,
119
+ alignSelf: 'center'
120
+ }
121
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
94
122
  tip: '撤销',
95
123
  shortcutKey: ['ctrl', 'Z'],
96
124
  icon: /*#__PURE__*/React.createElement(ArrowGoBackLineIcon, {
@@ -114,6 +142,43 @@ var EditorToolbar = function EditorToolbar(_ref) {
114
142
  return editor.chain().focus().redo().run();
115
143
  },
116
144
  disabled: !active.redo
145
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
146
+ tip: '清除格式',
147
+ icon: /*#__PURE__*/React.createElement(EraserLineIcon, {
148
+ sx: {
149
+ fontSize: '1rem'
150
+ }
151
+ }),
152
+ disabled: editor.state.selection.empty,
153
+ onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
154
+ var tr, currentNode, empty, content;
155
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
156
+ while (1) switch (_context.prev = _context.next) {
157
+ case 0:
158
+ if (!editor.state.selection.empty) {
159
+ tr = editor.state.tr;
160
+ currentNode = editor.state.selection.content();
161
+ empty = currentNode.content.size === 0;
162
+ if (!empty) {
163
+ content = currentNode.content.content;
164
+ if (content && content.length > 0) {
165
+ tr.doc.nodesBetween(editor.state.selection.from, editor.state.selection.to, function (node, pos) {
166
+ if (!node.isInline) return true;
167
+ node.marks.forEach(function (mark) {
168
+ tr.removeMark(pos, pos + node.nodeSize, mark.type);
169
+ });
170
+ return true;
171
+ });
172
+ }
173
+ }
174
+ editor.view.dispatch(tr);
175
+ }
176
+ case 1:
177
+ case "end":
178
+ return _context.stop();
179
+ }
180
+ }, _callee);
181
+ }))
117
182
  }), /*#__PURE__*/React.createElement(Divider, {
118
183
  orientation: "vertical",
119
184
  flexItem: true,
@@ -126,38 +191,6 @@ var EditorToolbar = function EditorToolbar(_ref) {
126
191
  editor: editor
127
192
  }), /*#__PURE__*/React.createElement(EditorFontSize, {
128
193
  editor: editor
129
- }), /*#__PURE__*/React.createElement(EditorListSelect, {
130
- editor: editor
131
- }), /*#__PURE__*/React.createElement(EditorAlignSelect, {
132
- editor: editor
133
- }), /*#__PURE__*/React.createElement(EditorVerticalAlignSelect, {
134
- editor: editor
135
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
136
- tip: '引用块',
137
- shortcutKey: ['ctrl', 'shift', 'B'],
138
- icon: /*#__PURE__*/React.createElement(DoubleQuotesLIcon, {
139
- sx: {
140
- fontSize: '1rem'
141
- }
142
- }),
143
- onClick: function onClick() {
144
- return editor.chain().focus().toggleBlockquote().run();
145
- },
146
- className: active.quote ? 'tool-active' : ''
147
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
148
- tip: '警告提示',
149
- icon: /*#__PURE__*/React.createElement(Information2LineIcon, {
150
- sx: {
151
- fontSize: '1rem'
152
- }
153
- }),
154
- onClick: function onClick() {
155
- return editor.chain().focus().toggleAlert({
156
- type: 'icon',
157
- variant: 'info'
158
- }).run();
159
- },
160
- className: active.alert ? 'tool-active' : ''
161
194
  }), /*#__PURE__*/React.createElement(Divider, {
162
195
  orientation: "vertical",
163
196
  flexItem: true,
@@ -214,16 +247,30 @@ var EditorToolbar = function EditorToolbar(_ref) {
214
247
  return editor.chain().focus().toggleUnderline().run();
215
248
  },
216
249
  className: active.underline ? 'tool-active' : ''
217
- }), /*#__PURE__*/React.createElement(Divider, {
218
- orientation: "vertical",
219
- flexItem: true,
220
- sx: {
221
- mx: 0.5,
222
- height: 20,
223
- alignSelf: 'center'
224
- }
225
- }), /*#__PURE__*/React.createElement(EditorScript, {
226
- editor: editor
250
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
251
+ tip: '上标',
252
+ shortcutKey: ['ctrl', '.'],
253
+ icon: /*#__PURE__*/React.createElement(SuperscriptIcon, {
254
+ sx: {
255
+ fontSize: '1rem'
256
+ }
257
+ }),
258
+ onClick: function onClick() {
259
+ return editor.chain().focus().toggleSuperscript().run();
260
+ },
261
+ className: active.superscript ? 'tool-active' : ''
262
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
263
+ tip: '下标',
264
+ shortcutKey: ['ctrl', ','],
265
+ icon: /*#__PURE__*/React.createElement(SubscriptIcon, {
266
+ sx: {
267
+ fontSize: '1rem'
268
+ }
269
+ }),
270
+ onClick: function onClick() {
271
+ return editor.chain().focus().toggleSubscript().run();
272
+ },
273
+ className: active.subscript ? 'tool-active' : ''
227
274
  }), /*#__PURE__*/React.createElement(EditorFontColor, {
228
275
  editor: editor
229
276
  }), /*#__PURE__*/React.createElement(EditorFontBgColor, {
@@ -236,6 +283,8 @@ var EditorToolbar = function EditorToolbar(_ref) {
236
283
  height: 20,
237
284
  alignSelf: 'center'
238
285
  }
286
+ }), /*#__PURE__*/React.createElement(EditorListSelect, {
287
+ editor: editor
239
288
  }), /*#__PURE__*/React.createElement(ToolbarItem, {
240
289
  tip: '链接',
241
290
  shortcutKey: ['ctrl', '1'],
@@ -255,59 +304,10 @@ var EditorToolbar = function EditorToolbar(_ref) {
255
304
  }).run();
256
305
  },
257
306
  className: active.link ? 'tool-active' : ''
258
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
259
- tip: '折叠块',
260
- shortcutKey: ['ctrl', '8'],
261
- icon: /*#__PURE__*/React.createElement(MenuFold2FillIcon, {
262
- sx: {
263
- fontSize: '1rem'
264
- }
265
- }),
266
- onClick: function onClick() {
267
- if (!active.details) {
268
- editor.chain().focus().setDetails().run();
269
- } else {
270
- editor.chain().focus().unsetDetails().run();
271
- }
272
- },
273
- className: active.details ? 'tool-active' : ''
274
- }), /*#__PURE__*/React.createElement(EditorCode, {
307
+ }), /*#__PURE__*/React.createElement(EditorAlignSelect, {
275
308
  editor: editor
276
- }), /*#__PURE__*/React.createElement(EditorMath, {
309
+ }), /*#__PURE__*/React.createElement(EditorVerticalAlignSelect, {
277
310
  editor: editor
278
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
279
- tip: '表格',
280
- shortcutKey: ['ctrl', '9'],
281
- icon: /*#__PURE__*/React.createElement(Table2Icon, {
282
- sx: {
283
- fontSize: '1rem'
284
- }
285
- }),
286
- className: active.table ? 'tool-active' : '',
287
- customComponent: /*#__PURE__*/React.createElement(TableSizePicker, {
288
- onConfirm: function onConfirm(cols, rows) {
289
- editor.chain().focus().insertTable({
290
- rows: rows,
291
- cols: cols,
292
- withHeaderRow: true
293
- }).run();
294
- }
295
- })
296
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
297
- tip: 'iframe',
298
- icon: /*#__PURE__*/React.createElement(WindowFillIcon, {
299
- sx: {
300
- fontSize: '1rem'
301
- }
302
- }),
303
- onClick: function onClick() {
304
- return editor.commands.setIframe({
305
- src: '',
306
- width: 760,
307
- height: 400
308
- });
309
- },
310
- className: active.iframe ? 'tool-active' : ''
311
311
  }), /*#__PURE__*/React.createElement(Divider, {
312
312
  orientation: "vertical",
313
313
  flexItem: true,
@@ -316,8 +316,6 @@ var EditorToolbar = function EditorToolbar(_ref) {
316
316
  height: 20,
317
317
  alignSelf: 'center'
318
318
  }
319
- }), /*#__PURE__*/React.createElement(EditorInsert, {
320
- editor: editor
321
319
  }), /*#__PURE__*/React.createElement(EditorMore, {
322
320
  more: menuInToolbarMore
323
321
  })));
@@ -17,7 +17,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
17
17
  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; }
18
18
  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; } }
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
- import { AddLineIcon, AlignBottomIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, AlignTopIcon, ArrowDownSLineIcon, AttachmentLineIcon, BrushLineIcon, DeleteLineIcon, DownloadLineIcon, DraggableIcon, FontSizeIcon, FormatClearIcon, H1Icon, H2Icon, H3Icon, ImageLineIcon, IndentDecreaseIcon, IndentIncreaseIcon, Information2LineIcon, ListCheck3Icon, ListOrdered2Icon, ListUnorderedIcon, MovieLineIcon, Music2LineIcon, QuoteTextIcon, Repeat2LineIcon, ScissorsCutLineIcon, SeparatorIcon, TextIcon, TextWrapIcon } from "../Icons";
20
+ import { AddLineIcon, AlignBottomIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, AlignTopIcon, ArrowDownSLineIcon, AttachmentLineIcon, BrushLineIcon, DeleteLineIcon, DownloadLineIcon, DraggableIcon, EraserLineIcon, FileCopyLineIcon, FontSizeIcon, H1Icon, H2Icon, H3Icon, ImageLineIcon, IndentDecreaseIcon, IndentIncreaseIcon, Information2LineIcon, ListCheck3Icon, ListOrdered2Icon, ListUnorderedIcon, MovieLineIcon, Music2LineIcon, QuoteTextIcon, Repeat2LineIcon, ScissorsCutLineIcon, SeparatorIcon, TextIcon, TextWrapIcon } from "../Icons";
21
21
  import { NODE_TYPE_LABEL, NodeTypeEnum } from "../../contants/enums";
22
22
  import { Box, Divider, Stack, Typography, useTheme } from '@mui/material';
23
23
  import DragHandle from '@tiptap/extension-drag-handle-react';
@@ -25,7 +25,6 @@ import { Fragment, Slice } from '@tiptap/pm/model';
25
25
  import { NodeSelection } from '@tiptap/pm/state';
26
26
  import React, { useCallback, useState } from 'react';
27
27
  import { convertNodeAt, downloadFiles, filterResourcesByType, getAllResources } from "../../util";
28
- import { FileCopyLineIcon } from "../Icons/file-copy-line-icon";
29
28
  import Menu from "../Menu";
30
29
  import { ToolbarItem } from "../Toolbar";
31
30
  var DragIcon = function DragIcon(_ref) {
@@ -314,6 +313,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
314
313
  }
315
314
  }
316
315
  }), currentNode ? /*#__PURE__*/React.createElement(Menu, {
316
+ width: 224,
317
317
  context: /*#__PURE__*/React.createElement(DragIcon, null),
318
318
  anchorOrigin: {
319
319
  vertical: 'bottom',
@@ -569,6 +569,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
569
569
  key: 'color',
570
570
  label: '颜色',
571
571
  maxHeight: 400,
572
+ width: 160,
572
573
  icon: /*#__PURE__*/React.createElement(BrushLineIcon, {
573
574
  sx: {
574
575
  fontSize: '1rem'
@@ -654,6 +655,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
654
655
  fontSize: '1rem'
655
656
  }
656
657
  }),
658
+ width: 100,
657
659
  minWidth: 100,
658
660
  maxHeight: 200,
659
661
  children: _toConsumableArray([10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60].map(function (it) {
@@ -678,6 +680,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
678
680
  }] : []), _toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.align ? [{
679
681
  key: 'align',
680
682
  label: '对齐方式',
683
+ width: 160,
681
684
  icon: /*#__PURE__*/React.createElement(AlignLeftIcon, {
682
685
  sx: {
683
686
  fontSize: '1rem'
@@ -833,6 +836,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
833
836
  }] : []), _toConsumableArray(currentNode !== null && currentNode !== void 0 && currentNode.convert ? [{
834
837
  label: '转换',
835
838
  key: 'convert',
839
+ width: 160,
836
840
  maxHeight: 400,
837
841
  icon: /*#__PURE__*/React.createElement(Repeat2LineIcon, {
838
842
  sx: {
@@ -1361,7 +1365,7 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
1361
1365
  }] : []))), _toConsumableArray(more ? more : []), _toConsumableArray(showFormat ? [{
1362
1366
  label: '文本格式化',
1363
1367
  key: 'format',
1364
- icon: /*#__PURE__*/React.createElement(FormatClearIcon, {
1368
+ icon: /*#__PURE__*/React.createElement(EraserLineIcon, {
1365
1369
  sx: {
1366
1370
  fontSize: '1rem'
1367
1371
  }
@@ -0,0 +1,6 @@
1
+ import { SvgIconProps } from "@mui/material";
2
+ import * as React from "react";
3
+ export declare const AddCircleFillIcon: {
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 AddCircleFillIcon = function AddCircleFillIcon(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: "M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM11 11H7V13H11V17H13V13H17V11H13V7H11V11Z"
11
+ }));
12
+ };
13
+ AddCircleFillIcon.displayName = 'icon-add-circle-fill';
@@ -0,0 +1,6 @@
1
+ import { SvgIconProps } from "@mui/material";
2
+ import * as React from "react";
3
+ export declare const EraserLineIcon: {
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 EraserLineIcon = function EraserLineIcon(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: "M8.58564 8.85449L3.63589 13.8042L8.83021 18.9985L9.99985 18.9978V18.9966H11.1714L14.9496 15.2184L8.58564 8.85449ZM9.99985 7.44027L16.3638 13.8042L19.1922 10.9758L12.8283 4.61185L9.99985 7.44027ZM13.9999 18.9966H20.9999V20.9966H11.9999L8.00229 20.9991L1.51457 14.5113C1.12405 14.1208 1.12405 13.4877 1.51457 13.0971L12.1212 2.49053C12.5117 2.1 13.1449 2.1 13.5354 2.49053L21.3136 10.2687C21.7041 10.6592 21.7041 11.2924 21.3136 11.6829L13.9999 18.9966Z"
11
+ }));
12
+ };
13
+ EraserLineIcon.displayName = 'icon-eraser-line';
@@ -0,0 +1,6 @@
1
+ import { SvgIconProps } from "@mui/material";
2
+ import * as React from "react";
3
+ export declare const Folder2LineIcon: {
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 Folder2LineIcon = function Folder2LineIcon(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: "M12.4142 5H21C21.5523 5 22 5.44772 22 6V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5ZM20 11H4V19H20V11ZM20 9V7H11.5858L9.58579 5H4V9H20Z"
11
+ }));
12
+ };
13
+ Folder2LineIcon.displayName = 'icon-folder-2-line';
@@ -1,3 +1,4 @@
1
+ export { AddCircleFillIcon } from './add-circle-fill-icon';
1
2
  export { AddLineIcon } from './add-line-icon';
2
3
  export { AiGenerate2Icon } from './ai-generate-2-icon';
3
4
  export { AiGenerateTextIcon } from './ai-generate-text-icon';
@@ -36,11 +37,13 @@ export { DoubleQuotesLIcon } from './double-quotes-l-icon';
36
37
  export { DownloadLineIcon } from './download-line-icon';
37
38
  export { DraggableIcon } from './draggable-icon';
38
39
  export { EditBoxLineIcon } from './edit-box-line-icon';
40
+ export { EraserLineIcon } from './eraser-line-icon';
39
41
  export { ErrorWarningFillIcon } from './error-warning-fill-icon';
40
42
  export { ExportLineIcon } from './export-line-icon';
41
43
  export { FileCopyLineIcon } from './file-copy-line-icon';
42
44
  export { FileUploadLineIcon } from './file-upload-line-icon';
43
45
  export { FlowChartIcon } from './flow-chart-icon';
46
+ export { Folder2LineIcon } from './folder-2-line-icon';
44
47
  export { FontColorIcon } from './font-color-icon';
45
48
  export { FontFamilyIcon } from './font-family-icon';
46
49
  export { FontSizeIcon } from './font-size-icon';
@@ -1,6 +1,7 @@
1
1
  // 此文件由脚本自动生成
2
2
  // 导出所有图标组件
3
3
 
4
+ export { AddCircleFillIcon } from "./add-circle-fill-icon";
4
5
  export { AddLineIcon } from "./add-line-icon";
5
6
  export { AiGenerate2Icon } from "./ai-generate-2-icon";
6
7
  export { AiGenerateTextIcon } from "./ai-generate-text-icon";
@@ -39,11 +40,13 @@ export { DoubleQuotesLIcon } from "./double-quotes-l-icon";
39
40
  export { DownloadLineIcon } from "./download-line-icon";
40
41
  export { DraggableIcon } from "./draggable-icon";
41
42
  export { EditBoxLineIcon } from "./edit-box-line-icon";
43
+ export { EraserLineIcon } from "./eraser-line-icon";
42
44
  export { ErrorWarningFillIcon } from "./error-warning-fill-icon";
43
45
  export { ExportLineIcon } from "./export-line-icon";
44
46
  export { FileCopyLineIcon } from "./file-copy-line-icon";
45
47
  export { FileUploadLineIcon } from "./file-upload-line-icon";
46
48
  export { FlowChartIcon } from "./flow-chart-icon";
49
+ export { Folder2LineIcon } from "./folder-2-line-icon";
47
50
  export { FontColorIcon } from "./font-color-icon";
48
51
  export { FontFamilyIcon } from "./font-family-icon";
49
52
  export { FontSizeIcon } from "./font-size-icon";
@@ -3,6 +3,7 @@ import { PopoverOrigin } from '@mui/material';
3
3
  import React from 'react';
4
4
  export interface NestedMenuListProps {
5
5
  list: MenuItem[];
6
+ width?: number;
6
7
  arrowIcon?: React.ReactNode;
7
8
  childrenProps?: {
8
9
  anchorOrigin?: PopoverOrigin;
@@ -15,6 +15,7 @@ import { Box, Popover, Stack } from '@mui/material';
15
15
  import React from 'react';
16
16
  var NestedList = function NestedList(_ref) {
17
17
  var list = _ref.list,
18
+ width = _ref.width,
18
19
  arrowIcon = _ref.arrowIcon,
19
20
  _ref$childrenProps = _ref.childrenProps,
20
21
  childrenProps = _ref$childrenProps === void 0 ? {
@@ -58,6 +59,7 @@ var NestedList = function NestedList(_ref) {
58
59
  className: "menu-select-list",
59
60
  sx: {
60
61
  minWidth: 160,
62
+ width: width,
61
63
  lineHeight: 1.625
62
64
  }
63
65
  }, list.map(function (item) {
@@ -104,13 +106,16 @@ var NestedList = function NestedList(_ref) {
104
106
  }
105
107
  }, childrenProps), /*#__PURE__*/React.createElement(Box, {
106
108
  className: "menu-select-sub-list",
107
- sx: _objectSpread(_objectSpread({
109
+ sx: _objectSpread(_objectSpread(_objectSpread({
108
110
  pointerEvents: 'auto',
109
111
  p: 0.5,
112
+ width: width,
110
113
  minWidth: 160,
111
114
  maxHeight: 360,
112
115
  overflow: 'auto'
113
- }, item.minWidth ? {
116
+ }, item.width ? {
117
+ width: item.width
118
+ } : {}), item.minWidth ? {
114
119
  minWidth: item.minWidth
115
120
  } : {}), item.maxHeight ? {
116
121
  maxHeight: item.maxHeight
@@ -10,6 +10,8 @@ import NestedList from "./NestedList";
10
10
  var Menu = function Menu(_ref) {
11
11
  var _ref$id = _ref.id,
12
12
  id = _ref$id === void 0 ? 'menu-select' : _ref$id,
13
+ _ref$width = _ref.width,
14
+ width = _ref$width === void 0 ? 160 : _ref$width,
13
15
  arrowIcon = _ref.arrowIcon,
14
16
  list = _ref.list,
15
17
  _ref$header = _ref.header,
@@ -75,6 +77,7 @@ var Menu = function Menu(_ref) {
75
77
  }, /*#__PURE__*/React.createElement(Box, {
76
78
  onClick: handleClose
77
79
  }, header), /*#__PURE__*/React.createElement(NestedList, {
80
+ width: width,
78
81
  list: list,
79
82
  arrowIcon: arrowIcon,
80
83
  childrenProps: childrenProps,