@seafile/sdoc-editor 0.5.76 → 0.5.78

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.
Files changed (27) hide show
  1. package/dist/basic-sdk/assets/css/dropdown-menu.css +0 -1
  2. package/dist/basic-sdk/comment/components/editor-comment.js +1 -0
  3. package/dist/basic-sdk/constants/index.js +1 -0
  4. package/dist/basic-sdk/extension/commons/dropdown-menu-item/index.css +4 -0
  5. package/dist/basic-sdk/extension/commons/dropdown-menu-item/index.js +2 -1
  6. package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +1 -2
  7. package/dist/basic-sdk/extension/plugins/paragraph/render-elem.js +2 -2
  8. package/dist/basic-sdk/extension/plugins/sdoc-link/hover-menu/index.css +1 -1
  9. package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/index.css +1 -2
  10. package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/seatable-table.js +14 -8
  11. package/dist/basic-sdk/extension/plugins/text-align/menu/index.css +6 -0
  12. package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +7 -2
  13. package/dist/basic-sdk/extension/toolbar/side-toolbar/index.css +14 -1
  14. package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +15 -6
  15. package/dist/basic-sdk/utils/dom-utils.js +3 -1
  16. package/dist/pages/document-plugin-editor.js +2 -2
  17. package/package.json +1 -1
  18. package/public/locales/cs/sdoc-editor.json +1 -1
  19. package/public/locales/de/sdoc-editor.json +1 -1
  20. package/public/locales/en/sdoc-editor.json +2 -1
  21. package/public/locales/es/sdoc-editor.json +1 -1
  22. package/public/locales/es_AR/sdoc-editor.json +1 -1
  23. package/public/locales/es_MX/sdoc-editor.json +1 -1
  24. package/public/locales/fr/sdoc-editor.json +1 -1
  25. package/public/locales/it/sdoc-editor.json +1 -1
  26. package/public/locales/ru/sdoc-editor.json +2 -2
  27. package/public/locales/zh_CN/sdoc-editor.json +1 -1
@@ -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", {
@@ -33,6 +33,7 @@ export const PAGE_EDIT_AREA_WIDTH = 672; // 672 = 794 - 2[borderLeft + borderRig
33
33
  export const COMMENT_EDITOR_EDIT_AREA_WIDTH = 364;
34
34
  export const COMMENT_EDITOR = 'comment_editor';
35
35
  export const WIKI_EDITOR = 'wiki_editor';
36
+ export const DOCUMENT_PLUGIN_EDITOR = 'document_plugin_editor';
36
37
  export const MODIFY_TYPE = {
37
38
  ADD: 'add',
38
39
  DELETE: 'delete',
@@ -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)) {
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,5 +1,6 @@
1
1
  import React, { useCallback, useEffect, useState } from 'react';
2
2
  import classNames from 'classnames';
3
+ import { useTranslation } from 'react-i18next';
3
4
  import { useSelected } from '@seafile/slate-react';
4
5
  import Loading from '../../../../../components/loading';
5
6
  import RecordHeader from './record-header';
@@ -11,21 +12,21 @@ 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
18
  const [isLoading, setIsLoading] = useState(true);
19
19
  const [records, setRecords] = useState([]);
20
20
  const [columns, setColumns] = useState([]);
21
+ const {
22
+ t
23
+ } = useTranslation();
21
24
  useEffect(() => {
22
25
  const {
23
26
  table_id
24
27
  } = element;
25
28
  const table = editor.getTableById(table_id);
26
- // todo
27
- const rows = table.rows.slice(0, 50);
28
- setRecords(rows);
29
+ setRecords(table.rows);
29
30
  setColumns(table.columns);
30
31
  setIsLoading(false);
31
32
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -39,18 +40,23 @@ function SeaTableTable(_ref) {
39
40
  } = element;
40
41
  return editor.getTableCellValue(table_id, row, column);
41
42
  }, [editor, element]);
43
+ const isShowMoreMessage = records.length - 10 > 0 ? true : false;
42
44
  return /*#__PURE__*/React.createElement("div", Object.assign({}, attributes, {
43
45
  className: containerClass,
44
46
  contentEditable: false
45
- }), isLoading && /*#__PURE__*/React.createElement(Loading, null), !isLoading && /*#__PURE__*/React.createElement("table", {
47
+ }), isLoading && /*#__PURE__*/React.createElement(Loading, null), !isLoading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("table", {
46
48
  className: "seatable-view-records"
47
49
  }, /*#__PURE__*/React.createElement(RecordHeader, {
48
50
  columns: columns
49
51
  }), /*#__PURE__*/React.createElement(RecordList, {
50
52
  editor: editor,
51
- records: records,
53
+ records: records.slice(0, 10),
52
54
  columns: columns,
53
55
  getTableCellValue: getTableCellValue
54
- })), children);
56
+ })), isShowMoreMessage && /*#__PURE__*/React.createElement("div", {
57
+ className: "ml-2 m-2"
58
+ }, t('And_x_more_records', {
59
+ count: records.length - 10
60
+ }))), children);
55
61
  }
