@seafile/sdoc-editor 0.3.17 → 0.3.18
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 +5 -2
- package/dist/basic-sdk/comment/components/elements-comment-count/element-comment-count.js +10 -4
- package/dist/basic-sdk/comment/components/elements-comment-count/index.js +4 -1
- package/dist/basic-sdk/comment/components/style.css +1 -0
- package/dist/basic-sdk/constants/index.js +3 -1
- package/dist/basic-sdk/constants/z-index.js +2 -0
- package/dist/basic-sdk/extension/plugins/table/helpers.js +11 -13
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import { useSelectionElement } from '../../hooks/use-selection-element';
|
|
|
8
8
|
import { useCommentContext } from '../hooks/comment-hooks/use-comment-context';
|
|
9
9
|
import ElementsCommentCount from './elements-comment-count';
|
|
10
10
|
import { ELEMENT_TYPE } from '../../extension/constants';
|
|
11
|
+
import { Z_INDEX } from '../../constants';
|
|
11
12
|
const EditorComment = _ref => {
|
|
12
13
|
let {
|
|
13
14
|
deleteUnseenNotifications
|
|
@@ -55,7 +56,8 @@ const EditorComment = _ref => {
|
|
|
55
56
|
top: '-99999px'
|
|
56
57
|
};
|
|
57
58
|
return {
|
|
58
|
-
top: cursor.y
|
|
59
|
+
top: cursor.y,
|
|
60
|
+
zIndex: Z_INDEX.COMMENT_ADD
|
|
59
61
|
};
|
|
60
62
|
}, [cursor, isShowComments, selectionElement, element_comments_map]);
|
|
61
63
|
const hiddenComment = useCallback(() => {
|
|
@@ -77,7 +79,8 @@ const EditorComment = _ref => {
|
|
|
77
79
|
}, /*#__PURE__*/React.createElement("i", {
|
|
78
80
|
className: "sdocfont sdoc-add-comment mr-1"
|
|
79
81
|
}))), /*#__PURE__*/React.createElement(ElementsCommentCount, {
|
|
80
|
-
elementCommentsMap: element_comments_map
|
|
82
|
+
elementCommentsMap: element_comments_map,
|
|
83
|
+
selectionElement: selectionElement
|
|
81
84
|
}), /*#__PURE__*/React.createElement("div", {
|
|
82
85
|
className: "comment-list-wrapper",
|
|
83
86
|
style: isShowComments ? {
|
|
@@ -5,9 +5,11 @@ import { useScrollContext } from '../../../hooks/use-scroll-context';
|
|
|
5
5
|
import { getElementCommentCountTop } from '../../helper';
|
|
6
6
|
import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
7
7
|
import { focusToCommentElement } from '../../utils';
|
|
8
|
+
import { Z_INDEX } from '../../../constants';
|
|
8
9
|
const ElementCommentCount = _ref => {
|
|
9
10
|
let {
|
|
10
11
|
elementId,
|
|
12
|
+
isElementSelected,
|
|
11
13
|
commentsCount
|
|
12
14
|
} = _ref;
|
|
13
15
|
const editor = useSlateStatic();
|
|
@@ -24,13 +26,17 @@ const ElementCommentCount = _ref => {
|
|
|
24
26
|
const scrollTop = (scrollRef === null || scrollRef === void 0 ? void 0 : (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTop) || 0;
|
|
25
27
|
const newTop = getElementCommentCountTop(editor, element, scrollTop);
|
|
26
28
|
setTop(newTop);
|
|
27
|
-
}, [editor, elementId, element, scrollRef]);
|
|
29
|
+
}, [editor, elementId, element, scrollRef, isElementSelected]);
|
|
28
30
|
if (!element) return null;
|
|
31
|
+
let style = {
|
|
32
|
+
top
|
|
33
|
+
};
|
|
34
|
+
if (isElementSelected) {
|
|
35
|
+
style['zIndex'] = Z_INDEX.ACTIVE_COMMENT_COUNT;
|
|
36
|
+
}
|
|
29
37
|
return /*#__PURE__*/React.createElement("div", {
|
|
30
38
|
className: "element-comments-count",
|
|
31
|
-
style:
|
|
32
|
-
top
|
|
33
|
-
},
|
|
39
|
+
style: style,
|
|
34
40
|
onClick: onClick
|
|
35
41
|
}, /*#__PURE__*/React.createElement("i", {
|
|
36
42
|
className: "sdocfont sdoc-comment-count"
|
|
@@ -3,7 +3,8 @@ import ElementCommentCount from './element-comment-count';
|
|
|
3
3
|
import './index.css';
|
|
4
4
|
const ElementsCommentCount = _ref => {
|
|
5
5
|
let {
|
|
6
|
-
elementCommentsMap
|
|
6
|
+
elementCommentsMap,
|
|
7
|
+
selectionElement
|
|
7
8
|
} = _ref;
|
|
8
9
|
if (!elementCommentsMap) return null;
|
|
9
10
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -14,9 +15,11 @@ const ElementsCommentCount = _ref => {
|
|
|
14
15
|
const unresolvedComment = comments.filter(item => !item.resolved);
|
|
15
16
|
const unresolvedCommentCount = unresolvedComment.length;
|
|
16
17
|
if (unresolvedCommentCount === 0) return null;
|
|
18
|
+
const isSelected = selectionElement.id === elementId;
|
|
17
19
|
return /*#__PURE__*/React.createElement(ElementCommentCount, {
|
|
18
20
|
key: elementId,
|
|
19
21
|
elementId: elementId,
|
|
22
|
+
isElementSelected: isSelected,
|
|
20
23
|
commentsCount: unresolvedCommentCount
|
|
21
24
|
});
|
|
22
25
|
}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Z_INDEX from './z-index';
|
|
1
2
|
export const INTERNAL_EVENT = {
|
|
2
3
|
CANCEL_TABLE_SELECT_RANGE: 'cancel_table_select_range',
|
|
3
4
|
SET_TABLE_SELECT_RANGE: 'set_table_select_range',
|
|
@@ -41,4 +42,5 @@ export const REBASE_ORIGIN = {
|
|
|
41
42
|
OTHER: 'other',
|
|
42
43
|
MY: 'my'
|
|
43
44
|
};
|
|
44
|
-
export const REBASE_MARKS = [REBASE_MARK_KEY.ORIGIN, REBASE_MARK_KEY.REBASE_TYPE, REBASE_MARK_KEY.MODIFY_TYPE, REBASE_MARK_KEY.OLD_ELEMENT];
|
|
45
|
+
export const REBASE_MARKS = [REBASE_MARK_KEY.ORIGIN, REBASE_MARK_KEY.REBASE_TYPE, REBASE_MARK_KEY.MODIFY_TYPE, REBASE_MARK_KEY.OLD_ELEMENT];
|
|
46
|
+
export { Z_INDEX };
|
|
@@ -2,7 +2,8 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import slugid from 'slugid';
|
|
3
3
|
import { Editor, Range, Transforms, Point, Node } from '@seafile/slate';
|
|
4
4
|
import { ReactEditor } from '@seafile/slate-react';
|
|
5
|
-
import
|
|
5
|
+
import deepCopy from 'deep-copy';
|
|
6
|
+
import { getNodeType, getParentNode, getSelectedNodeByType, isTextNode, getSelectedElems, focusEditor, getNode, findPath, replaceNodeChildren, replaceNode } from '../../core';
|
|
6
7
|
import { ELEMENT_TYPE, KEYBOARD, CLIPBOARD_FORMAT_KEY, INSERT_POSITION } from '../../constants';
|
|
7
8
|
import { TABLE_MAX_ROWS, TABLE_MAX_COLUMNS, EMPTY_SELECTED_RANGE, TABLE_ROW_MIN_HEIGHT, TABLE_CELL_MIN_WIDTH, TABLE_ELEMENT, TABLE_ELEMENT_POSITION, TABLE_ROW_STYLE } from './constants';
|
|
8
9
|
import EventBus from '../../../utils/event-bus';
|
|
@@ -868,6 +869,7 @@ export const insertMultipleRowsAndColumns = (editor, rows, columns) => {
|
|
|
868
869
|
rowIndex,
|
|
869
870
|
cellIndex
|
|
870
871
|
} = getSelectedInfo(editor);
|
|
872
|
+
let newTable = deepCopy(table);
|
|
871
873
|
const eventBus = EventBus.getInstance();
|
|
872
874
|
eventBus.dispatch(INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
873
875
|
const insertRows = rows.slice(tableSize[0] - rowIndex);
|
|
@@ -878,20 +880,15 @@ export const insertMultipleRowsAndColumns = (editor, rows, columns) => {
|
|
|
878
880
|
const insertRow = validInsertRows[i];
|
|
879
881
|
const row = generateTableRow(tableSize[1]);
|
|
880
882
|
row.style = insertRow.style;
|
|
881
|
-
|
|
882
|
-
at: [...tablePath, tableSize[0] + i]
|
|
883
|
-
});
|
|
883
|
+
newTable.children.push(row);
|
|
884
884
|
}
|
|
885
885
|
if (validInsertColumns.length > 0) {
|
|
886
|
-
|
|
886
|
+
newTable.columns = [...table.columns, ...validInsertColumns];
|
|
887
887
|
}
|
|
888
888
|
for (let j = 0; j < validInsertColumns.length; j++) {
|
|
889
889
|
for (let i = 0; i < tableSize[0] + validInsertRows.length; i++) {
|
|
890
|
-
const newCellPath = [...tablePath, i, tableSize[1] - 1];
|
|
891
890
|
const newCell = generateTableCell();
|
|
892
|
-
|
|
893
|
-
at: newCellPath
|
|
894
|
-
});
|
|
891
|
+
newTable.children[i].children.push(newCell);
|
|
895
892
|
}
|
|
896
893
|
}
|
|
897
894
|
for (let i = rowIndex; i < Math.min(TABLE_MAX_ROWS, rowIndex + rows.length); i++) {
|
|
@@ -900,12 +897,13 @@ export const insertMultipleRowsAndColumns = (editor, rows, columns) => {
|
|
|
900
897
|
for (let j = cellIndex; j < Math.min(TABLE_MAX_COLUMNS, cellIndex + columns.length); j++) {
|
|
901
898
|
const replaceCellIndex = j - cellIndex;
|
|
902
899
|
const replaceCell = cells[replaceCellIndex];
|
|
903
|
-
|
|
904
|
-
at: [...tablePath, i, j],
|
|
905
|
-
nodes: replacePastedDataId(replaceCell.children)
|
|
906
|
-
});
|
|
900
|
+
newTable.children[i].children[j].children = replacePastedDataId(replaceCell.children);
|
|
907
901
|
}
|
|
908
902
|
}
|
|
903
|
+
replaceNode(editor, {
|
|
904
|
+
at: tablePath,
|
|
905
|
+
nodes: newTable
|
|
906
|
+
});
|
|
909
907
|
focusEditor(editor, [...tablePath, rowIndex, cellIndex, 0]);
|
|
910
908
|
const {
|
|
911
909
|
focus: newFocus
|