@ctzhian/tiptap 1.6.15 → 1.6.17

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.
@@ -7,11 +7,9 @@ import 'react-photo-view/dist/react-photo-view.css';
7
7
  var ReadonlyImage = function ReadonlyImage(_ref) {
8
8
  var attrs = _ref.attrs;
9
9
  return /*#__PURE__*/React.createElement(NodeViewWrapper, {
10
- className: "image-wrapper",
11
- contentEditable: false
10
+ className: "image-wrapper"
12
11
  }, /*#__PURE__*/React.createElement(Box, {
13
12
  component: 'span',
14
- contentEditable: false,
15
13
  sx: {
16
14
  position: 'relative',
17
15
  display: 'inline-block',
@@ -183,7 +183,6 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
183
183
  updateAttributes({
184
184
  src: editSrc.trim(),
185
185
  width: currentWidth
186
- // error: true,
187
186
  });
188
187
  setEditSrc(editSrc.trim());
189
188
  }
@@ -191,6 +190,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
191
190
  };
192
191
  useEffect(function () {
193
192
  if (isDragging) {
193
+ setAnchorEl(null);
194
194
  document.addEventListener('mousemove', handleMouseMove);
195
195
  document.addEventListener('mouseup', handleMouseUp);
196
196
  return function () {
@@ -199,11 +199,6 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
199
199
  };
200
200
  }
201
201
  }, [isDragging]);
202
- useEffect(function () {
203
- return function () {
204
- if (rafRef.current) cancelAnimationFrame(rafRef.current);
205
- };
206
- }, []);
207
202
  if (!attrs.src && !editor.isEditable) {
208
203
  return null;
209
204
  }
@@ -234,7 +229,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
234
229
  className: "image-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
235
230
  as: 'span',
236
231
  contentEditable: false,
237
- 'data-drag-handle': false
232
+ "data-drag-handle": false
238
233
  }, /*#__PURE__*/React.createElement(Box, {
239
234
  component: 'span',
240
235
  contentEditable: false,
@@ -269,8 +264,8 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
269
264
  _onError === null || _onError === void 0 || _onError(e);
270
265
  }
271
266
  }), (isHovering || isDragging) && /*#__PURE__*/React.createElement(Box, {
272
- contentEditable: false,
273
267
  onMouseDown: handleMouseDown,
268
+ contentEditable: false,
274
269
  sx: {
275
270
  position: 'absolute',
276
271
  right: -2,
@@ -288,8 +283,8 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
288
283
  zIndex: 10
289
284
  }
290
285
  }), (isHovering || !!anchorEl) && /*#__PURE__*/React.createElement(Box, {
291
- contentEditable: false,
292
286
  className: "image-controls",
287
+ contentEditable: false,
293
288
  sx: {
294
289
  position: 'absolute',
295
290
  top: '0.5rem',
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { NestedList } from "../../../component";
8
- import { ArrowDownSLineIcon, AttachmentLineIcon, CheckboxCircleFillIcon, CloseCircleFillIcon, ErrorWarningFillIcon, FormulaIcon, FunctionsIcon, ImageLineIcon, Information2FillIcon, Information2LineIcon, MovieLineIcon, Music2LineIcon, SquareRootIcon, Table2Icon, UploadIcon } from "../../../component/Icons";
8
+ import { ArrowDownSLineIcon, AttachmentLineIcon, CheckboxCircleFillIcon, CloseCircleFillIcon, ErrorWarningFillIcon, FormulaIcon, FunctionsIcon, ImageLineIcon, Information2FillIcon, Information2LineIcon, MovieLineIcon, Music2LineIcon, SquareRootIcon, Table2Icon, UploadIcon, UserSmileFillIcon } from "../../../component/Icons";
9
9
  import { ToolbarItem } from "../../../component/Toolbar";
10
10
  import TableSizePicker from "../../../component/Toolbar/TableSizePicker";
11
11
  import { getShortcutKeyText } from "../../../util";
@@ -158,6 +158,26 @@ var SlashCommandsList = /*#__PURE__*/forwardRef(function (_ref, ref) {
158
158
  }
159
159
  }));
160
160
  }
161
+ }, {
162
+ label: '默认 Default',
163
+ key: 'default',
164
+ icon: /*#__PURE__*/React.createElement(UserSmileFillIcon, {
165
+ sx: {
166
+ fontSize: '1rem',
167
+ color: 'text.disabled'
168
+ }
169
+ }),
170
+ onClick: function onClick() {
171
+ var node = items.find(function (it) {
172
+ return it.title === '警告提示';
173
+ });
174
+ if (node) command(_objectSpread(_objectSpread({}, node), {}, {
175
+ attrs: {
176
+ type: 'icon',
177
+ variant: 'default'
178
+ }
179
+ }));
180
+ }
161
181
  }]
162
182
  }, {
163
183
  label: '数学公式',
@@ -118,6 +118,13 @@ export var InlineAttachmentExtension = function InlineAttachmentExtension(props)
118
118
  onError: props.onError,
119
119
  attachmentType: 'icon'
120
120
  }));
121
+ }, {
122
+ stopEvent: function stopEvent() {
123
+ return true;
124
+ },
125
+ ignoreMutation: function ignoreMutation() {
126
+ return true;
127
+ }
121
128
  });
122
129
  }
123
130
  });
@@ -9,6 +9,16 @@ import { ReactNodeViewRenderer } from "@tiptap/react";
9
9
  import ImageViewWrapper from "../component/Image";
10
10
  var customImage = function customImage(props) {
11
11
  return Image.extend({
12
+ atom: true,
13
+ inline: function inline() {
14
+ return true;
15
+ },
16
+ group: function group() {
17
+ return 'inline';
18
+ },
19
+ selectable: true,
20
+ draggable: true,
21
+ marks: '',
12
22
  addKeyboardShortcuts: function addKeyboardShortcuts() {
13
23
  var _this = this;
14
24
  return {
@@ -27,13 +37,11 @@ var customImage = function customImage(props) {
27
37
  onError: props.onError
28
38
  }));
29
39
  }, {
30
- stopEvent: function stopEvent(e) {
31
- var el = e.event.target;
32
- // Swallow events from resizer & controls (safe option: return true for all)
33
- if (el.closest('.image-resizer') || el.closest('.image-controls') || el.closest('.image-wrapper')) {
34
- return true;
35
- }
36
- return false;
40
+ stopEvent: function stopEvent() {
41
+ return true;
42
+ },
43
+ ignoreMutation: function ignoreMutation() {
44
+ return true;
37
45
  }
38
46
  });
39
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "1.6.15",
3
+ "version": "1.6.17",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",