@ctzhian/tiptap 1.6.13 → 1.6.15
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,9 +7,11 @@ 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"
|
|
10
|
+
className: "image-wrapper",
|
|
11
|
+
contentEditable: false
|
|
11
12
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
12
13
|
component: 'span',
|
|
14
|
+
contentEditable: false,
|
|
13
15
|
sx: {
|
|
14
16
|
position: 'relative',
|
|
15
17
|
display: 'inline-block',
|
|
@@ -149,12 +149,17 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
149
149
|
// 使用当前实际显示的宽度作为拖拽起始点
|
|
150
150
|
setDragStartWidth(getCurrentDisplayWidth());
|
|
151
151
|
};
|
|
152
|
+
var rafRef = useRef(null);
|
|
152
153
|
var handleMouseMove = function handleMouseMove(e) {
|
|
153
154
|
if (!isDragging) return;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
+
});
|
|
158
163
|
});
|
|
159
164
|
};
|
|
160
165
|
var handleMouseUp = function handleMouseUp() {
|
|
@@ -177,8 +182,8 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
177
182
|
var currentWidth = getCurrentDisplayWidth();
|
|
178
183
|
updateAttributes({
|
|
179
184
|
src: editSrc.trim(),
|
|
180
|
-
width: currentWidth
|
|
181
|
-
error: true
|
|
185
|
+
width: currentWidth
|
|
186
|
+
// error: true,
|
|
182
187
|
});
|
|
183
188
|
setEditSrc(editSrc.trim());
|
|
184
189
|
}
|
|
@@ -194,6 +199,11 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
194
199
|
};
|
|
195
200
|
}
|
|
196
201
|
}, [isDragging]);
|
|
202
|
+
useEffect(function () {
|
|
203
|
+
return function () {
|
|
204
|
+
if (rafRef.current) cancelAnimationFrame(rafRef.current);
|
|
205
|
+
};
|
|
206
|
+
}, []);
|
|
197
207
|
if (!attrs.src && !editor.isEditable) {
|
|
198
208
|
return null;
|
|
199
209
|
}
|
|
@@ -223,9 +233,11 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
223
233
|
return /*#__PURE__*/React.createElement(NodeViewWrapper, {
|
|
224
234
|
className: "image-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
|
|
225
235
|
as: 'span',
|
|
236
|
+
contentEditable: false,
|
|
226
237
|
'data-drag-handle': false
|
|
227
238
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
228
239
|
component: 'span',
|
|
240
|
+
contentEditable: false,
|
|
229
241
|
sx: {
|
|
230
242
|
position: 'relative',
|
|
231
243
|
display: 'inline-block',
|
|
@@ -257,6 +269,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
257
269
|
_onError === null || _onError === void 0 || _onError(e);
|
|
258
270
|
}
|
|
259
271
|
}), (isHovering || isDragging) && /*#__PURE__*/React.createElement(Box, {
|
|
272
|
+
contentEditable: false,
|
|
260
273
|
onMouseDown: handleMouseDown,
|
|
261
274
|
sx: {
|
|
262
275
|
position: 'absolute',
|
|
@@ -275,6 +288,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
275
288
|
zIndex: 10
|
|
276
289
|
}
|
|
277
290
|
}), (isHovering || !!anchorEl) && /*#__PURE__*/React.createElement(Box, {
|
|
291
|
+
contentEditable: false,
|
|
278
292
|
className: "image-controls",
|
|
279
293
|
sx: {
|
|
280
294
|
position: 'absolute',
|
|
@@ -26,6 +26,15 @@ var customImage = function customImage(props) {
|
|
|
26
26
|
onUpload: props.onUpload,
|
|
27
27
|
onError: props.onError
|
|
28
28
|
}));
|
|
29
|
+
}, {
|
|
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;
|
|
37
|
+
}
|
|
29
38
|
});
|
|
30
39
|
}
|
|
31
40
|
});
|