@ctzhian/tiptap 1.12.7 → 1.12.8

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.
@@ -152,7 +152,7 @@ var Reader = function Reader() {
152
152
  }
153
153
  return onUpload;
154
154
  }(),
155
- content: "<p>\u8FD9\u91CC\u662F\u6B63\u6587\u90E8\u5206\uFF0C\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A\u554A</p><p></p><h1 id=\"b8f46431-15cc-4d9a-823f-3b99a5048e9d\">\u8FD9\u662F\u4E00\u7EA7\u6807\u9898</h1><h2 id=\"ef598fd2-24f8-472f-bedc-a5e4e39e5373\">\u4E8C\u7EA7\u6807\u9898</h2><h3 id=\"2ea03e39-c201-49ae-9236-3acf23b14965\">\u4E09\u7EA7\u6807\u9898</h3><h4 id=\"9a0dd00d-e0b8-4ae4-9371-b6f2e49ce0af\">\u56DB\u7EA7\u6807\u9898</h4><p></p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li></ol></li></ol></li></ol></li><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u6709\u5E8F\u5217\u8868</p></li></ol><p></p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li></ul></li></ul></li></ul></li><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li><li><p>\u8FD9\u662F\u65E0\u5E8F\u5217\u8868</p></li></ul><p></p><ul data-type=\"taskList\"><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>\u4EFB\u52A1\u5217\u8868</p><ul data-type=\"taskList\"><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"true\"><label><input type=\"checkbox\" checked=\"checked\"><span></span></label><div><p>\u4EFB\u52A1\u5217\u8868</p></div></li><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>\u4EFB\u52A1\u5217\u8868</p></div></li></ul></div></li><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>\u4EFB\u52A1\u5217\u8868</p></div></li><li class=\"task-item\" data-type=\"taskItem\" data-checked=\"false\"><label><input type=\"checkbox\"><span></span></label><div><p>\u4EFB\u52A1\u5217\u8868</p></div></li></ul><p></p><blockquote><p>\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9</p><p>\u6362\u4E00\u6BB5\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9\uFF0C\u8FD9\u91CC\u662F\u5F15\u7528\u5185\u5BB9</p></blockquote><p></p><pre><code class=\"language-c\">#include &lt;stdio.h&gt;\n\nint main(int argc, char* argv[]) {\n return 0;\n}</code></pre><p></p><div data-id=\"alert_d89jtsekma\" data-variant=\"warning\" data-type=\"icon\" data-node=\"alert\"><p>\u8FD9\u91CC\u662F\u9AD8\u4EAE\u5757</p></div><div data-id=\"alert_y52bknyrhp\" data-variant=\"default\" data-type=\"icon\" data-node=\"alert\"><p></p></div><div data-id=\"alert_8kccvrutm1b\" data-variant=\"error\" data-type=\"icon\" data-node=\"alert\"><p><span style=\"color: rgb(254, 69, 69);\">\u8FD9\u91CC\u662F\u9AD8\u4EAE\u5757</span></p></div><p></p><p><a target=\"_blank\" type=\"text\" href=\"\u641C\u7D22\" title=\"\u8FD9\u662F\u94FE\u63A5\">\u8FD9\u662F\u94FE\u63A5</a></p><p><a target=\"_blank\" type=\"text\" href=\"http://a123123\" title=\"http://a123123\">http://a123123</a></p><a target=\"_blank\" type=\"block\" href=\"http://localhost:8000/components/%E6%90%9C%E7%B4%A2\" title=\"\u8FD9\u662F\u94FE\u63A5\">\u8FD9\u662F\u94FE\u63A5</a><hr class=\"custom-horizontal-rule\"><p>\u8FD9\u662F\u5206\u5272\u7EBF</p><hr class=\"custom-horizontal-rule\"><p></p><p><span data-latex=\"a, b, c \neq { { a}, b, c}\" data-type=\"inline-math\"></span></p><div data-latex=\"\frac{int_{0}^{\frac{pi}{2}}}{sum_{i=1}^{n}} = 1\" data-type=\"block-math\"></div><p></p><p style=\"text-align: center;\"><img src=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" width=\"375\"></p><p style=\"text-align: left;\"></p><div data-tag=\"attachment\" url=\"\" title=\"\" size=\"0\" data-url=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" data-title=\"4174c1ae-6d06-4287-a184-0b24c7c698fd.png\" data-size=\"193.47 KB\"></div><div data-tag=\"attachment\" url=\"\" title=\"\" size=\"0\" data-url=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" data-title=\"\u9ED8\u8BA4\u77E5\u8BC6\u5E93222.lakebook\" data-size=\"170.5 KB\"></div><p style=\"text-align: left;\"></p><div class=\"tableWrapper\"><table style=\"min-width: 400px;\"><colgroup><col style=\"min-width: 100px;\"><col style=\"min-width: 100px;\"><col style=\"min-width: 100px;\"><col style=\"min-width: 100px;\"></colgroup><tbody><tr class=\"table-row\"><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>\u963F\u65AF\u987F</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>\u5F97\u5230\u7684</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>\u4E0A\u4E0A\u8272</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>\u53EF\u63A7\u54C7</p></th></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p><img src=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" width=\"100\"></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td></tr></tbody></table></div><p></p><p>\u4E30\u5C0F\u5B66\u6821\u56ED\u751F\u6D3B<strong>\u52A0\u918B\u52A0\u918B</strong><em>\u5199\u9898\u5199\u9898</em></p>"
155
+ content: ''
156
156
  }),
