@seafile/sdoc-editor 0.5.78 → 1.0.0
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/extension/plugins/link/plugin.js +1 -1
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/seatable-table.js +19 -10
- package/dist/basic-sdk/extension/plugins/table/helpers.js +1 -0
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/index.js +8 -8
- package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +2 -2
- package/dist/basic-sdk/utils/dom-utils.js +1 -1
- package/dist/pages/document-plugin-editor.js +9 -4
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +3 -1
- package/public/locales/de/sdoc-editor.json +3 -1
- package/public/locales/en/sdoc-editor.json +2 -1
- package/public/locales/es/sdoc-editor.json +3 -1
- package/public/locales/es_AR/sdoc-editor.json +3 -1
- package/public/locales/es_MX/sdoc-editor.json +3 -1
- package/public/locales/fr/sdoc-editor.json +3 -1
- package/public/locales/it/sdoc-editor.json +3 -1
- package/public/locales/ru/sdoc-editor.json +3 -1
- package/public/locales/zh_CN/sdoc-editor.json +3 -1
|
@@ -83,7 +83,7 @@ const withLink = editor => {
|
|
|
83
83
|
});
|
|
84
84
|
} else {
|
|
85
85
|
const [firstSelectedNode, ...restNodes] = getSelectedElems(newEditor);
|
|
86
|
-
if (!firstSelectedNode || restNodes) return; // If select more than one node or not select any node, return
|
|
86
|
+
if (!firstSelectedNode || restNodes.length) return; // If select more than one node or not select any node, return
|
|
87
87
|
const isSelectTextNodes = firstSelectedNode.children.some(node => Text.isText(node));
|
|
88
88
|
if (!isSelectTextNodes) return;
|
|
89
89
|
const selectContent = window.getSelection().toString();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import { useSelected } from '@seafile/slate-react';
|
|
4
|
+
import { useReadOnly, useSelected } from '@seafile/slate-react';
|
|
5
5
|
import Loading from '../../../../../components/loading';
|
|
6
6
|
import RecordHeader from './record-header';
|
|
7
7
|
import RecordList from './record-list';
|
|
@@ -15,9 +15,12 @@ function SeaTableTable(_ref) {
|
|
|
15
15
|
editor
|
|
16
16
|
} = _ref;
|
|
17
17
|
const isSelected = useSelected();
|
|
18
|
+
const isReadOnly = useReadOnly();
|
|
18
19
|
const [isLoading, setIsLoading] = useState(true);
|
|
19
|
-
const [records, setRecords] = useState([]);
|
|
20
20
|
const [columns, setColumns] = useState([]);
|
|
21
|
+
const [records, setRecords] = useState([]);
|
|
22
|
+
const [shownRecords, setShownRecords] = useState([]);
|
|
23
|
+
const [isShowTipMessage, setIsShowTipMessage] = useState(false);
|
|
21
24
|
const {
|
|
22
25
|
t
|
|
23
26
|
} = useTranslation();
|
|
@@ -26,11 +29,16 @@ function SeaTableTable(_ref) {
|
|
|
26
29
|
table_id
|
|
27
30
|
} = element;
|
|
28
31
|
const table = editor.getTableById(table_id);
|
|
29
|
-
setRecords(table.rows);
|
|
30
32
|
setColumns(table.columns);
|
|
33
|
+
const records = table.rows;
|
|
34
|
+
const isShowTipMessage = isReadOnly ? records.length > 200 : records.length > 10;
|
|
35
|
+
const shownRecords = isReadOnly ? records.slice(0, 200) : records.slice(0, 10);
|
|
36
|
+
setIsShowTipMessage(isShowTipMessage);
|
|
37
|
+
setRecords(records);
|
|
38
|
+
setShownRecords(shownRecords);
|
|
31
39
|
setIsLoading(false);
|
|
32
40
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
}, [element]);
|
|
41
|
+
}, [element, isReadOnly]);
|
|
34
42
|
const containerClass = classNames('seatable-view-container', {
|
|
35
43
|
selected: isSelected
|
|
36
44
|
});
|
|
@@ -40,7 +48,6 @@ function SeaTableTable(_ref) {
|
|
|
40
48
|
} = element;
|
|
41
49
|
return editor.getTableCellValue(table_id, row, column);
|
|
42
50
|
}, [editor, element]);
|
|
43
|
-
const isShowMoreMessage = records.length - 10 > 0 ? true : false;
|
|
44
51
|
return /*#__PURE__*/React.createElement("div", Object.assign({}, attributes, {
|
|
45
52
|
className: containerClass,
|
|
46
53
|
contentEditable: false
|
|
@@ -50,13 +57,15 @@ function SeaTableTable(_ref) {
|
|
|
50
57
|
columns: columns
|
|
51
58
|
}), /*#__PURE__*/React.createElement(RecordList, {
|
|
52
59
|
editor: editor,
|
|
53
|
-
records:
|
|
60
|
+
records: shownRecords,
|
|
54
61
|
columns: columns,
|
|
55
62
|
getTableCellValue: getTableCellValue
|
|
56
|
-
})),
|
|
57
|
-
className: "ml-2 m-2"
|
|
63
|
+
})), !isReadOnly && isShowTipMessage && /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: "d-print-none ml-2 m-2"
|
|
58
65
|
}, t('And_x_more_records', {
|
|
59
66
|
count: records.length - 10
|
|
60
|
-
}))
|
|
67
|
+
})), isReadOnly && isShowTipMessage && /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: "d-print-none ml-2 m-2"
|
|
69
|
+
}, t('Print_limit_exceeded'))), children);
|
|
61
70
|
}
|
|
62
71
|
export default SeaTableTable;
|
|
@@ -30,6 +30,7 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
30
30
|
const renderItemListRef = useRef([]);
|
|
31
31
|
const downDownWrapperRef = useRef(null);
|
|
32
32
|
const onInsertImageToggle = useCallback(() => {
|
|
33
|
+
callback && callback();
|
|
33
34
|
const eventBus = EventBus.getInstance();
|
|
34
35
|
if (insertPosition === INSERT_POSITION.CURRENT) {
|
|
35
36
|
Transforms.select(editor, editor.selection.focus);
|
|
@@ -39,47 +40,47 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
39
40
|
insertPosition,
|
|
40
41
|
slateNode
|
|
41
42
|
});
|
|
42
|
-
callback && callback();
|
|
43
43
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
44
|
}, [editor, insertPosition]);
|
|
45
45
|
const createTable = useCallback(size => {
|
|
46
|
+
callback && callback();
|
|
46
47
|
const newInsertPosition = slateNode.type === ELEMENT_TYPE.LIST_ITEM ? INSERT_POSITION.AFTER : insertPosition;
|
|
47
48
|
insertTable(editor, size, editor.selection, newInsertPosition);
|
|
48
|
-
callback && callback();
|
|
49
49
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
50
|
}, [editor, insertPosition, slateNode]);
|
|
51
51
|
const openLinkDialog = useCallback(() => {
|
|
52
|
+
callback && callback();
|
|
52
53
|
const eventBus = EventBus.getInstance();
|
|
53
54
|
eventBus.dispatch(INTERNAL_EVENT.INSERT_ELEMENT, {
|
|
54
55
|
type: ELEMENT_TYPE.LINK,
|
|
55
56
|
insertPosition,
|
|
56
57
|
slateNode
|
|
57
58
|
});
|
|
58
|
-
callback && callback();
|
|
59
59
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
60
|
}, [insertPosition]);
|
|
61
61
|
const onInsertCodeBlock = useCallback(() => {
|
|
62
|
+
callback && callback();
|
|
62
63
|
const newInsertPosition = slateNode.type === ELEMENT_TYPE.LIST_ITEM ? INSERT_POSITION.AFTER : insertPosition;
|
|
63
64
|
changeToCodeBlock(editor, 'plaintext', newInsertPosition);
|
|
64
|
-
callback && callback();
|
|
65
65
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
66
|
}, [editor, insertPosition, slateNode]);
|
|
67
67
|
const onInsertList = useCallback(type => {
|
|
68
|
-
toggleList(editor, type, insertPosition);
|
|
69
68
|
callback && callback();
|
|
69
|
+
toggleList(editor, type, insertPosition);
|
|
70
70
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
71
71
|
}, [editor, insertPosition, slateNode]);
|
|
72
72
|
const onInsertCheckList = useCallback(() => {
|
|
73
|
-
setCheckListItemType(editor, ELEMENT_TYPE.CHECK_LIST_ITEM, insertPosition);
|
|
74
73
|
callback && callback();
|
|
74
|
+
setCheckListItemType(editor, ELEMENT_TYPE.CHECK_LIST_ITEM, insertPosition);
|
|
75
75
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
76
|
}, [editor, insertPosition, slateNode]);
|
|
77
77
|
const onInsert = useCallback(type => {
|
|
78
|
-
insertElement(editor, type, insertPosition);
|
|
79
78
|
callback && callback();
|
|
79
|
+
insertElement(editor, type, insertPosition);
|
|
80
80
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
81
81
|
}, [editor, insertPosition, slateNode]);
|
|
82
82
|
const onInsertCallout = useCallback(type => {
|
|
83
|
+
callback && callback();
|
|
83
84
|
if (insertPosition === INSERT_POSITION.CURRENT) {
|
|
84
85
|
wrapCallout(editor);
|
|
85
86
|
Transforms.removeNodes(editor, {
|
|
@@ -89,7 +90,6 @@ const QuickInsertBlockMenu = _ref => {
|
|
|
89
90
|
insertElement(editor, type, insertPosition);
|
|
90
91
|
wrapCallout(editor);
|
|
91
92
|
}
|
|
92
|
-
callback && callback();
|
|
93
93
|
}, [callback, editor, insertPosition]);
|
|
94
94
|
const isDisableCallout = useMemo(() => {
|
|
95
95
|
const callout = getAboveBlockNode(editor, {
|
|
@@ -33,9 +33,9 @@ const SideToolbar = () => {
|
|
|
33
33
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
34
|
}, []);
|
|
35
35
|
const handleClick = useCallback(e => {
|
|
36
|
-
if (!isShowSideMenu) return;
|
|
36
|
+
if (!isShowSideMenu || !menuRef.current) return;
|
|
37
37
|
const isClickSideTool = menuRef.current.contains(e.target);
|
|
38
|
-
if (isClickSideTool) return;
|
|
38
|
+
if (isClickSideTool || !sideMenuRef.current) return;
|
|
39
39
|
const {
|
|
40
40
|
sideMenuDom
|
|
41
41
|
} = sideMenuRef.current;
|
|
@@ -60,7 +60,7 @@ export const getHeaderHeight = editor => {
|
|
|
60
60
|
case WIKI_EDITOR:
|
|
61
61
|
return 113.2;
|
|
62
62
|
case DOCUMENT_PLUGIN_EDITOR:
|
|
63
|
-
return
|
|
63
|
+
return 67 + 48 + 49 + 37;
|
|
64
64
|
default:
|
|
65
65
|
// sdoc-editor-page-header height = 56
|
|
66
66
|
// sdoc-editor-toolbar height = 37
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useMemo } from 'react';
|
|
2
2
|
import { withTranslation } from 'react-i18next';
|
|
3
3
|
import context from '../context';
|
|
4
|
-
import { SDocEditor } from '../basic-sdk';
|
|
4
|
+
import { SDocEditor, SDocViewer } from '../basic-sdk';
|
|
5
5
|
import { PAGE_EDIT_AREA_WIDTH, DOCUMENT_PLUGIN_EDITOR } from '../basic-sdk/constants';
|
|
6
6
|
import { createDefaultEditor } from '../basic-sdk/extension';
|
|
7
7
|
import withNodeId from '../basic-sdk/node-id';
|
|
@@ -13,9 +13,9 @@ import '../assets/css/simple-editor.css';
|
|
|
13
13
|
import '../assets/css/plugin-editor.css';
|
|
14
14
|
const DocumentPluginEditor = _ref => {
|
|
15
15
|
let {
|
|
16
|
+
isReadOnly,
|
|
16
17
|
document,
|
|
17
18
|
showOutline,
|
|
18
|
-
scrollRef,
|
|
19
19
|
tableId,
|
|
20
20
|
columns,
|
|
21
21
|
getColumnCellValue,
|
|
@@ -58,12 +58,17 @@ const DocumentPluginEditor = _ref => {
|
|
|
58
58
|
validEditor.getColumnCellValue = getColumnCellValue ? getColumnCellValue : null;
|
|
59
59
|
forceUpdate();
|
|
60
60
|
}, [forceUpdate, getColumnCellValue, validEditor.getColumnCellValue]);
|
|
61
|
-
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(SDocEditor, {
|
|
61
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, null, !isReadOnly && /*#__PURE__*/React.createElement(SDocEditor, {
|
|
62
62
|
editor: validEditor,
|
|
63
|
-
scrollRef: scrollRef,
|
|
64
63
|
document: document,
|
|
65
64
|
showComment: false,
|
|
66
65
|
showOutline: showOutline
|
|
66
|
+
}), isReadOnly && /*#__PURE__*/React.createElement(SDocViewer, {
|
|
67
|
+
editor: validEditor,
|
|
68
|
+
document: document,
|
|
69
|
+
showToolbar: false,
|
|
70
|
+
showComment: false,
|
|
71
|
+
showOutline: showOutline
|
|
67
72
|
}));
|
|
68
73
|
};
|
|
69
74
|
export default withTranslation('sdoc-editor')(DocumentPluginEditor);
|
package/package.json
CHANGED
|
@@ -462,5 +462,7 @@
|
|
|
462
462
|
"Vertical_align": "Vertical alignment",
|
|
463
463
|
"Horizontal_align": "Horizontal alignment",
|
|
464
464
|
"SeaTable_column": "SeaTable column",
|
|
465
|
-
"SeaTable_table": "SeaTable table"
|
|
465
|
+
"SeaTable_table": "SeaTable table",
|
|
466
|
+
"And_x_more_records": "and {{count}} more records",
|
|
467
|
+
"Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed"
|
|
466
468
|
}
|
|
@@ -462,5 +462,7 @@
|
|
|
462
462
|
"Vertical_align": "Vertical alignment",
|
|
463
463
|
"Horizontal_align": "Horizontal alignment",
|
|
464
464
|
"SeaTable_column": "SeaTable column",
|
|
465
|
-
"SeaTable_table": "SeaTable table"
|
|
465
|
+
"SeaTable_table": "SeaTable table",
|
|
466
|
+
"And_x_more_records": "and {{count}} more records",
|
|
467
|
+
"Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed"
|
|
466
468
|
}
|
|
@@ -463,5 +463,6 @@
|
|
|
463
463
|
"Horizontal_align": "Horizontal alignment",
|
|
464
464
|
"SeaTable_column": "SeaTable column",
|
|
465
465
|
"SeaTable_table": "SeaTable table",
|
|
466
|
-
"And_x_more_records": "and {{count}} more records"
|
|
466
|
+
"And_x_more_records": "and {{count}} more records",
|
|
467
|
+
"Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed"
|
|
467
468
|
}
|
|
@@ -462,5 +462,7 @@
|
|
|
462
462
|
"Vertical_align": "Vertical alignment",
|
|
463
463
|
"Horizontal_align": "Horizontal alignment",
|
|
464
464
|
"SeaTable_column": "SeaTable column",
|
|
465
|
-
"SeaTable_table": "SeaTable table"
|
|
465
|
+
"SeaTable_table": "SeaTable table",
|
|
466
|
+
"And_x_more_records": "and {{count}} more records",
|
|
467
|
+
"Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed"
|
|
466
468
|
}
|
|
@@ -462,5 +462,7 @@
|
|
|
462
462
|
"Vertical_align": "Vertical alignment",
|
|
463
463
|
"Horizontal_align": "Horizontal alignment",
|
|
464
464
|
"SeaTable_column": "SeaTable column",
|
|
465
|
-
"SeaTable_table": "SeaTable table"
|
|
465
|
+
"SeaTable_table": "SeaTable table",
|
|
466
|
+
"And_x_more_records": "and {{count}} more records",
|
|
467
|
+
"Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed"
|
|
466
468
|
}
|
|
@@ -462,5 +462,7 @@
|
|
|
462
462
|
"Vertical_align": "Vertical alignment",
|
|
463
463
|
"Horizontal_align": "Horizontal alignment",
|
|
464
464
|
"SeaTable_column": "SeaTable column",
|
|
465
|
-
"SeaTable_table": "SeaTable table"
|
|
465
|
+
"SeaTable_table": "SeaTable table",
|
|
466
|
+
"And_x_more_records": "and {{count}} more records",
|
|
467
|
+
"Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed"
|
|
466
468
|
}
|
|
@@ -462,5 +462,7 @@
|
|
|
462
462
|
"Vertical_align": "Vertical alignment",
|
|
463
463
|
"Horizontal_align": "Horizontal alignment",
|
|
464
464
|
"SeaTable_column": "SeaTable column",
|
|
465
|
-
"SeaTable_table": "SeaTable table"
|
|
465
|
+
"SeaTable_table": "SeaTable table",
|
|
466
|
+
"And_x_more_records": "and {{count}} more records",
|
|
467
|
+
"Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed"
|
|
466
468
|
}
|
|
@@ -462,5 +462,7 @@
|
|
|
462
462
|
"Vertical_align": "Vertical alignment",
|
|
463
463
|
"Horizontal_align": "Horizontal alignment",
|
|
464
464
|
"SeaTable_column": "SeaTable column",
|
|
465
|
-
"SeaTable_table": "SeaTable table"
|
|
465
|
+
"SeaTable_table": "SeaTable table",
|
|
466
|
+
"And_x_more_records": "and {{count}} more records",
|
|
467
|
+
"Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed"
|
|
466
468
|
}
|
|
@@ -462,5 +462,7 @@
|
|
|
462
462
|
"Vertical_align": "Вертикальное выравнивание",
|
|
463
463
|
"Horizontal_align": "Горизонтальное выравнивание",
|
|
464
464
|
"SeaTable_column": "Столбец SeaTable",
|
|
465
|
-
"SeaTable_table": "SeaTable
|
|
465
|
+
"SeaTable_table": "Таблица SeaTable",
|
|
466
|
+
"And_x_more_records": "and {{count}} more records",
|
|
467
|
+
"Print_limit_exceeded": "Exceeding the print limit, only the first 200 lines will be printed"
|
|
466
468
|
}
|
|
@@ -462,5 +462,7 @@
|
|
|
462
462
|
"Vertical_align": "垂直对齐",
|
|
463
463
|
"Horizontal_align": "水平对齐",
|
|
464
464
|
"SeaTable_column": "SeaTable 列",
|
|
465
|
-
"SeaTable_table": "SeaTable 子表"
|
|
465
|
+
"SeaTable_table": "SeaTable 子表",
|
|
466
|
+
"And_x_more_records": "以及另外 {{count}} 条记录",
|
|
467
|
+
"Print_limit_exceeded": "超过打印限制, 只会打印前 200 行"
|
|
466
468
|
}
|