@ctzhian/tiptap 1.6.14 → 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.
|
@@ -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
|
}
|
|
@@ -227,6 +237,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
227
237
|
'data-drag-handle': false
|
|
228
238
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
229
239
|
component: 'span',
|
|
240
|
+
contentEditable: false,
|
|
230
241
|
sx: {
|
|
231
242
|
position: 'relative',
|
|
232
243
|
display: 'inline-block',
|
|
@@ -258,6 +269,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
258
269
|
_onError === null || _onError === void 0 || _onError(e);
|
|
259
270
|
}
|
|
260
271
|
}), (isHovering || isDragging) && /*#__PURE__*/React.createElement(Box, {
|
|
272
|
+
contentEditable: false,
|
|
261
273
|
onMouseDown: handleMouseDown,
|
|
262
274
|
sx: {
|
|
263
275
|
position: 'absolute',
|
|
@@ -276,6 +288,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
276
288
|
zIndex: 10
|
|
277
289
|
}
|
|
278
290
|
}), (isHovering || !!anchorEl) && /*#__PURE__*/React.createElement(Box, {
|
|
291
|
+
contentEditable: false,
|
|
279
292
|
className: "image-controls",
|
|
280
293
|
sx: {
|
|
281
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
|
});
|