@seafile/sdoc-editor 0.3.16 → 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/assets/css/simple-editor.css +1 -1
- 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/commons/insert-element-dialog/index.js +5 -1
- package/dist/basic-sdk/extension/constants/index.js +1 -1
- package/dist/basic-sdk/extension/constants/menus-config.js +6 -0
- package/dist/basic-sdk/extension/plugins/table/constants/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/dialogs/index.js +3 -0
- package/dist/basic-sdk/extension/plugins/table/dialogs/split-cell-setting-dialog.js +99 -0
- package/dist/basic-sdk/extension/plugins/table/helpers.js +335 -14
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/combine-cells.js +32 -0
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.css +0 -4
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +6 -0
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +31 -4
- package/dist/basic-sdk/extension/plugins/table/render/index.css +1 -11
- package/dist/basic-sdk/extension/plugins/table/render/index.js +35 -7
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +34 -15
- package/dist/basic-sdk/extension/plugins/table/render/render-row.js +5 -118
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/{resize-handler.js → column-resize-handler.js} +2 -2
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/index.js +17 -4
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/row-resize-handler.js +89 -0
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js +12 -13
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +7 -1
- package/public/locales/zh_CN/sdoc-editor.json +7 -1
- /package/dist/basic-sdk/extension/plugins/table/{dialog → dialogs}/custom-table-size-dialog/index.css +0 -0
- /package/dist/basic-sdk/extension/plugins/table/{dialog → dialogs}/custom-table-size-dialog/index.js +0 -0
- /package/dist/basic-sdk/extension/plugins/table/{dialog → dialogs}/custom-table-size-dialog/number-input.js +0 -0
|
@@ -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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState, useRef } from 'react';
|
|
2
|
-
import CustomTableSizeDialog from '../../plugins/table/
|
|
2
|
+
import { CustomTableSizeDialog, SplitCellSettingDialog } from '../../plugins/table/dialogs';
|
|
3
3
|
import AddLinkDialog from '../../plugins/link/dialog/add-link-dialog';
|
|
4
4
|
import SelectFileDialog from '../select-file-dialog/index.js';
|
|
5
5
|
import EventBus from '../../../utils/event-bus';
|
|
@@ -77,6 +77,10 @@ const InsertElementDialog = _ref => {
|
|
|
77
77
|
{
|
|
78
78
|
return /*#__PURE__*/React.createElement(CustomTableSizeDialog, props);
|
|
79
79
|
}
|
|
80
|
+
case ELEMENT_TYPE.TABLE_CELL:
|
|
81
|
+
{
|
|
82
|
+
return /*#__PURE__*/React.createElement(SplitCellSettingDialog, props);
|
|
83
|
+
}
|
|
80
84
|
case ELEMENT_TYPE.LINK:
|
|
81
85
|
{
|
|
82
86
|
return /*#__PURE__*/React.createElement(AddLinkDialog, props);
|
|
@@ -5,7 +5,7 @@ export { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, DEFAULT_FONT
|
|
|
5
5
|
export { FONT_SIZE, DEFAULT_FONT, FONT, GOOGLE_FONT_CLASS, RECENT_USED_FONTS_KEY, SDOC_FONT_SIZE } from './font';
|
|
6
6
|
export { DIFF_TYPE, ADDED_STYLE, DELETED_STYLE } from './diff-view';
|
|
7
7
|
export { KEYBOARD, MAC_HOTKEYS, WIN_HOTKEYS } from './keyboard';
|
|
8
|
-
export { UNDO, REDO, TEXT_STYLE, TEXT_STYLE_MAP, TEXT_STYLE_MORE, TEXT_ALIGN, REMOVE_TABLE, CLEAR_FORMAT, MENUS_CONFIG_MAP, SIDE_TRANSFORM_MENUS_CONFIG, SIDE_INSERT_MENUS_CONFIG } from './menus-config';
|
|
8
|
+
export { UNDO, REDO, TEXT_STYLE, TEXT_STYLE_MAP, TEXT_STYLE_MORE, TEXT_ALIGN, REMOVE_TABLE, COMBINE_CELL, CLEAR_FORMAT, MENUS_CONFIG_MAP, SIDE_TRANSFORM_MENUS_CONFIG, SIDE_INSERT_MENUS_CONFIG } from './menus-config';
|
|
9
9
|
export const HEADERS = [HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6];
|
|
10
10
|
export const HEADER_TITLE_MAP = {
|
|
11
11
|
[TITLE]: 'Title',
|
|
@@ -4,6 +4,7 @@ export const UNDO = 'undo';
|
|
|
4
4
|
export const REDO = 'redo';
|
|
5
5
|
export const CLEAR_FORMAT = 'clear_format';
|
|
6
6
|
export const REMOVE_TABLE = 'remove_table';
|
|
7
|
+
export const COMBINE_CELL = 'combine_cell';
|
|
7
8
|
|
|
8
9
|
// text style
|
|
9
10
|
export const TEXT_STYLE = 'text_style';
|
|
@@ -89,6 +90,11 @@ export const MENUS_CONFIG_MAP = {
|
|
|
89
90
|
iconClass: 'sdocfont sdoc-delete-table',
|
|
90
91
|
text: 'Delete_table'
|
|
91
92
|
},
|
|
93
|
+
[COMBINE_CELL]: {
|
|
94
|
+
id: "sdoc_".concat(COMBINE_CELL),
|
|
95
|
+
iconClass: 'sdocfont sdoc-merge-cell',
|
|
96
|
+
text: 'Combine_cell'
|
|
97
|
+
},
|
|
92
98
|
[TEXT_STYLE]: [{
|
|
93
99
|
id: ITALIC,
|
|
94
100
|
iconClass: 'sdocfont sdoc-italic',
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Alert, Row, Col, FormGroup, Label, Input } from 'reactstrap';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { getSelectedInfo, splitCell } from '../helpers';
|
|
5
|
+
const SplitCellSettingDialog = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
editor,
|
|
8
|
+
closeDialog
|
|
9
|
+
} = _ref;
|
|
10
|
+
const {
|
|
11
|
+
t
|
|
12
|
+
} = useTranslation();
|
|
13
|
+
const {
|
|
14
|
+
cell
|
|
15
|
+
} = getSelectedInfo(editor);
|
|
16
|
+
const {
|
|
17
|
+
rowspan = 1,
|
|
18
|
+
colspan = 1
|
|
19
|
+
} = cell;
|
|
20
|
+
const [rowNumber, setRowNumber] = useState(rowspan);
|
|
21
|
+
const [columnNumber, setColumnNumber] = useState(colspan);
|
|
22
|
+
const CELL_SPLIT_MAX_ROWS = rowspan;
|
|
23
|
+
const CELL_SPLIT_MAX_COLUMNS = colspan;
|
|
24
|
+
const [errorMessage, setErrorMessage] = useState('');
|
|
25
|
+
const onRowNumberChange = useCallback(e => {
|
|
26
|
+
setRowNumber(e.target.value);
|
|
27
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
+
}, []);
|
|
29
|
+
const onColumnNumberChange = useCallback(e => {
|
|
30
|
+
setColumnNumber(e.target.value);
|
|
31
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
+
}, []);
|
|
33
|
+
const handleSubmit = useCallback(() => {
|
|
34
|
+
const parsedRowNumber = parseInt(rowNumber);
|
|
35
|
+
const parsedColumnNumber = parseInt(columnNumber);
|
|
36
|
+
if (!parsedRowNumber || !parsedColumnNumber || parsedRowNumber < 0 || parsedColumnNumber < 0) {
|
|
37
|
+
setErrorMessage(t('Please_enter_a_non-negative_integer'));
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
let targetRowNumber = parsedRowNumber;
|
|
41
|
+
let targetColumnNumber = parsedColumnNumber;
|
|
42
|
+
if (parsedRowNumber > CELL_SPLIT_MAX_ROWS) {
|
|
43
|
+
targetRowNumber = CELL_SPLIT_MAX_ROWS;
|
|
44
|
+
setRowNumber(targetRowNumber);
|
|
45
|
+
setErrorMessage(t('The_maximum_row_number_is_{number}').replace('{number}', CELL_SPLIT_MAX_ROWS));
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (parsedColumnNumber > CELL_SPLIT_MAX_COLUMNS) {
|
|
49
|
+
targetColumnNumber = CELL_SPLIT_MAX_COLUMNS;
|
|
50
|
+
setColumnNumber(targetColumnNumber);
|
|
51
|
+
setErrorMessage(t('The_maximum_column_number_is_{number}').replace('{number}', CELL_SPLIT_MAX_COLUMNS));
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
splitCell(editor, targetRowNumber, targetColumnNumber);
|
|
55
|
+
closeDialog();
|
|
56
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
+
}, [rowNumber, columnNumber]);
|
|
58
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
59
|
+
isOpen: true,
|
|
60
|
+
autoFocus: false,
|
|
61
|
+
toggle: closeDialog,
|
|
62
|
+
zIndex: 1071,
|
|
63
|
+
returnFocusAfterClose: true
|
|
64
|
+
}, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
65
|
+
toggle: closeDialog
|
|
66
|
+
}, t('Split_cell')), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, {
|
|
67
|
+
md: 6
|
|
68
|
+
}, /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Label, {
|
|
69
|
+
for: "row-number"
|
|
70
|
+
}, t('Row_number')), /*#__PURE__*/React.createElement(Input, {
|
|
71
|
+
id: "row-number",
|
|
72
|
+
name: "row-number",
|
|
73
|
+
type: "number",
|
|
74
|
+
min: 1,
|
|
75
|
+
value: rowNumber,
|
|
76
|
+
onChange: onRowNumberChange
|
|
77
|
+
}))), /*#__PURE__*/React.createElement(Col, {
|
|
78
|
+
md: 6
|
|
79
|
+
}, /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Label, {
|
|
80
|
+
for: "column-number"
|
|
81
|
+
}, t('Column_number')), /*#__PURE__*/React.createElement(Input, {
|
|
82
|
+
id: "column-number",
|
|
83
|
+
name: "column-number",
|
|
84
|
+
type: "number",
|
|
85
|
+
min: 1,
|
|
86
|
+
value: columnNumber,
|
|
87
|
+
onChange: onColumnNumberChange
|
|
88
|
+
})))), errorMessage && /*#__PURE__*/React.createElement(Alert, {
|
|
89
|
+
className: "mt-2 mb-0",
|
|
90
|
+
color: "danger"
|
|
91
|
+
}, t(errorMessage))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
92
|
+
color: "secondary",
|
|
93
|
+
onClick: closeDialog
|
|
94
|
+
}, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
95
|
+
color: "primary",
|
|
96
|
+
onClick: handleSubmit
|
|
97
|
+
}, t('Submit'))));
|
|
98
|
+
};
|
|
99
|
+
export default SplitCellSettingDialog;
|