157
157
  editor = _useTiptap.editor;
158
158
  return /*#__PURE__*/React.createElement(EditorThemeProvider, {
@@ -1,9 +1,15 @@
1
- import { ActionDropdown, HoverPopover } from "../../../component";
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { FloatingPopover } from "../../../component";
2
8
  import { CheckboxCircleFillIcon, CloseCircleFillIcon, ErrorWarningFillIcon, Information2FillIcon, ScrollToBottomLineIcon, TextIcon, UserSmileFillIcon } from "../../../component/Icons";
3
9
  import { ToolbarItem } from "../../../component/Toolbar";
4
10
  import { Box, Divider, Stack } from '@mui/material';
5
11
  import { NodeViewContent, NodeViewWrapper } from '@tiptap/react';
6
- import React, { useMemo, useRef } from 'react';
12
+ import React, { useMemo, useRef, useState } from 'react';
7
13
  var VARIANT_DATA = {
8
14
  info: {
9
15
  icon: /*#__PURE__*/React.createElement(Information2FillIcon, {
@@ -54,11 +60,62 @@ var AlertView = function AlertView(_ref) {
54
60
  selected = _ref.selected;
55
61
  var attrs = node.attrs;
56
62
  var containerRef = useRef(null);
63
+ var _useState = useState(null),
64
+ _useState2 = _slicedToArray(_useState, 2),
65
+ anchorEl = _useState2[0],
66
+ setAnchorEl = _useState2[1];
57
67
  var showIcon = attrs.type !== 'text';
58
68
  var variantData = useMemo(function () {
59
69
  return VARIANT_DATA[attrs.variant || 'info'];
60
70
  }, [attrs.variant]);
61
- var operationMenu = /*#__PURE__*/React.createElement(Stack, {
71
+ var handleShowOperationPopover = function handleShowOperationPopover(event) {
72
+ return setAnchorEl(event.currentTarget);
73
+ };
74
+ var handleCloseOperationPopover = function handleCloseOperationPopover() {
75
+ return setAnchorEl(null);
76
+ };
77
+ return /*#__PURE__*/React.createElement(NodeViewWrapper, {
78
+ ref: containerRef,
79
+ className: "alert-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
80
+ "data-drag-handle": true,
81
+ as: 'div',
82
+ style: {
83
+ marginLeft: (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.indent ? node.attrs.indent * 32 : undefined,
84
+ border: '1px solid',
85
+ borderColor: variantData.color,
86
+ // color: attrs.variant === 'default' ? 'var(--mui-palette-text-primary)' : variantData.color,
87
+ borderRadius: '10px',
88
+ padding: '12px 16px',
89
+ lineHeight: 1.625,
90
+ display: 'flex',
91
+ alignItems: 'flex-start',
92
+ gap: '16px',
93
+ background: attrs.variant === 'default' ? 'var(--mui-palette-background-paper3)' : "color-mix(in srgb, ".concat(variantData.color, " 10%, transparent)")
94
+ },
95
+ onClick: handleShowOperationPopover
96
+ }, showIcon && /*#__PURE__*/React.createElement(Box, {
97
+ sx: {
98
+ pt: '2px',
99
+ lineHeight: 1,
100
+ color: attrs.variant === 'default' ? 'text.disabled' : variantData.color
101
+ }
102
+ }, variantData.icon), /*#__PURE__*/React.createElement(Box, {
103
+ sx: {
104
+ flex: 1,
105
+ width: 0,
106
+ 'code': {
107
+ borderColor: attrs.variant === 'default' ? '' : "color-mix(in srgb, ".concat(variantData.color, " 30%, transparent) !important"),
108
+ bgcolor: attrs.variant === 'default' ? '' : "color-mix(in srgb, ".concat(variantData.color, " 10%, transparent) !important")
109
+ }
110
+ }
111
+ }, /*#__PURE__*/React.createElement(NodeViewContent, {
112
+ as: 'div'
113
+ })), editor.isEditable && /*#__PURE__*/React.createElement(FloatingPopover, {
114
+ open: Boolean(anchorEl),
115
+ anchorEl: anchorEl,
116
+ onClose: handleCloseOperationPopover,
117
+ placement: "top"
118
+ }, /*#__PURE__*/React.createElement(Stack, {
62
119
  direction: 'row',
63
120
  alignItems: 'center',
64
121
  sx: {
@@ -143,78 +200,33 @@ var AlertView = function AlertView(_ref) {
143
200
  alignSelf: 'center',
144
201
  borderColor: 'divider'
145
202
  }
146
- }), /*#__PURE__*/React.createElement(ActionDropdown, {
147
- list: [{
148
- key: 'text',
149
- label: '文字',
150
- icon: /*#__PURE__*/React.createElement(TextIcon, {
151
- sx: {
152
- fontSize: '1rem'
153
- }
154
- }),
155
- onClick: function onClick() {
156
- return updateAttributes({
157
- type: 'text'
158
- });
159
- }
160
- }, {
161
- key: 'icon',
162
- label: '图标文字',
163
- icon: /*#__PURE__*/React.createElement(ScrollToBottomLineIcon, {
164
- sx: {
165
- transform: 'rotate(90deg)',
166
- fontSize: '1rem'
167
- }
168
- }),
169
- onClick: function onClick() {
170
- return updateAttributes({
171
- type: 'icon'
172
- });
203
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
204
+ icon: /*#__PURE__*/React.createElement(TextIcon, {
205
+ sx: {
206
+ fontSize: '1rem'
173
207
  }
174
- }],
175
- selected: attrs.type || 'icon',
176
- tip: "\u7C7B\u578B"
177
- }));
178
- return /*#__PURE__*/React.createElement(HoverPopover, {
179
- actions: operationMenu,
180
- hoverDelay: 500,
181
- closeDelay: 300,
182
- placement: "top",
183
- disabled: !editor.isEditable
184
- }, /*#__PURE__*/React.createElement(NodeViewWrapper, {
185
- ref: containerRef,
186
- className: "alert-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
187
- "data-drag-handle": true,
188
- as: 'div',
189
- style: {
190
- marginLeft: (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.indent ? node.attrs.indent * 32 : undefined,
191
- border: '1px solid',
192
- borderColor: "color-mix(in srgb, ".concat(variantData.color, " 50%, transparent)"),
193
- borderRadius: '10px',
194
- padding: '16px',
195
- lineHeight: 1.625,
196
- display: 'flex',
197
- alignItems: 'flex-start',
198
- gap: '16px',
199
- background: attrs.variant === 'default' ? 'var(--mui-palette-background-paper3)' : "color-mix(in srgb, ".concat(variantData.color, " 10%, transparent)")
200
- }
201
- }, showIcon && /*#__PURE__*/React.createElement(Box, {
202
- sx: {
203
- pt: '2px',
204
- lineHeight: 1,
205
- color: attrs.variant === 'default' ? 'text.disabled' : variantData.color
206
- }
207
- }, variantData.icon), /*#__PURE__*/React.createElement(Box, {
208
- sx: {
209
- flex: 1,
210
- width: 0,
211
- 'code': {
212
- borderColor: attrs.variant === 'default' ? '' : "color-mix(in srgb, ".concat(variantData.color, " 30%, transparent) !important"),
213
- bgcolor: attrs.variant === 'default' ? '' : "color-mix(in srgb, ".concat(variantData.color, " 10%, transparent) !important")
208
+ }),
209
+ tip: "\u7EAF\u6587\u5B57",
210
+ onClick: function onClick() {
211
+ return updateAttributes({
212
+ type: 'text'
213
+ });
214
+ },
215
+ className: attrs.type === 'text' ? 'tool-active' : ''
216
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
217
+ icon: /*#__PURE__*/React.createElement(ScrollToBottomLineIcon, {
218
+ sx: {
219
+ transform: 'rotate(90deg)',
220
+ fontSize: '1rem'
214
221
  }
215
- }
216
- }, /*#__PURE__*/React.createElement(NodeViewContent, {
217
- as: 'div'
222
+ }),
223
+ tip: "\u56FE\u6807\u6587\u5B57",
224
+ onClick: function onClick() {
225
+ return updateAttributes({
226
+ type: 'icon'
227
+ });
228
+ },
229
+ className: attrs.type === 'icon' ? 'tool-active' : ''
218
230
  }))));
219
231
  };
220
232
  export default AlertView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "1.12.7",
3
+ "version": "1.12.8",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",