56
62
  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
  }))));
@@ -8,7 +8,6 @@
8
8
  width: 24px;
9
9
  height: 24px;
10
10
  border-radius: 3px;
11
- transition: all 0.2s;
12
11
  }
13
12
 
14
13
  .sdoc-side-toolbar-container:hover {
@@ -32,3 +31,17 @@
32
31
  background-color: #F2F2F2;
33
32
  border-radius: 2px;
34
33
  }
34
+
35
+ @keyframes fade-out {
36
+ from {
37
+ opacity: 1;
38
+ }
39
+
40
+ to {
41
+ opacity: 0.3;
42
+ }
43
+ }
44
+
45
+ .fade-out {
46
+ animation: fade-out 0.15s ease-out;
47
+ }
@@ -24,6 +24,7 @@ const SideToolbar = () => {
24
24
  const [isShowSideMenu, setShowSideMenu] = useState(false);
25
25
  const [menuPosition, setMenuPosition] = useState({});
26
26
  const [isEnterMoreVertical, setIsEnterMoreVertical] = useState(false);
27
+ const [isMoving, setIsMoving] = useState(false);
27
28
  const sideMenuRef = useRef();
28
29
  const onReset = useCallback(() => {
29
30
  setShowSideMenu(false);
@@ -74,10 +75,15 @@ const SideToolbar = () => {
74
75
  const top = getDomTopHeight(editor, dom, node);
75
76
  const isEmpty = isVoidNode(node);
76
77
  const offsetY = !editor.editorType ? -1 : 0; // editorType is undefined means sdoc editor
77
- setSidePosition({
78
- top: top + scrollRef.current.scrollTop + offsetY,
79
- left: 20
80
- });
78
+ const topValue = top + scrollRef.current.scrollTop + offsetY;
79
+ if (topValue !== sidePosition.top) setIsMoving(true);
80
+ setTimeout(() => {
81
+ // wait animation
82
+ setSidePosition({
83
+ top: topValue,
84
+ left: 20
85
+ });
86
+ }, 150);
81
87
  setSlateNode(node);
82
88
  setNodeEmpty(isEmpty);
83
89
  };
@@ -86,7 +92,7 @@ const SideToolbar = () => {
86
92
  return unSubscribeMouseEnter;
87
93
 
88
94
  // eslint-disable-next-line react-hooks/exhaustive-deps
89
- }, [editor, isShowSideMenu, scrollRef]);
95
+ }, [editor, isShowSideMenu, scrollRef, sidePosition.top]);
90
96
  const onShowSideMenuToggle = useCallback(() => {
91
97
  setSelection(editor, slateNode);
92
98
  const {
@@ -249,7 +255,10 @@ const SideToolbar = () => {
249
255
  setIsEnterMoreVertical(false);
250
256
  }, []);
251
257
  return /*#__PURE__*/React.createElement("div", {
252
- className: "sdoc-side-toolbar-container",
258
+ onAnimationEnd: () => setIsMoving(false),
259
+ className: classnames('sdoc-side-toolbar-container', {
260
+ 'fade-out': isMoving
261
+ }),
253
262
  style: sidePosition
254
263
  }, slateNode && /*#__PURE__*/React.createElement("div", {
255
264
  ref: menuRef,
@@ -1,4 +1,4 @@
1
- import { WIKI_EDITOR } from '../constants';
1
+ import { WIKI_EDITOR, DOCUMENT_PLUGIN_EDITOR } from '../constants';
2
2
  export const getDomHeight = dom => {
3
3
  const styles = window.getComputedStyle(dom);
4
4
  const rect = dom.getBoundingClientRect();
@@ -59,6 +59,8 @@ export const getHeaderHeight = editor => {
59
59
  switch (editorType) {
60
60
  case WIKI_EDITOR:
61
61
  return 113.2;
62
+ case DOCUMENT_PLUGIN_EDITOR:
63
+ return 38 + 48 + 49 + 37;
62
64
  default:
63
65
  // sdoc-editor-page-header height = 56
64
66
  // sdoc-editor-toolbar height = 37
@@ -2,7 +2,7 @@ import React, { useEffect, useMemo } from 'react';
2
2
  import { withTranslation } from 'react-i18next';
3
3
  import context from '../context';
4
4
  import { SDocEditor } from '../basic-sdk';
5
- import { PAGE_EDIT_AREA_WIDTH } from '../basic-sdk/constants';
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';
8
8
  import { withSocketIO } from '../basic-sdk/socket';
@@ -50,7 +50,7 @@ const DocumentPluginEditor = _ref => {
50
50
  newEditor.getTableCellValue = getTableCellValue;
51
51
  newEditor.cursors = cursors || {};
52
52
  newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
53
-
53
+ newEditor.editorType = DOCUMENT_PLUGIN_EDITOR;
54
54
  return newEditor;
55
55
  // eslint-disable-next-line react-hooks/exhaustive-deps
56
56
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.5.76",
3
+ "version": "0.5.78",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -462,5 +462,5 @@
462
462
  "Vertical_align": "Vertical alignment",
463
463
  "Horizontal_align": "Horizontal alignment",
464
464
  "SeaTable_column": "SeaTable column",
465
- "SeaTable_view": "SeaTable view"
465
+ "SeaTable_table": "SeaTable table"
466
466
  }
@@ -462,5 +462,5 @@
462
462
  "Vertical_align": "Vertical alignment",
463
463
  "Horizontal_align": "Horizontal alignment",
464
464
  "SeaTable_column": "SeaTable column",
465
- "SeaTable_view": "SeaTable view"
465
+ "SeaTable_table": "SeaTable table"
466
466
  }
@@ -462,5 +462,6 @@
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"
466
467
  }
@@ -462,5 +462,5 @@
462
462
  "Vertical_align": "Vertical alignment",
463
463
  "Horizontal_align": "Horizontal alignment",
464
464
  "SeaTable_column": "SeaTable column",
465
- "SeaTable_view": "SeaTable view"
465
+ "SeaTable_table": "SeaTable table"
466
466
  }
@@ -462,5 +462,5 @@
462
462
  "Vertical_align": "Vertical alignment",
463
463
  "Horizontal_align": "Horizontal alignment",
464
464
  "SeaTable_column": "SeaTable column",
465
- "SeaTable_view": "SeaTable view"
465
+ "SeaTable_table": "SeaTable table"
466
466
  }
@@ -462,5 +462,5 @@
462
462
  "Vertical_align": "Vertical alignment",
463
463
  "Horizontal_align": "Horizontal alignment",
464
464
  "SeaTable_column": "SeaTable column",
465
- "SeaTable_view": "SeaTable view"
465
+ "SeaTable_table": "SeaTable table"
466
466
  }
@@ -462,5 +462,5 @@
462
462
  "Vertical_align": "Vertical alignment",
463
463
  "Horizontal_align": "Horizontal alignment",
464
464
  "SeaTable_column": "SeaTable column",
465
- "SeaTable_view": "SeaTable view"
465
+ "SeaTable_table": "SeaTable table"
466
466
  }
@@ -462,5 +462,5 @@
462
462
  "Vertical_align": "Vertical alignment",
463
463
  "Horizontal_align": "Horizontal alignment",
464
464
  "SeaTable_column": "SeaTable column",
465
- "SeaTable_view": "SeaTable view"
465
+ "SeaTable_table": "SeaTable table"
466
466
  }
@@ -461,6 +461,6 @@
461
461
  "Enter_text_or_press_forward_slash_to_insert_element": "Введите текст или нажмите '/', чтобы вставить элемент",
462
462
  "Vertical_align": "Вертикальное выравнивание",
463
463
  "Horizontal_align": "Горизонтальное выравнивание",
464
- "SeaTable_column": "SeaTable column",
465
- "SeaTable_view": "SeaTable view"
464
+ "SeaTable_column": "Столбец SeaTable",
465
+ "SeaTable_table": "SeaTable table"
466
466
  }
@@ -462,5 +462,5 @@
462
462
  "Vertical_align": "垂直对齐",
463
463
  "Horizontal_align": "水平对齐",
464
464
  "SeaTable_column": "SeaTable 列",
465
- "SeaTable_view": "SeaTable 视图"
465
+ "SeaTable_table": "SeaTable 子表"
466
466
  }