@ctzhian/tiptap 1.6.16 → 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.
|
@@ -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,7 @@ 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
|
|
182
186
|
});
|
|
183
187
|
setEditSrc(editSrc.trim());
|
|
184
188
|
}
|
|
@@ -186,6 +190,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
186
190
|
};
|
|
187
191
|
useEffect(function () {
|
|
188
192
|
if (isDragging) {
|
|
193
|
+
setAnchorEl(null);
|
|
189
194
|
document.addEventListener('mousemove', handleMouseMove);
|
|
190
195
|
document.addEventListener('mouseup', handleMouseUp);
|
|
191
196
|
return function () {
|
|
@@ -223,9 +228,11 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
223
228
|
return /*#__PURE__*/React.createElement(NodeViewWrapper, {
|
|
224
229
|
className: "image-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
|
|
225
230
|
as: 'span',
|
|
226
|
-
|
|
231
|
+
contentEditable: false,
|
|
232
|
+
"data-drag-handle": false
|
|
227
233
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
228
234
|
component: 'span',
|
|
235
|
+
contentEditable: false,
|
|
229
236
|
sx: {
|
|
230
237
|
position: 'relative',
|
|
231
238
|
display: 'inline-block',
|
|
@@ -258,6 +265,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
258
265
|
}
|
|
259
266
|
}), (isHovering || isDragging) && /*#__PURE__*/React.createElement(Box, {
|
|
260
267
|
onMouseDown: handleMouseDown,
|
|
268
|
+
contentEditable: false,
|
|
261
269
|
sx: {
|
|
262
270
|
position: 'absolute',
|
|
263
271
|
right: -2,
|
|
@@ -276,6 +284,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
276
284
|
}
|
|
277
285
|
}), (isHovering || !!anchorEl) && /*#__PURE__*/React.createElement(Box, {
|
|
278
286
|
className: "image-controls",
|
|
287
|
+
contentEditable: false,
|
|
279
288
|
sx: {
|
|
280
289
|
position: 'absolute',
|
|
281
290
|
top: '0.5rem',
|
|
@@ -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 {
|
|
@@ -26,6 +36,13 @@ var customImage = function customImage(props) {
|
|
|
26
36
|
onUpload: props.onUpload,
|
|
27
37
|
onError: props.onError
|
|
28
38
|
}));
|
|
39
|
+
}, {
|
|
40
|
+
stopEvent: function stopEvent() {
|
|
41
|
+
return true;
|
|
42
|
+
},
|
|
43
|
+
ignoreMutation: function ignoreMutation() {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
29
46
|
});
|
|
30
47
|
}
|
|
31
48
|
});
|