@seafile/comment-editor 1.0.31 → 1.0.32-beta.2
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.
|
@@ -12,8 +12,10 @@ var _reactI18next = require("react-i18next");
|
|
|
12
12
|
var _slate = require("@seafile/slate");
|
|
13
13
|
var _slateReact = require("@seafile/slate-react");
|
|
14
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
16
|
var _imagePlaceholder = _interopRequireDefault(require("../../../assets/images/image-placeholder.png"));
|
|
16
17
|
var _constants = require("../../../constants");
|
|
18
|
+
var _useComment = require("../../../hooks/use-comment");
|
|
17
19
|
var _useScrollContext = require("../../../hooks/use-scroll-context");
|
|
18
20
|
var _eventBus = _interopRequireDefault(require("../../../utils/event-bus"));
|
|
19
21
|
var _constants2 = require("../../constants");
|
|
@@ -52,6 +54,12 @@ const Image = _ref => {
|
|
|
52
54
|
border: _constants3.IMAGE_BORDER_TYPE.find(item => item.type === border_type).value
|
|
53
55
|
};
|
|
54
56
|
const readOnly = (0, _slateReact.useReadOnly)();
|
|
57
|
+
const {
|
|
58
|
+
imageConfig = {}
|
|
59
|
+
} = (0, _useComment.useComment)();
|
|
60
|
+
const {
|
|
61
|
+
disableHoverMenu = false
|
|
62
|
+
} = imageConfig;
|
|
55
63
|
const imageRef = (0, _react.useRef)(null);
|
|
56
64
|
const resizerRef = (0, _react.useRef)(null);
|
|
57
65
|
const imageCaptionInputRef = (0, _react.useRef)(null);
|
|
@@ -207,10 +215,11 @@ const Image = _ref => {
|
|
|
207
215
|
});
|
|
208
216
|
}
|
|
209
217
|
}, []);
|
|
210
|
-
const onClickImage = (0, _react.useCallback)(
|
|
218
|
+
const onClickImage = (0, _react.useCallback)(() => {
|
|
219
|
+
if (disableHoverMenu) return;
|
|
211
220
|
setPosition();
|
|
212
221
|
setIsShowImageHoverMenu(true);
|
|
213
|
-
}, [setPosition]);
|
|
222
|
+
}, [disableHoverMenu, setPosition]);
|
|
214
223
|
const reloadImage = (0, _react.useCallback)(() => {
|
|
215
224
|
if (imageRef.current) {
|
|
216
225
|
imageRef.current['src'] = (0, _helpers.getImageURL)(data, editor);
|
|
@@ -351,6 +360,15 @@ const Image = _ref => {
|
|
|
351
360
|
})));
|
|
352
361
|
};
|
|
353
362
|
const SdocImage = Image;
|
|
363
|
+
SdocImage.propTypes = {
|
|
364
|
+
element: _propTypes.default.object,
|
|
365
|
+
editor: _propTypes.default.object,
|
|
366
|
+
style: _propTypes.default.object,
|
|
367
|
+
className: _propTypes.default.string,
|
|
368
|
+
attributes: _propTypes.default.object,
|
|
369
|
+
children: _propTypes.default.node,
|
|
370
|
+
isSelected: _propTypes.default.bool
|
|
371
|
+
};
|
|
354
372
|
function renderImage(props, editor) {
|
|
355
373
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
356
374
|
const isSelected = (0, _slateReact.useSelected)();
|
|
@@ -28,7 +28,8 @@ const CommentProvider = _ref => {
|
|
|
28
28
|
pluginEvent,
|
|
29
29
|
collaborators = [],
|
|
30
30
|
participants = [],
|
|
31
|
-
addParticipants
|
|
31
|
+
addParticipants,
|
|
32
|
+
imageConfig = {}
|
|
32
33
|
} = _ref;
|
|
33
34
|
const getCollaborators = (0, _react.useCallback)(() => {
|
|
34
35
|
const newCollaborators = collaborators.map(user => new _model.User(user));
|
|
@@ -46,6 +47,7 @@ const CommentProvider = _ref => {
|
|
|
46
47
|
pluginName,
|
|
47
48
|
pluginEventBus,
|
|
48
49
|
pluginEvent,
|
|
50
|
+
imageConfig,
|
|
49
51
|
collaborators: getCollaborators(),
|
|
50
52
|
participants: getParticipants(),
|
|
51
53
|
addParticipants
|
|
@@ -18,6 +18,7 @@ const SeafileCommentEditor = _ref => {
|
|
|
18
18
|
// sdoc or dtable or txt or py ...
|
|
19
19
|
pluginEventBus,
|
|
20
20
|
pluginEvent,
|
|
21
|
+
imageConfig,
|
|
21
22
|
// Comment editor
|
|
22
23
|
content,
|
|
23
24
|
insertContent,
|
|
@@ -45,6 +46,7 @@ const SeafileCommentEditor = _ref => {
|
|
|
45
46
|
pluginName: pluginName,
|
|
46
47
|
pluginEventBus: pluginEventBus,
|
|
47
48
|
pluginEvent: pluginEvent,
|
|
49
|
+
imageConfig: imageConfig,
|
|
48
50
|
collaborators: collaborators,
|
|
49
51
|
participants: participants,
|
|
50
52
|
addParticipants: addParticipants
|