@seafile/sdoc-editor 0.2.19 → 0.2.21
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.
- package/dist/basic-sdk/comment/components/editor-comment.js +8 -3
- package/dist/basic-sdk/comment/components/elements-comment-count/element-comment-count.js +13 -4
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +17 -1
- package/dist/basic-sdk/extension/render/custom-element.js +15 -1
- package/dist/basic-sdk/outline/index.js +1 -1
- package/dist/basic-sdk/outline/outline-item.js +1 -1
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +2 -1
- package/public/locales/de/sdoc-editor.json +2 -1
- package/public/locales/es/sdoc-editor.json +2 -1
- package/public/locales/fr/sdoc-editor.json +2 -1
- package/public/locales/it/sdoc-editor.json +2 -1
- package/public/locales/ru/sdoc-editor.json +4 -3
- package/public/locales/zh_CN/sdoc-editor.json +2 -1
|
@@ -8,6 +8,7 @@ import CommentList from './comment-list';
|
|
|
8
8
|
import { useSelectionElement } from '../../hooks/use-selection-element';
|
|
9
9
|
import { useCommentContext } from '../hooks/use-comment-context';
|
|
10
10
|
import ElementsCommentCount from './elements-comment-count';
|
|
11
|
+
import { ELEMENT_TYPE } from '../../extension/constants';
|
|
11
12
|
var EditorComment = function EditorComment() {
|
|
12
13
|
useSelectionUpdate();
|
|
13
14
|
var editor = useSlateStatic();
|
|
@@ -43,9 +44,13 @@ var EditorComment = function EditorComment() {
|
|
|
43
44
|
var cursor = useCursorPosition();
|
|
44
45
|
var style = useMemo(function () {
|
|
45
46
|
var _Node$string;
|
|
46
|
-
if (selectionElement && ((_Node$string = Node.string(selectionElement)) === null || _Node$string === void 0 ? void 0 : _Node$string.length) === 0)
|
|
47
|
-
|
|
48
|
-
}
|
|
47
|
+
if (selectionElement && ((_Node$string = Node.string(selectionElement)) === null || _Node$string === void 0 ? void 0 : _Node$string.length) === 0 && !selectionElement.children.find(function (n) {
|
|
48
|
+
return n.type === ELEMENT_TYPE.IMAGE;
|
|
49
|
+
})) {
|
|
50
|
+
return {
|
|
51
|
+
top: '-99999px'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
49
54
|
var comments = element_comments_map[selectionElement === null || selectionElement === void 0 ? void 0 : selectionElement.id];
|
|
50
55
|
var unresolvedComments = comments && comments.filter(function (item) {
|
|
51
56
|
return !item.resolved;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
3
|
import { useSlateStatic } from '@seafile/slate-react';
|
|
3
4
|
import { Editor } from '@seafile/slate';
|
|
4
5
|
import { getNodeById, focusEditor, findPath } from '../../../extension/core';
|
|
@@ -6,12 +7,15 @@ import { useScrollContext } from '../../../hooks/use-scroll-context';
|
|
|
6
7
|
import { getElementCommentCountTop } from '../../helper';
|
|
7
8
|
import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
8
9
|
var ElementCommentCount = function ElementCommentCount(_ref) {
|
|
9
|
-
var _scrollRef$current;
|
|
10
10
|
var elementId = _ref.elementId,
|
|
11
11
|
commentsCount = _ref.commentsCount;
|
|
12
12
|
var editor = useSlateStatic();
|
|
13
13
|
var element = getNodeById(editor.children, elementId);
|
|
14
14
|
var scrollRef = useScrollContext();
|
|
15
|
+
var _useState = useState(-9999),
|
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
+
top = _useState2[0],
|
|
18
|
+
setTop = _useState2[1];
|
|
15
19
|
var onClick = useCallback(function (event) {
|
|
16
20
|
eventStopPropagation(event);
|
|
17
21
|
var path = findPath(editor, element);
|
|
@@ -22,9 +26,14 @@ var ElementCommentCount = function ElementCommentCount(_ref) {
|
|
|
22
26
|
};
|
|
23
27
|
focusEditor(editor, range);
|
|
24
28
|
}, [editor, element]);
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
var _scrollRef$current;
|
|
31
|
+
if (!element) return;
|
|
32
|
+
var scrollTop = (scrollRef === null || scrollRef === void 0 ? void 0 : (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTop) || 0;
|
|
33
|
+
var newTop = getElementCommentCountTop(editor, element, scrollTop);
|
|
34
|
+
setTop(newTop);
|
|
35
|
+
}, [editor, elementId, element, scrollRef]);
|
|
25
36
|
if (!element) return null;
|
|
26
|
-
var scrollTop = (scrollRef === null || scrollRef === void 0 ? void 0 : (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTop) || 0;
|
|
27
|
-
var top = getElementCommentCountTop(editor, element, scrollTop);
|
|
28
37
|
return /*#__PURE__*/React.createElement("div", {
|
|
29
38
|
className: "element-comments-count",
|
|
30
39
|
style: {
|
|
@@ -279,7 +279,8 @@ function renderImage(props, editor) {
|
|
|
279
279
|
var isSelected = useSelected();
|
|
280
280
|
|
|
281
281
|
// decorate diff-viewer
|
|
282
|
-
var element = props.element
|
|
282
|
+
var element = props.element,
|
|
283
|
+
leaf = props.leaf;
|
|
283
284
|
if (element.ADD || element.DELETE) {
|
|
284
285
|
var style = element.ADD ? ADDED_STYLE : DELETED_STYLE;
|
|
285
286
|
return /*#__PURE__*/React.createElement("span", {
|
|
@@ -290,6 +291,21 @@ function renderImage(props, editor) {
|
|
|
290
291
|
height: 'fit-content'
|
|
291
292
|
}
|
|
292
293
|
}, /*#__PURE__*/React.createElement(SdocImage, Object.assign({}, props, {
|
|
294
|
+
className: classNames(props.className || '', 'm-0'),
|
|
295
|
+
editor: editor,
|
|
296
|
+
isSelected: isSelected
|
|
297
|
+
})));
|
|
298
|
+
}
|
|
299
|
+
if (leaf && leaf.computed_background_color) {
|
|
300
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
301
|
+
className: "d-inline-block p-1",
|
|
302
|
+
style: {
|
|
303
|
+
backgroundColor: leaf.computed_background_color,
|
|
304
|
+
width: 'fit-content',
|
|
305
|
+
height: 'fit-content'
|
|
306
|
+
}
|
|
307
|
+
}, /*#__PURE__*/React.createElement(SdocImage, Object.assign({}, props, {
|
|
308
|
+
className: classNames(props.className || '', 'm-0'),
|
|
293
309
|
editor: editor,
|
|
294
310
|
isSelected: isSelected
|
|
295
311
|
})));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
3
|
import { useCallback } from 'react';
|
|
3
4
|
import { useSlateStatic } from '@seafile/slate-react';
|
|
@@ -5,6 +6,7 @@ import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4,
|
|
|
5
6
|
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin } from '../plugins';
|
|
6
7
|
import EventBus from '../../utils/event-bus';
|
|
7
8
|
import { INTERNAL_EVENT } from '../../constants';
|
|
9
|
+
import { getParentNode } from '../core';
|
|
8
10
|
var CustomRenderElement = function CustomRenderElement(props) {
|
|
9
11
|
var editor = useSlateStatic();
|
|
10
12
|
var element = props.element,
|
|
@@ -102,9 +104,21 @@ var CustomRenderElement = function CustomRenderElement(props) {
|
|
|
102
104
|
}
|
|
103
105
|
case IMAGE:
|
|
104
106
|
{
|
|
107
|
+
var _editor$element_comme;
|
|
108
|
+
var parentNode = getParentNode(editor.children, element.id);
|
|
109
|
+
var comments = ((_editor$element_comme = editor.element_comments_map) === null || _editor$element_comme === void 0 ? void 0 : _editor$element_comme[parentNode.id]) || [];
|
|
110
|
+
var unresolvedComments = comments && comments.filter(function (item) {
|
|
111
|
+
return !item.resolved;
|
|
112
|
+
});
|
|
113
|
+
var leaf = {};
|
|
114
|
+
if (unresolvedComments && unresolvedComments.length > 0) {
|
|
115
|
+
leaf['computed_background_color'] = 'rgba(129, 237, 247, 0.5)';
|
|
116
|
+
}
|
|
105
117
|
var _ImagePlugin$renderEl = _slicedToArray(ImagePlugin.renderElements, 1),
|
|
106
118
|
renderImage = _ImagePlugin$renderEl[0];
|
|
107
|
-
return renderImage(props,
|
|
119
|
+
return renderImage(_objectSpread(_objectSpread({}, props), {}, {
|
|
120
|
+
leaf: leaf
|
|
121
|
+
}), editor);
|
|
108
122
|
}
|
|
109
123
|
case ELEMENT_TYPE.TABLE:
|
|
110
124
|
{
|
|
@@ -61,7 +61,7 @@ var SDocOutline = function SDocOutline(_ref) {
|
|
|
61
61
|
onClick: toggleShow
|
|
62
62
|
})), list.length === 0 && /*#__PURE__*/React.createElement("p", {
|
|
63
63
|
className: "mt-4 text-secondary"
|
|
64
|
-
}, t('Headings_you_add_to_the_document_will_appear_here')), list.length > 0 && /*#__PURE__*/React.createElement("
|
|
64
|
+
}, t('Headings_you_add_to_the_document_will_appear_here')), list.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
65
65
|
className: "sdoc-outline-list-container"
|
|
66
66
|
}, list.map(function (item, index) {
|
|
67
67
|
return /*#__PURE__*/React.createElement(OutlineItem, {
|
|
@@ -43,7 +43,7 @@ var OutlineItem = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
43
43
|
'pl-7': type === 'header3',
|
|
44
44
|
'active': isHighlighted
|
|
45
45
|
});
|
|
46
|
-
return /*#__PURE__*/React.createElement("
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
47
|
className: outlineItemClass,
|
|
48
48
|
onClick: this.onItemClick,
|
|
49
49
|
onMouseOver: this.onMouseOver,
|
package/package.json
CHANGED
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Smazání se nezdařilo",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Löschen fehlgeschlagen",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Eliminar falló",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Échec de la suppression",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -391,5 +391,6 @@
|
|
|
391
391
|
"Delete_failed": "Rimozione fallita",
|
|
392
392
|
"Insert_caption": "Insert caption",
|
|
393
393
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
|
-
"Find_a_collaborator": "Find a collaborator"
|
|
394
|
+
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|
|
@@ -389,7 +389,8 @@
|
|
|
389
389
|
"Published": "Опубликовано",
|
|
390
390
|
"Delete_Successfully": "Удалено",
|
|
391
391
|
"Delete_failed": "Не удалось удалить",
|
|
392
|
-
"Insert_caption": "
|
|
393
|
-
"No_collaborators_available": "
|
|
394
|
-
"Find_a_collaborator": "
|
|
392
|
+
"Insert_caption": "Вставить подпись",
|
|
393
|
+
"No_collaborators_available": "Нет доступных соавторов",
|
|
394
|
+
"Find_a_collaborator": "Найти соавтора",
|
|
395
|
+
"Doc_comments": "Document comments"
|
|
395
396
|
}
|