@seafile/sdoc-editor 0.5.78 → 0.5.79

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.
@@ -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: records.slice(0, 10),
60
+ records: shownRecords,
54
61
  columns: columns,
55
62
  getTableCellValue: getTableCellValue
56
- })), isShowMoreMessage && /*#__PURE__*/React.createElement("div", {
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
- }))), children);
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;
@@ -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 38 + 48 + 49 + 37;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.5.78",
3
+ "version": "0.5.79",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -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 table"
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
  }