@seafile/sdoc-editor 0.5.77 → 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.
@@ -45,7 +45,6 @@
45
45
  .sdoc-dropdown-menu .sdoc-dropdown-menu-item .sdoc-dropdown-item-content {
46
46
  display: flex;
47
47
  align-items: center;
48
- justify-content: space-between;
49
48
  flex: 1;
50
49
  font-size: 14px;
51
50
  }
@@ -65,6 +65,7 @@ const EditorComment = _ref => {
65
65
  zIndex: Z_INDEX.COMMENT_ADD
66
66
  };
67
67
  }, [selectionElement, element_comments_map, cursor.y, isShowComments]);
68
+ if (!selectionElement) return null;
68
69
  return /*#__PURE__*/React.createElement("div", {
69
70
  className: "sdoc-comment-container"
70
71
  }, /*#__PURE__*/React.createElement("div", {
@@ -2,3 +2,7 @@
2
2
  .sdoc-dropdown-item-with-left-icon .sdoc-dropdown-item-content .sdoc-dropdown-item-content-icon {
3
3
  color: #444;
4
4
  }
5
+
6
+ .sdoc-link-dropdown-menu-item .sdoc-dropdown-item-content{
7
+ justify-content: space-between;
8
+ }
@@ -28,7 +28,8 @@ const DropdownMenuItem = _ref => {
28
28
  return /*#__PURE__*/React.createElement("div", {
29
29
  className: classnames('sdoc-dropdown-menu-item', className, {
30
30
  'disabled': disabled,
31
- 'sdoc-dropdown-item-with-left-icon': iconClass
31
+ 'sdoc-dropdown-item-with-left-icon': iconClass,
32
+ 'sdoc-link-dropdown-menu-item': shortcut
32
33
  }),
33
34
  id: menuConfig.id || '',
34
35
  onClick: disabled ? () => {} : onClick || (() => {})
@@ -67,8 +67,7 @@ const CodeBlock = _ref => {
67
67
  });
68
68
  focusEditor(editor);
69
69
  Transforms.select(editor, editor.selection);
70
- // eslint-disable-next-line react-hooks/exhaustive-deps
71
- }, []);
70
+ }, [editor, element]);
72
71
  const onFocusCodeBlock = useCallback(e => {
73
72
  if (readOnly) return;
74
73
  if (codeBlockRef.current) {
@@ -1,7 +1,7 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React from 'react';
3
3
  import { Node, Range } from '@seafile/slate';
4
- import { useSelected, useSlateStatic } from '@seafile/slate-react';
4
+ import { ReactEditor, useSelected, useSlateStatic } from '@seafile/slate-react';
5
5
  import { Placeholder } from '../../core';
6
6
  import { isEmptyNode } from './helper';
7
7
  import { COMMENT_EDITOR, WIKI_EDITOR } from '../../../constants';
@@ -33,7 +33,7 @@ const Paragraph = _ref => {
33
33
  const node = editor.children[1];
34
34
  isShowPlaceHolder = Node.string(element) === '' && (node === null || node === void 0 ? void 0 : node.id) === (element === null || element === void 0 ? void 0 : element.id) && !isComposing;
35
35
  }
36
- if (isSelected && isWikiEditor && Range.isCollapsed(editor.selection) && isEmptyNode(element) && !isComposing) {
36
+ if (isSelected && isWikiEditor && Range.isCollapsed(editor.selection) && isEmptyNode(element) && ReactEditor.findPath(editor, element).length === 1 && !isComposing) {
37
37
  isShowPlaceHolder = true;
38
38
  }
39
39
  const style = {
@@ -69,7 +69,7 @@
69
69
 
70
70
  .sdoc-link-hover-menu-container .hover-menu-container .icon-font {
71
71
  font-size: 12px;
72
- color: #999999;
72
+ color: #444;
73
73
  }
74
74
 
75
75
  .sdoc-link-hover-menu-container .sdoc-file-display-style-popover {
@@ -1,8 +1,7 @@
1
1
  .seatable-view-container {
2
2
  width: 100%;
3
- min-height: 200px;
4
- max-height: 400px;
5
3
  overflow: auto;
4
+ border: 1px solid transparent;
6
5
  }
7
6
 
8
7
  .seatable-view-container.selected {
@@ -1,6 +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
- import { useSelected } from '@seafile/slate-react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { useReadOnly, useSelected } from '@seafile/slate-react';
4
5
  import Loading from '../../../../../components/loading';
5
6
  import RecordHeader from './record-header';
6
7
  import RecordList from './record-list';
@@ -11,25 +12,33 @@ function SeaTableTable(_ref) {
11
12
  className,
12
13
  attributes,
13
14
  children,
14
- editor,
15
- t
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);
24
+ const {
25
+ t
26
+ } = useTranslation();
21
27
  useEffect(() => {
22
28
  const {
23
29
  table_id
24
30
  } = element;
25
31
  const table = editor.getTableById(table_id);
26
- // todo
27
- const rows = table.rows.slice(0, 50);
28
- setRecords(rows);
29
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);
30
39
  setIsLoading(false);
31
40
  // eslint-disable-next-line react-hooks/exhaustive-deps
32
- }, [element]);
41
+ }, [element, isReadOnly]);
33
42
  const containerClass = classNames('seatable-view-container', {
34
43
  selected: isSelected
35
44
  });
@@ -42,15 +51,21 @@ function SeaTableTable(_ref) {
42
51
  return /*#__PURE__*/React.createElement("div", Object.assign({}, attributes, {
43
52
  className: containerClass,
44
53
  contentEditable: false
45
- }), isLoading && /*#__PURE__*/React.createElement(Loading, null), !isLoading && /*#__PURE__*/React.createElement("table", {
54
+ }), isLoading && /*#__PURE__*/React.createElement(Loading, null), !isLoading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("table", {
46
55
  className: "seatable-view-records"
47
56
  }, /*#__PURE__*/React.createElement(RecordHeader, {
48
57
  columns: columns
49
58
  }), /*#__PURE__*/React.createElement(RecordList, {
50
59
  editor: editor,
51
- records: records,
60
+ records: shownRecords,
52
61
  columns: columns,
53
62
  getTableCellValue: getTableCellValue
54
- })), children);
63
+ })), !isReadOnly && isShowTipMessage && /*#__PURE__*/React.createElement("div", {
64
+ className: "d-print-none ml-2 m-2"
65
+ }, t('And_x_more_records', {
66
+ count: records.length - 10
67
+ })), isReadOnly && isShowTipMessage && /*#__PURE__*/React.createElement("div", {
68
+ className: "d-print-none ml-2 m-2"
69
+ }, t('Print_limit_exceeded'))), children);
55
70
  }
