@ctzhian/tiptap 1.6.17 → 1.6.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,9 +4,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
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
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
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { FloatingPopover } from "../../../component";
8
7
  import { CustomSizeIcon, DeleteLineIcon, EditBoxLineIcon } from "../../../component/Icons";
9
- import { Box, Button, IconButton, Stack, TextField, Tooltip } from "@mui/material";
8
+ import { Box, Button, IconButton, Popover, Stack, TextField, Tooltip } from "@mui/material";
10
9
  import { NodeViewWrapper } from "@tiptap/react";
11
10
  import React, { useEffect, useRef, useState } from "react";
12
11
  import CropImage from "./Crop";
@@ -149,17 +148,12 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
149
148
  // 使用当前实际显示的宽度作为拖拽起始点
150
149
  setDragStartWidth(getCurrentDisplayWidth());
151
150
  };
152
- var rafRef = useRef(null);
153
151
  var handleMouseMove = function handleMouseMove(e) {
154
152
  if (!isDragging) return;
155
- if (rafRef.current) return;
156
- rafRef.current = requestAnimationFrame(function () {
157
- rafRef.current = null;
158
- var deltaX = e.clientX - dragStartX;
159
- var newWidth = Math.max(100, Math.min(1200, dragStartWidth + deltaX));
160
- updateAttributes({
161
- width: newWidth
162
- });
153
+ var deltaX = e.clientX - dragStartX;
154
+ var newWidth = Math.max(100, Math.min(1200, dragStartWidth + deltaX));
155
+ updateAttributes({
156
+ width: newWidth
163
157
  });
164
158
  };
165
159
  var handleMouseUp = function handleMouseUp() {
@@ -182,7 +176,8 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
182
176
  var currentWidth = getCurrentDisplayWidth();
183
177
  updateAttributes({
184
178
  src: editSrc.trim(),
185
- width: currentWidth
179
+ width: currentWidth,
180
+ error: true
186
181
  });
187
182
  setEditSrc(editSrc.trim());
188
183
  }
@@ -190,7 +185,6 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
190
185
  };
191
186
  useEffect(function () {
192
187
  if (isDragging) {
193
- setAnchorEl(null);
194
188
  document.addEventListener('mousemove', handleMouseMove);
195
189
  document.addEventListener('mouseup', handleMouseUp);
196
190
  return function () {
@@ -228,11 +222,9 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
228
222
  return /*#__PURE__*/React.createElement(NodeViewWrapper, {
229
223
  className: "image-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
230
224
  as: 'span',
231
- contentEditable: false,
232
- "data-drag-handle": false
225
+ 'data-drag-handle': false
233
226
  }, /*#__PURE__*/React.createElement(Box, {
234
227
  component: 'span',
235
- contentEditable: false,
236
228
  sx: {
237
229
  position: 'relative',
238
230
  display: 'inline-block',
@@ -265,7 +257,6 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
265
257
  }
266
258
  }), (isHovering || isDragging) && /*#__PURE__*/React.createElement(Box, {
267
259
  onMouseDown: handleMouseDown,
268
- contentEditable: false,
269
260
  sx: {
270
261
  position: 'absolute',
271
262
  right: -2,
@@ -284,7 +275,6 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
284
275
  }
285
276
  }), (isHovering || !!anchorEl) && /*#__PURE__*/React.createElement(Box, {
286
277
  className: "image-controls",
287
- contentEditable: false,
288
278
  sx: {
289
279
  position: 'absolute',
290
280
  top: '0.5rem',
@@ -334,11 +324,19 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
334
324
  sx: {
335
325
  fontSize: 18
336
326
  }
337
- }))))), /*#__PURE__*/React.createElement(FloatingPopover, {
327
+ }))))), /*#__PURE__*/React.createElement(Popover, {
338
328
  open: Boolean(anchorEl),
339
329
  anchorEl: anchorEl,
340
330
  onClose: handleClosePopover,
341
- placement: "bottom"
331
+ disableScrollLock: true,
332
+ anchorOrigin: {
333
+ vertical: 'bottom',
334
+ horizontal: 'left'
335
+ },
336
+ transformOrigin: {
337
+ vertical: 'top',
338
+ horizontal: 'left'
339
+ }
342
340
  }, /*#__PURE__*/React.createElement(Stack, {
343
341
  sx: {
344
342
  p: 2,
@@ -118,13 +118,6 @@ 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
- }
128
121
  });
129
122
  }
130
123
  });
@@ -9,16 +9,6 @@ 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: '',
22
12
  addKeyboardShortcuts: function addKeyboardShortcuts() {
23
13
  var _this = this;
24
14
  return {
@@ -36,13 +26,6 @@ var customImage = function customImage(props) {
36
26
  onUpload: props.onUpload,
37
27
  onError: props.onError
38
28
  }));
39
- }, {
40
- stopEvent: function stopEvent() {
41
- return true;
42
- },
43
- ignoreMutation: function ignoreMutation() {
44
- return true;
45
- }
46
29
  });
47
30
  }
48
31
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "1.6.17",
3
+ "version": "1.6.18",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",