@seafile/sdoc-editor 2.0.100 → 2.0.102
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.
|
@@ -13,11 +13,12 @@ var _menuItem = _interopRequireDefault(require("./menu-item"));
|
|
|
13
13
|
require("./index.css");
|
|
14
14
|
var CommentContextMenu = function CommentContextMenu(_ref) {
|
|
15
15
|
var isRichEditor = _ref.isRichEditor;
|
|
16
|
-
var onCommentClick = (0, _react.useCallback)(function (
|
|
16
|
+
var onCommentClick = (0, _react.useCallback)(function (e) {
|
|
17
|
+
e.stopPropagation();
|
|
17
18
|
// Make context toolbar disappear
|
|
18
19
|
var contextToolBarDom = document.querySelector('.sdoc-context-toolbar');
|
|
19
20
|
if (contextToolBarDom) {
|
|
20
|
-
contextToolBarDom.
|
|
21
|
+
contextToolBarDom.style.display = 'none';
|
|
21
22
|
}
|
|
22
23
|
var eventBus = _eventBus["default"].getInstance();
|
|
23
24
|
eventBus.dispatch(_constants.INTERNAL_EVENT.ADD_CONTEXT_COMMENT);
|
|
@@ -263,6 +263,11 @@
|
|
|
263
263
|
border-top-left-radius: 3px;
|
|
264
264
|
border-top-right-radius: 3px;
|
|
265
265
|
border-radius: 3px;
|
|
266
|
+
transition: border-color 0.3s ease;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.sdoc-comment-editor-wrapper:focus-within {
|
|
270
|
+
border-color: #ff8e03;
|
|
266
271
|
}
|
|
267
272
|
|
|
268
273
|
.comment-editor-wrapper .sdoc-comment-editor-wrapper .article.sdoc-comment-editor {
|
|
@@ -17,6 +17,7 @@ var _helpers = require("./helpers");
|
|
|
17
17
|
var updateImageNode = /*#__PURE__*/function () {
|
|
18
18
|
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee(editor, element, newUrl) {
|
|
19
19
|
var isError,
|
|
20
|
+
url,
|
|
20
21
|
nodePath,
|
|
21
22
|
newData,
|
|
22
23
|
_args = arguments;
|
|
@@ -24,9 +25,12 @@ var updateImageNode = /*#__PURE__*/function () {
|
|
|
24
25
|
while (1) switch (_context.prev = _context.next) {
|
|
25
26
|
case 0:
|
|
26
27
|
isError = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
|
|
28
|
+
url = (0, _helpers.isCommentEditor)(editor) ? (0, _helpers.getImageURL)({
|
|
29
|
+
src: newUrl
|
|
30
|
+
}, editor) : newUrl;
|
|
27
31
|
nodePath = _slateReact.ReactEditor.findPath(editor, element);
|
|
28
32
|
newData = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, element.data), {}, {
|
|
29
|
-
src:
|
|
33
|
+
src: url,
|
|
30
34
|
is_copy_error: isError
|
|
31
35
|
});
|
|
32
36
|
_slate.Transforms.setNodes(editor, {
|
|
@@ -34,7 +38,7 @@ var updateImageNode = /*#__PURE__*/function () {
|
|
|
34
38
|
}, {
|
|
35
39
|
at: nodePath
|
|
36
40
|
});
|
|
37
|
-
case
|
|
41
|
+
case 5:
|
|
38
42
|
case "end":
|
|
39
43
|
return _context.stop();
|
|
40
44
|
}
|
|
@@ -22,6 +22,7 @@ var ContextToolbar = function ContextToolbar() {
|
|
|
22
22
|
var scrollRef = (0, _useScrollContext.useScrollContext)();
|
|
23
23
|
var inFocus = (0, _slateReact.useFocused)();
|
|
24
24
|
var readOnly = (0, _slateReact.useReadOnly)();
|
|
25
|
+
var clickedCommentRef = (0, _react.useRef)(false);
|
|
25
26
|
var setContextToolbarPosition = (0, _react.useCallback)(function () {
|
|
26
27
|
var el = ref.current;
|
|
27
28
|
var domSelection = window.getSelection();
|
|
@@ -52,6 +53,10 @@ var ContextToolbar = function ContextToolbar() {
|
|
|
52
53
|
if (!el) {
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
56
|
+
if (clickedCommentRef.current) {
|
|
57
|
+
clickedCommentRef.current = false;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
55
60
|
if (readOnly || !selection || !inFocus || _slate.Range.isCollapsed(selection) || _slate.Editor.string(editor, selection) === '' || (0, _core.getSelectedNodeByType)(editor, _constants.CODE_BLOCK)) {
|
|
56
61
|
scrollRef.current && scrollRef.current.removeEventListener('scroll', onScroll);
|
|
57
62
|
el.removeAttribute('style');
|
|
@@ -60,6 +65,18 @@ var ContextToolbar = function ContextToolbar() {
|
|
|
60
65
|
scrollRef.current && scrollRef.current.addEventListener('scroll', onScroll);
|
|
61
66
|
setContextToolbarPosition();
|
|
62
67
|
});
|
|
68
|
+
(0, _react.useEffect)(function () {
|
|
69
|
+
var handleClickCommentBtn = function handleClickCommentBtn(e) {
|
|
70
|
+
var target = e.target;
|
|
71
|
+
if (target !== null && target !== void 0 && target.closest('#context-toolbar-comment')) {
|
|
72
|
+
clickedCommentRef.current = true;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
document.addEventListener('mousedown', handleClickCommentBtn);
|
|
76
|
+
return function () {
|
|
77
|
+
return document.removeEventListener('mousedown', handleClickCommentBtn);
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
63
80
|
var onMouseDown = (0, _react.useCallback)(function (event) {
|
|
64
81
|
event.preventDefault(); // prevent toolbar from taking focus away from editor
|
|
65
82
|
}, []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.102",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "3cf1bbc8201869c439313e3504a9829e08a41abd"
|
|
74
74
|
}
|