56
71
  export default SeaTableTable;
@@ -0,0 +1,6 @@
1
+ .sdocfont.sdoc-check-mark {
2
+ position: absolute;
3
+ left: 8px;
4
+ transform: scale(.8);
5
+ color: #798d99;
6
+ }
@@ -5,6 +5,7 @@ import classnames from 'classnames';
5
5
  import { getAlignType, isMenuDisabled, setAlignType } from '../helpers';
6
6
  import { TEXT_ALIGN, MENUS_CONFIG_MAP } from '../../../constants';
7
7
  import Tooltip from '../../../../../components/tooltip';
8
+ import './index.css';
8
9
  const TextAlignMenu = _ref => {
9
10
  let {
10
11
  isRichEditor,
@@ -42,9 +43,10 @@ const TextAlignMenu = _ref => {
42
43
  'rich-icon-btn-hover': isRichEditor && !disabled,
43
44
  'btn btn-icon btn-secondary btn-active d-flex': !isRichEditor
44
45
  });
45
- const curType = getCurrentType();
46
+ let curType = getCurrentType();
46
47
  const curIcon = MENUS_CONFIG_MAP[TEXT_ALIGN].filter(item => item.type === curType)[0].iconClass;
47
48
  const caretIconClass = "sdoc-menu-with-dropdown-triangle-icon sdocfont sdoc-".concat(isShowMenu ? 'caret-up' : 'drop-down');
49
+ curType = 'align_' + curType;
48
50
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
49
51
  type: "button",
50
52
  className: validClassName,
@@ -72,11 +74,14 @@ const TextAlignMenu = _ref => {
72
74
  }, /*#__PURE__*/React.createElement("div", {
73
75
  className: "pt-2 pb-2"
74
76
  }, MENUS_CONFIG_MAP[TEXT_ALIGN].map((item, index) => {
77
+ const isSelected = curType === item.id;
75
78
  return /*#__PURE__*/React.createElement("div", {
76
79
  key: index,
77
80
  className: "sdoc-dropdown-menu-item",
78
81
  onClick: () => setType(item.type)
79
- }, /*#__PURE__*/React.createElement("i", {
82
+ }, isSelected && /*#__PURE__*/React.createElement("i", {
83
+ className: "sdocfont sdoc-check-mark"
84
+ }), /*#__PURE__*/React.createElement("i", {
80
85
  className: item.iconClass
81
86
  }));
82
87
  }))));
@@ -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.77",
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
  }
@@ -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": "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
  }