@seafile/sdoc-editor 0.5.74 → 0.5.76

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 (40) hide show
  1. package/dist/basic-sdk/extension/constants/element-type.js +1 -1
  2. package/dist/basic-sdk/extension/constants/index.js +2 -2
  3. package/dist/basic-sdk/extension/constants/menus-config.js +6 -6
  4. package/dist/basic-sdk/extension/plugins/index.js +1 -1
  5. package/dist/basic-sdk/extension/plugins/paragraph/render-elem.js +8 -3
  6. package/dist/basic-sdk/extension/plugins/{seatable-views → seatable-tables}/helpers.js +6 -9
  7. package/dist/basic-sdk/extension/plugins/{seatable-views → seatable-tables}/index.js +4 -4
  8. package/dist/basic-sdk/extension/plugins/{seatable-views → seatable-tables}/menu/index.js +9 -9
  9. package/dist/basic-sdk/extension/plugins/seatable-tables/model.js +11 -0
  10. package/dist/basic-sdk/extension/plugins/{seatable-views → seatable-tables}/plugin.js +6 -6
  11. package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/index.js +8 -0
  12. package/dist/basic-sdk/extension/plugins/{seatable-views → seatable-tables}/render-element/record-item.js +2 -3
  13. package/dist/basic-sdk/extension/plugins/{seatable-views → seatable-tables}/render-element/record-list.js +2 -4
  14. package/dist/basic-sdk/extension/plugins/{seatable-views/render-element/seatable-view.js → seatable-tables/render-element/seatable-table.js} +11 -12
  15. package/dist/basic-sdk/extension/render/custom-element.js +4 -4
  16. package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +2 -2
  17. package/dist/basic-sdk/extension/toolbar/side-toolbar/index.css +12 -2
  18. package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +13 -3
  19. package/dist/pages/document-plugin-editor.js +11 -8
  20. package/package.json +2 -1
  21. package/public/locales/cs/sdoc-editor.json +4 -3
  22. package/public/locales/de/sdoc-editor.json +4 -3
  23. package/public/locales/en/sdoc-editor.json +1 -1
  24. package/public/locales/es/sdoc-editor.json +4 -3
  25. package/public/locales/es_AR/sdoc-editor.json +4 -3
  26. package/public/locales/es_MX/sdoc-editor.json +4 -3
  27. package/public/locales/fr/sdoc-editor.json +4 -3
  28. package/public/locales/it/sdoc-editor.json +4 -3
  29. package/public/locales/ru/sdoc-editor.json +5 -4
  30. package/public/locales/zh_CN/sdoc-editor.json +4 -3
  31. package/public/media/sdoc-editor-font/iconfont.eot +0 -0
  32. package/public/media/sdoc-editor-font/iconfont.svg +3 -1
  33. package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
  34. package/public/media/sdoc-editor-font/iconfont.woff +0 -0
  35. package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
  36. package/public/media/sdoc-editor-font.css +11 -7
  37. package/dist/basic-sdk/extension/plugins/seatable-views/model.js +0 -12
  38. package/dist/basic-sdk/extension/plugins/seatable-views/render-element/index.js +0 -8
  39. /package/dist/basic-sdk/extension/plugins/{seatable-views → seatable-tables}/render-element/index.css +0 -0
  40. /package/dist/basic-sdk/extension/plugins/{seatable-views → seatable-tables}/render-element/record-header.js +0 -0
@@ -30,7 +30,7 @@ export const MENTION_TEMP = 'mention_temp';
30
30
  export const FILE_LINK_INSET_INPUT_TEMP = 'file_link_insert_input_temp';
31
31
  export const QUICK_INSERT = 'quick_insert';
32
32
  export const COLUMN = 'column';
33
- export const SEATABLE_VIEW = 'seatable_view';
33
+ export const SEATABLE_TABLE = 'seatable_table';
34
34
 
35
35
  // font
36
36
  export const FONT_SIZE = 'font-size';
@@ -1,7 +1,7 @@
1
1
  // extension plugin
2
2
  import * as ELEMENT_TYPE from './element-type';
3
3
  // eslint-disable-next-line no-duplicate-imports
4
- import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, IMAGE_BLOCK, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT, MENTION, MENTION_TEMP, FILE_LINK_INSET_INPUT_TEMP, QUICK_INSERT, COLUMN, SEATABLE_VIEW } from './element-type';
4
+ import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, IMAGE_BLOCK, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT, MENTION, MENTION_TEMP, FILE_LINK_INSET_INPUT_TEMP, QUICK_INSERT, COLUMN, SEATABLE_TABLE } from './element-type';
5
5
  export { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, DEFAULT_FONT_COLOR, RECENT_USED_HIGHLIGHT_COLORS_KEY, RECENT_USED_FONT_COLORS_KEY, RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY, DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR } from './color';
6
6
  export { FONT_SIZE, DEFAULT_FONT, FONT, GOOGLE_FONT_CLASS, RECENT_USED_FONTS_KEY, SDOC_FONT_SIZE } from './font';
7
7
  export { DIFF_TYPE, ADDED_STYLE, DELETED_STYLE } from './diff-view';
@@ -57,4 +57,4 @@ export const MOUSE_ENTER_EVENT_DISABLED_MAP = {
57
57
  [CALL_OUT]: [CALL_OUT]
58
58
  };
59
59
  export const ROOT_ELEMENT_TYPES = [PARAGRAPH, TITLE, SUBTITLE, CHECK_LIST_ITEM, ORDERED_LIST, UNORDERED_LIST, BLOCKQUOTE, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, CALL_OUT, TABLE, CODE_BLOCK, IMAGE_BLOCK];
60
- export { ELEMENT_TYPE, BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, IMAGE_BLOCK, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT, MENTION, MENTION_TEMP, FILE_LINK_INSET_INPUT_TEMP, QUICK_INSERT, SEATABLE_VIEW };
60
+ export { ELEMENT_TYPE, BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, IMAGE_BLOCK, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT, MENTION, MENTION_TEMP, FILE_LINK_INSET_INPUT_TEMP, QUICK_INSERT, SEATABLE_TABLE };
@@ -1,5 +1,5 @@
1
1
  import { RECENT_USED_HIGHLIGHT_COLORS_KEY, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, RECENT_USED_FONT_COLORS_KEY, DEFAULT_FONT_COLOR, DEFAULT_LAST_USED_FONT_COLOR } from './color';
2
- import { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST_ITEM, CODE_BLOCK, LINK, IMAGE, TABLE, SDOC_LINK, FILE_LINK, PARAGRAPH, CALL_OUT, COLUMN, SEATABLE_VIEW } from './element-type';
2
+ import { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST_ITEM, CODE_BLOCK, LINK, IMAGE, TABLE, SDOC_LINK, FILE_LINK, PARAGRAPH, CALL_OUT, COLUMN, SEATABLE_TABLE } from './element-type';
3
3
  export const UNDO = 'undo';
4
4
  export const REDO = 'redo';
5
5
  export const CLEAR_FORMAT = 'clear_format';
@@ -197,11 +197,11 @@ export const MENUS_CONFIG_MAP = {
197
197
  iconClass: 'sdocfont sdoc-choose-column',
198
198
  text: 'SeaTable_column'
199
199
  },
200
- [SEATABLE_VIEW]: {
201
- id: SEATABLE_VIEW,
202
- iconClass: 'sdocfont sdoc-seatable-view',
203
- type: SEATABLE_VIEW,
204
- text: 'SeaTable_view'
200
+ [SEATABLE_TABLE]: {
201
+ id: SEATABLE_TABLE,
202
+ iconClass: 'sdocfont sdoc-seatable-table',
203
+ type: SEATABLE_TABLE,
204
+ text: 'SeaTable_table'
205
205
  }
206
206
  };
207
207
 
@@ -20,7 +20,7 @@ import MentionPlugin from './mention';
20
20
  import QuickInsertPlugin from './quick-insert';
21
21
  import WikiLinkPlugin from './wiki-link';
22
22
  import SeaTableColumnPlugin from './seatable-column';
23
- import SeaTableViewsPlugin from './seatable-views';
23
+ import SeaTableViewsPlugin from './seatable-tables';
24
24
  const Plugins = [MarkDownPlugin, HtmlPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, SearchReplacePlugin];
25
25
  const WikiPlugins = [...Plugins, QuickInsertPlugin, WikiLinkPlugin];
26
26
  const CommentPlugins = [MarkDownPlugin, HtmlPlugin, ParagraphPlugin, TextPlugin, ListPlugin, ImagePlugin, LinkPlugin, MentionPlugin, BlockquotePlugin];
@@ -1,10 +1,10 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React from 'react';
3
- import { Node } from '@seafile/slate';
4
- import { useSlateStatic } from '@seafile/slate-react';
3
+ import { Node, Range } from '@seafile/slate';
4
+ import { useSelected, useSlateStatic } from '@seafile/slate-react';
5
5
  import { Placeholder } from '../../core';
6
6
  import { isEmptyNode } from './helper';
7
- import { COMMENT_EDITOR } from '../../../constants';
7
+ import { COMMENT_EDITOR, WIKI_EDITOR } from '../../../constants';
8
8
  const PLACEHOLDER = 'Please_enter_text';
9
9
  const Paragraph = _ref => {
10
10
  let {
@@ -19,7 +19,9 @@ const Paragraph = _ref => {
19
19
  indent
20
20
  } = element;
21
21
  const editor = useSlateStatic();
22
+ const isSelected = useSelected();
22
23
  const isCommentEditor = editor.editorType === COMMENT_EDITOR;
24
+ const isWikiEditor = editor.editorType === WIKI_EDITOR;
23
25
  let isShowPlaceHolder = false;
24
26
  if (editor.children.length === 1) {
25
27
  const node = editor.children[0];
@@ -31,6 +33,9 @@ const Paragraph = _ref => {
31
33
  const node = editor.children[1];
32
34
  isShowPlaceHolder = Node.string(element) === '' && (node === null || node === void 0 ? void 0 : node.id) === (element === null || element === void 0 ? void 0 : element.id) && !isComposing;
33
35
  }
36
+ if (isSelected && isWikiEditor && Range.isCollapsed(editor.selection) && isEmptyNode(element)) {
37
+ isShowPlaceHolder = true;
38
+ }
34
39
  const style = {
35
40
  textAlign: element.align,
36
41
  paddingTop: '5px',
@@ -1,8 +1,8 @@
1
1
  import { Editor, Transforms } from '@seafile/slate';
2
2
  import slugId from 'slugid';
3
3
  import { getNodeType, isTextNode, getParentNode, generateDefaultText } from '../../core';
4
- import { ELEMENT_TYPE, SEATABLE_VIEW } from '../../constants';
5
- export const isInsertSeaTableViewDisabled = (editor, readonly) => {
4
+ import { ELEMENT_TYPE, SEATABLE_TABLE } from '../../constants';
5
+ export const isInsertSeaTableTableDisabled = (editor, readonly) => {
6
6
  if (readonly) return true;
7
7
  const {
8
8
  selection
@@ -33,18 +33,15 @@ export const isInsertSeaTableViewDisabled = (editor, readonly) => {
33
33
  if (match) return true;
34
34
  return false;
35
35
  };
36
- export const generateSeaTableView = (table_id, view_id) => {
36
+ export const generateSeaTableTable = table_id => {
37
37
  return {
38
38
  id: slugId.nice(),
39
- type: SEATABLE_VIEW,
39
+ type: SEATABLE_TABLE,
40
40
  table_id,
41
- view_id,
42
41
  children: [generateDefaultText()]
43
42
  };
44
43
  };
45
- export const insertSeaTableView = (editor, item) => {
46
- const table_id = editor.table_id;
47
- const view_id = item._id;
48
- const node = generateSeaTableView(table_id, view_id);
44
+ export const insertSeaTableTable = (editor, item) => {
45
+ const node = generateSeaTableTable(item._id);
49
46
  Transforms.setNodes(editor, node);
50
47
  };
@@ -1,14 +1,14 @@
1
- import { SEATABLE_VIEW } from '../../constants';
1
+ import { SEATABLE_TABLE } from '../../constants';
2
2
  import ImageMenu from './menu';
3
3
  import SeaTableView from './model';
4
4
  import withSeaTableView from './plugin';
5
5
  import renderSeaTableView from './render-element';
6
- const SeaTableViewsPlugin = {
7
- type: SEATABLE_VIEW,
6
+ const SeaTableTablesPlugin = {
7
+ type: SEATABLE_TABLE,
8
8
  nodeType: 'element',
9
9
  model: SeaTableView,
10
10
  editorMenus: [ImageMenu],
11
11
  editorPlugin: withSeaTableView,
12
12
  renderElements: [renderSeaTableView]
13
13
  };
14
- export default SeaTableViewsPlugin;
14
+ export default SeaTableTablesPlugin;
@@ -1,18 +1,18 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { UncontrolledPopover } from 'reactstrap';
3
- import { insertSeaTableView, isInsertSeaTableViewDisabled } from '../helpers';
4
- import { MENUS_CONFIG_MAP, SEATABLE_VIEW } from '../../../constants';
3
+ import { insertSeaTableTable, isInsertSeaTableTableDisabled } from '../helpers';
4
+ import { MENUS_CONFIG_MAP, SEATABLE_TABLE } from '../../../constants';
5
5
  import DropdownMenuItem from '../../../commons/dropdown-menu-item';
6
- const SeaTableViewMenu = _ref => {
6
+ const SeaTableTableMenu = _ref => {
7
7
  let {
8
8
  editor,
9
9
  readonly
10
10
  } = _ref;
11
- const disabled = isInsertSeaTableViewDisabled(editor, readonly);
12
- const menuConfig = MENUS_CONFIG_MAP[SEATABLE_VIEW];
13
- const views = editor.views;
11
+ const disabled = isInsertSeaTableTableDisabled(editor, readonly);
12
+ const menuConfig = MENUS_CONFIG_MAP[SEATABLE_TABLE];
13
+ const tables = editor.tables;
14
14
  const onViewClick = useCallback(item => {
15
- insertSeaTableView(editor, item);
15
+ insertSeaTableTable(editor, item);
16
16
  }, [editor]);
17
17
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownMenuItem, {
18
18
  disabled: disabled,
@@ -29,7 +29,7 @@ const SeaTableViewMenu = _ref => {
29
29
  fade: false
30
30
  }, /*#__PURE__*/React.createElement("div", {
31
31
  className: "sdoc-dropdown-menu-container"
32
- }, views.map(item => {
32
+ }, tables.map(item => {
33
33
  return /*#__PURE__*/React.createElement("div", {
34
34
  key: item._id,
35
35
  className: "sdoc-dropdown-menu-item",
@@ -37,4 +37,4 @@ const SeaTableViewMenu = _ref => {
37
37
  }, item.name);
38
38
  }))));
39
39
  };
40
- export default SeaTableViewMenu;
40
+ export default SeaTableTableMenu;
@@ -0,0 +1,11 @@
1
+ import { SEATABLE_TABLE } from '../../constants/element-type';
2
+ class SeaTableTable {
3
+ constructor(options) {
4
+ this.type = options.type || SEATABLE_TABLE;
5
+ this.table_id = options.table_id;
6
+ this.children = options.children || [{
7
+ text: ''
8
+ }];
9
+ }
10
+ }
11
+ export default SeaTableTable;
@@ -1,6 +1,6 @@
1
1
  import { Transforms, Path, Editor, Element, Range } from '@seafile/slate';
2
2
  import { focusEditor, generateEmptyElement, getNodeType, isBlockAboveEmpty, isLastNode } from '../../core';
3
- import { PARAGRAPH, SEATABLE_VIEW } from '../../constants/element-type';
3
+ import { PARAGRAPH, SEATABLE_TABLE } from '../../constants/element-type';
4
4
  const withSeaTableView = editor => {
5
5
  const {
6
6
  isVoid,
@@ -14,7 +14,7 @@ const withSeaTableView = editor => {
14
14
  const {
15
15
  type
16
16
  } = elem;
17
- if (type === SEATABLE_VIEW) {
17
+ if (type === SEATABLE_TABLE) {
18
18
  return true;
19
19
  }
20
20
  return isVoid(elem);
@@ -29,16 +29,16 @@ const withSeaTableView = editor => {
29
29
  });
30
30
  if (!point) return deleteBackward(unit);
31
31
  const [node, path] = Editor.node(editor, [point.path[0], point.path[1]]);
32
- const isPerviousSeaTableView = node.type === SEATABLE_VIEW;
32
+ const isPerviousSeaTableView = node.type === SEATABLE_TABLE;
33
33
  if (isPerviousSeaTableView && Range.isCollapsed(selection) && isBlockAboveEmpty(editor) && !Path.isCommon(path, selection.anchor.path)) {
34
34
  deleteBackward(unit);
35
35
  focusEditor(newEditor, Editor.end(newEditor, focusPoint));
36
36
  return;
37
37
  }
38
- if (Element.isElement(node) && node.type === SEATABLE_VIEW) {
38
+ if (Element.isElement(node) && node.type === SEATABLE_TABLE) {
39
39
  // If the wrapping element is image_block, delete the wrapping element
40
40
  const [parentNode, p] = Editor.node(editor, [path[0]]);
41
- if (parentNode.type === SEATABLE_VIEW) {
41
+ if (parentNode.type === SEATABLE_TABLE) {
42
42
  Transforms.removeNodes(editor, {
43
43
  at: p
44
44
  });
@@ -53,7 +53,7 @@ const withSeaTableView = editor => {
53
53
  newEditor.normalizeNode = _ref => {
54
54
  let [node, path] = _ref;
55
55
  const type = getNodeType(node);
56
- if (type !== SEATABLE_VIEW) {
56
+ if (type !== SEATABLE_TABLE) {
57
57
  return normalizeNode([node, path]);
58
58
  }
59
59
 
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import SeaTableTable from './seatable-table';
3
+ const renderSeaTableTable = (props, editor) => {
4
+ return /*#__PURE__*/React.createElement(SeaTableTable, Object.assign({}, props, {
5
+ editor: editor
6
+ }));
7
+ };
8
+ export default renderSeaTableTable;
@@ -2,10 +2,9 @@ import React from 'react';
2
2
  import { getColumnWidth } from '../../seatable-column/helpers';
3
3
  export default function RecordItem(_ref) {
4
4
  let {
5
- editor,
6
5
  record,
7
6
  columns,
8
- getViewCellValue
7
+ getTableCellValue
9
8
  } = _ref;
10
9
  return /*#__PURE__*/React.createElement("tr", {
11
10
  className: "seatable-view-body-column-row"
@@ -17,6 +16,6 @@ export default function RecordItem(_ref) {
17
16
  style: {
18
17
  width
19
18
  }
20
- }, getViewCellValue(record, column));
19
+ }, getTableCellValue(record, column));
21
20
  }));
22
21
  }
@@ -4,16 +4,14 @@ export default function RecordList(_ref) {
4
4
  let {
5
5
  records,
6
6
  columns,
7
- editor,
8
- getViewCellValue
7
+ getTableCellValue
9
8
  } = _ref;
10
9
  return /*#__PURE__*/React.createElement("tbody", null, records.map(record => {
11
10
  return /*#__PURE__*/React.createElement(RecordItem, {
12
11
  key: record._id,
13
12
  record: record,
14
13
  columns: columns,
15
- editor: editor,
16
- getViewCellValue: getViewCellValue
14
+ getTableCellValue: getTableCellValue
17
15
  });
18
16
  }));
19
17
  }
@@ -5,7 +5,7 @@ import Loading from '../../../../../components/loading';
5
5
  import RecordHeader from './record-header';
6
6
  import RecordList from './record-list';
7
7
  import './index.css';
8
- function SeaTableView(_ref) {
8
+ function SeaTableTable(_ref) {
9
9
  let {
10
10
  element,
11
11
  className,
@@ -20,25 +20,24 @@ function SeaTableView(_ref) {
20
20
  const [columns, setColumns] = useState([]);
21
21
  useEffect(() => {
22
22
  const {
23
- table_id,
24
- view_id
23
+ table_id
25
24
  } = element;
26
- const rows = editor.getViewRowsById(table_id, view_id);
27
- const columns = editor.getViewColsById(table_id, view_id);
25
+ const table = editor.getTableById(table_id);
26
+ // todo
27
+ const rows = table.rows.slice(0, 50);
28
28
  setRecords(rows);
29
- setColumns(columns);
29
+ setColumns(table.columns);
30
30
  setIsLoading(false);
31
31
  // eslint-disable-next-line react-hooks/exhaustive-deps
32
32
  }, [element]);
33
33
  const containerClass = classNames('seatable-view-container', {
34
34
  selected: isSelected
35
35
  });
36
- const getViewCellValue = useCallback((row, column) => {
36
+ const getTableCellValue = useCallback((row, column) => {
37
37
  const {
38
- table_id,
39
- view_id
38
+ table_id
40
39
  } = element;
41
- return editor.getViewCellValue(table_id, view_id, row, column);
40
+ return editor.getTableCellValue(table_id, row, column);
42
41
  }, [editor, element]);
43
42
  return /*#__PURE__*/React.createElement("div", Object.assign({}, attributes, {
44
43
  className: containerClass,
@@ -51,7 +50,7 @@ function SeaTableView(_ref) {
51
50
  editor: editor,
52
51
  records: records,
53
52
  columns: columns,
54
- getViewCellValue: getViewCellValue
53
+ getTableCellValue: getTableCellValue
55
54
  })), children);
56
55
  }
57
- export default SeaTableView;
56
+ export default SeaTableTable;
@@ -5,7 +5,7 @@ import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin
5
5
  import { onDragOver, onDragLeave, onDrop } from '../toolbar/side-toolbar/event';
6
6
  import { getParentNode } from '../core';
7
7
  import { setDataRoot, setMouseEnter } from './helper';
8
- import { COLUMN, WIKI_LINK, SEATABLE_VIEW } from '../constants/element-type';
8
+ import { COLUMN, WIKI_LINK, SEATABLE_TABLE } from '../constants/element-type';
9
9
  import { WIKI_EDITOR, DIFF_VIEWER } from '../../constants';
10
10
  const CustomRenderElement = props => {
11
11
  const editor = useSlateStatic();
@@ -179,10 +179,10 @@ const CustomRenderElement = props => {
179
179
  const [renderColumn] = SeaTableColumnPlugin.renderElements;
180
180
  return renderColumn(props, editor);
181
181
  }
182
- case SEATABLE_VIEW:
182
+ case SEATABLE_TABLE:
183
183
  {
184
- const [renderSeaTableView] = SeaTableViewsPlugin.renderElements;
185
- return renderSeaTableView(props, editor);
184
+ const [renderSeaTableTable] = SeaTableViewsPlugin.renderElements;
185
+ return renderSeaTableTable(props, editor);
186
186
  }
187
187
  default:
188
188
  {
@@ -9,7 +9,7 @@ import CodeBlockMenu from '../../../plugins/code-block/menu';
9
9
  import SdocLinkMenu from '../../../plugins/sdoc-link/menu';
10
10
  import FileLinkMenu from '../../../plugins/file-link/menu';
11
11
  import SeaTableColumnMenu from '../../../plugins/seatable-column/menu';
12
- import SeaTableViewMenu from '../../../plugins/seatable-views/menu';
12
+ import SeaTableTableMenu from '../../../plugins/seatable-tables/menu';
13
13
  import EventBus from '../../../../utils/event-bus';
14
14
  import './index.css';
15
15
  const InsertToolbar = _ref => {
@@ -87,7 +87,7 @@ const InsertToolbar = _ref => {
87
87
  }
88
88
  }, /*#__PURE__*/React.createElement(ImageMenu, props), /*#__PURE__*/React.createElement(TableMenu, props), /*#__PURE__*/React.createElement(LinkMenu, props), /*#__PURE__*/React.createElement(CodeBlockMenu, props), /*#__PURE__*/React.createElement("div", {
89
89
  className: "sdoc-dropdown-menu-divider"
90
- }), editor.columns && /*#__PURE__*/React.createElement(SeaTableColumnMenu, props), editor.views && /*#__PURE__*/React.createElement(SeaTableViewMenu, props), /*#__PURE__*/React.createElement(SdocLinkMenu, props), /*#__PURE__*/React.createElement(FileLinkMenu, props))));
90
+ }), editor.columns && /*#__PURE__*/React.createElement(SeaTableColumnMenu, props), editor.tables && /*#__PURE__*/React.createElement(SeaTableTableMenu, props), /*#__PURE__*/React.createElement(SdocLinkMenu, props), /*#__PURE__*/React.createElement(FileLinkMenu, props))));
91
91
  };
92
92
  InsertToolbar.defaultProps = {
93
93
  isRichEditor: true,
@@ -2,15 +2,25 @@
2
2
  position: absolute;
3
3
  left: 0px;
4
4
  top: 0px;
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ width: 24px;
9
+ height: 24px;
10
+ border-radius: 3px;
11
+ transition: all 0.2s;
12
+ }
13
+
14
+ .sdoc-side-toolbar-container:hover {
15
+ background-color: #EFEFEF;
5
16
  }
6
17
 
7
18
  .sdoc-side-toolbar-container .sdoc-side-op-icon {
8
19
  border-radius: 3px;
9
20
  padding: 0px 3px;
10
21
  height: 24px;
11
- color: #BDBDBD;
22
+ color: #AFAFAD;
12
23
  margin-right: 1px;
13
- transform: rotate(180deg);
14
24
  cursor: pointer;
15
25
  }
16
26
 
@@ -23,6 +23,7 @@ const SideToolbar = () => {
23
23
  const [isNodeEmpty, setNodeEmpty] = useState(false);
24
24
  const [isShowSideMenu, setShowSideMenu] = useState(false);
25
25
  const [menuPosition, setMenuPosition] = useState({});
26
+ const [isEnterMoreVertical, setIsEnterMoreVertical] = useState(false);
26
27
  const sideMenuRef = useRef();
27
28
  const onReset = useCallback(() => {
28
29
  setShowSideMenu(false);
@@ -241,6 +242,12 @@ const SideToolbar = () => {
241
242
  unSubscribeDrop();
242
243
  };
243
244
  }, [dragLeave, dragOver, drop]);
245
+ const onMouseEnter = useCallback(() => {
246
+ setIsEnterMoreVertical(true);
247
+ }, []);
248
+ const onMouseLeave = useCallback(() => {
249
+ setIsEnterMoreVertical(false);
250
+ }, []);
244
251
  return /*#__PURE__*/React.createElement("div", {
245
252
  className: "sdoc-side-toolbar-container",
246
253
  style: sidePosition
@@ -249,11 +256,14 @@ const SideToolbar = () => {
249
256
  draggable: true,
250
257
  onDragStart: dragStart,
251
258
  className: "sdoc-side-op-icon",
252
- onClick: onShowSideMenuToggle
259
+ onClick: onShowSideMenuToggle,
260
+ onMouseEnter: onMouseEnter,
261
+ onMouseLeave: onMouseLeave
253
262
  }, /*#__PURE__*/React.createElement("span", {
254
263
  className: classnames('sdocfont', {
255
- 'sdoc-more-vertical': !isNodeEmpty,
256
- 'sdoc-append': isNodeEmpty
264
+ 'sdoc-more-vertical': !isNodeEmpty && !isEnterMoreVertical,
265
+ 'sdoc-append': isNodeEmpty,
266
+ 'sdoc-more-vertical-left': !isNodeEmpty && isEnterMoreVertical
257
267
  })
258
268
  })), isShowSideMenu && /*#__PURE__*/React.createElement(SideMenu, {
259
269
  slateNode: slateNode,
@@ -18,11 +18,10 @@ const DocumentPluginEditor = _ref => {
18
18
  scrollRef,
19
19
  tableId,
20
20
  columns,
21
- views,
22
- getViewRowsById,
23
- getViewColsById,
24
21
  getColumnCellValue,
25
- getViewCellValue
22
+ tables,
23
+ getTableById,
24
+ getTableCellValue
26
25
  } = _ref;
27
26
  context.initApi();
28
27
  const forceUpdate = useForceUpdate();
@@ -39,12 +38,16 @@ const DocumentPluginEditor = _ref => {
39
38
  cursors
40
39
  } = document;
41
40
  newEditor.getColumnCellValue = getColumnCellValue;
41
+
42
+ // insert column
42
43
  newEditor.table_id = tableId;
43
- newEditor.views = views || [];
44
44
  newEditor.columns = columns || [];
45
- newEditor.getViewRowsById = getViewRowsById;
46
- newEditor.getViewColsById = getViewColsById;
47
- newEditor.getViewCellValue = getViewCellValue;
45
+ newEditor.getColumnCellValue = getColumnCellValue;
46
+
47
+ // insert table
48
+ newEditor.tables = tables || [];
49
+ newEditor.getTableById = getTableById;
50
+ newEditor.getTableCellValue = getTableCellValue;
48
51
  newEditor.cursors = cursors || {};
49
52
  newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
50
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.5.74",
3
+ "version": "0.5.76",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -97,6 +97,7 @@
97
97
  "css-minimizer-webpack-plugin": "5.0.1",
98
98
  "dotenv": "6.2.0",
99
99
  "dotenv-expand": "5.1.0",
100
+ "dtable-utils": "5.0.1",
100
101
  "ejs": "3.1.10",
101
102
  "eslint": "6.8.0",
102
103
  "eslint-config-react-app": "^5.0.2",
@@ -43,7 +43,6 @@
43
43
  "Delete_row": "Delete row",
44
44
  "Delete_column": "Delete column",
45
45
  "Insert_row": "Vložit řádek",
46
- "Insert_column": "Vložit sloupec",
47
46
  "Set_align": "Nastavit zarovnání",
48
47
  "Left": "Vlevo",
49
48
  "Center": "Střed",
@@ -461,5 +460,7 @@
461
460
  "Fit_table_to_page_width": "Fit table to page width",
462
461
  "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
463
462
  "Vertical_align": "Vertical alignment",
464
- "Horizontal_align": "Horizontal alignment"
465
- }
463
+ "Horizontal_align": "Horizontal alignment",
464
+ "SeaTable_column": "SeaTable column",
465
+ "SeaTable_view": "SeaTable view"
466
+ }
@@ -43,7 +43,6 @@
43
43
  "Delete_row": "Delete row",
44
44
  "Delete_column": "Delete column",
45
45
  "Insert_row": "Zeile einfügen",
46
- "Insert_column": "Spalte einfügen",
47
46
  "Set_align": "Ausrichtung festlegen",
48
47
  "Left": "Links",
49
48
  "Center": "Zentrieren",
@@ -461,5 +460,7 @@
461
460
  "Fit_table_to_page_width": "Fit table to page width",
462
461
  "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
463
462
  "Vertical_align": "Vertical alignment",
464
- "Horizontal_align": "Horizontal alignment"
465
- }
463
+ "Horizontal_align": "Horizontal alignment",
464
+ "SeaTable_column": "SeaTable column",
465
+ "SeaTable_view": "SeaTable view"
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
  }
@@ -43,7 +43,6 @@
43
43
  "Delete_row": "Delete row",
44
44
  "Delete_column": "Delete column",
45
45
  "Insert_row": "Insert row",
46
- "Insert_column": "Insert column",
47
46
  "Set_align": "Establecer alineación",
48
47
  "Left": "Izquierda",
49
48
  "Center": "Centrar",
@@ -461,5 +460,7 @@
461
460
  "Fit_table_to_page_width": "Fit table to page width",
462
461
  "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
463
462
  "Vertical_align": "Vertical alignment",
464
- "Horizontal_align": "Horizontal alignment"
465
- }
463
+ "Horizontal_align": "Horizontal alignment",
464
+ "SeaTable_column": "SeaTable column",
465
+ "SeaTable_view": "SeaTable view"
466
+ }
@@ -43,7 +43,6 @@
43
43
  "Delete_row": "Delete row",
44
44
  "Delete_column": "Delete column",
45
45
  "Insert_row": "Insert row",
46
- "Insert_column": "Insert column",
47
46
  "Set_align": "Establecer alineación",
48
47
  "Left": "Izquierda",
49
48
  "Center": "Centrar",
@@ -461,5 +460,7 @@
461
460
  "Fit_table_to_page_width": "Fit table to page width",
462
461
  "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
463
462
  "Vertical_align": "Vertical alignment",
464
- "Horizontal_align": "Horizontal alignment"
465
- }
463
+ "Horizontal_align": "Horizontal alignment",
464
+ "SeaTable_column": "SeaTable column",
465
+ "SeaTable_view": "SeaTable view"
466
+ }
@@ -43,7 +43,6 @@
43
43
  "Delete_row": "Delete row",
44
44
  "Delete_column": "Delete column",
45
45
  "Insert_row": "Insert row",
46
- "Insert_column": "Insert column",
47
46
  "Set_align": "Establecer alineación",
48
47
  "Left": "Izquierda",
49
48
  "Center": "Centrar",
@@ -461,5 +460,7 @@
461
460
  "Fit_table_to_page_width": "Fit table to page width",
462
461
  "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
463
462
  "Vertical_align": "Vertical alignment",
464
- "Horizontal_align": "Horizontal alignment"
465
- }
463
+ "Horizontal_align": "Horizontal alignment",
464
+ "SeaTable_column": "SeaTable column",
465
+ "SeaTable_view": "SeaTable view"
466
+ }
@@ -43,7 +43,6 @@
43
43
  "Delete_row": "Supprimer la ligne",
44
44
  "Delete_column": "Supprimer la colonne",
45
45
  "Insert_row": "Insérer une ligne",
46
- "Insert_column": "Insérer une colonne",
47
46
  "Set_align": "Ajuster l'alignement",
48
47
  "Left": "Gauche",
49
48
  "Center": "Centrer",
@@ -461,5 +460,7 @@
461
460
  "Fit_table_to_page_width": "Fit table to page width",
462
461
  "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
463
462
  "Vertical_align": "Vertical alignment",
464
- "Horizontal_align": "Horizontal alignment"
465
- }
463
+ "Horizontal_align": "Horizontal alignment",
464
+ "SeaTable_column": "SeaTable column",
465
+ "SeaTable_view": "SeaTable view"
466
+ }
@@ -43,7 +43,6 @@
43
43
  "Delete_row": "Delete row",
44
44
  "Delete_column": "Delete column",
45
45
  "Insert_row": "Insert row",
46
- "Insert_column": "Insert column",
47
46
  "Set_align": "Imposta allineamento",
48
47
  "Left": "Sinistra",
49
48
  "Center": "Centrato",
@@ -461,5 +460,7 @@
461
460
  "Fit_table_to_page_width": "Fit table to page width",
462
461
  "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
463
462
  "Vertical_align": "Vertical alignment",
464
- "Horizontal_align": "Horizontal alignment"
465
- }
463
+ "Horizontal_align": "Horizontal alignment",
464
+ "SeaTable_column": "SeaTable column",
465
+ "SeaTable_view": "SeaTable view"
466
+ }
@@ -43,7 +43,6 @@
43
43
  "Delete_row": "Удалить строку",
44
44
  "Delete_column": "Удалить столбец",
45
45
  "Insert_row": "Вставить строку",
46
- "Insert_column": "Вставить столбец",
47
46
  "Set_align": "Установить выравнивание",
48
47
  "Left": "Слева",
49
48
  "Center": "По центру",
@@ -445,7 +444,7 @@
445
444
  "Recent_visited": "Недавно посещенные",
446
445
  "The_document_does_not_exist": "Документ не существует",
447
446
  "Create_a_new_sdoc_file": "Создать новый файл sdoc",
448
- "New_page": "New page",
447
+ "New_page": "Новая страница",
449
448
  "Create": "Создать",
450
449
  "Top_align": "Верх",
451
450
  "Center_align": "Середина",
@@ -461,5 +460,7 @@
461
460
  "Fit_table_to_page_width": "Подогнать таблицу по ширине страницы",
462
461
  "Enter_text_or_press_forward_slash_to_insert_element": "Введите текст или нажмите '/', чтобы вставить элемент",
463
462
  "Vertical_align": "Вертикальное выравнивание",
464
- "Horizontal_align": "Горизонтальное выравнивание"
465
- }
463
+ "Horizontal_align": "Горизонтальное выравнивание",
464
+ "SeaTable_column": "SeaTable column",
465
+ "SeaTable_view": "SeaTable view"
466
+ }
@@ -43,7 +43,6 @@
43
43
  "Delete_row": "删除当前行",
44
44
  "Delete_column": "删除当前列",
45
45
  "Insert_row": "插入行",
46
- "Insert_column": "插入列",
47
46
  "Set_align": "对齐方式",
48
47
  "Left": "左对齐",
49
48
  "Center": "居中",
@@ -461,5 +460,7 @@
461
460
  "Fit_table_to_page_width": "自动适应页面宽度",
462
461
  "Enter_text_or_press_forward_slash_to_insert_element": "输入文本或按下 '/' 插入元素",
463
462
  "Vertical_align": "垂直对齐",
464
- "Horizontal_align": "水平对齐"
465
- }
463
+ "Horizontal_align": "水平对齐",
464
+ "SeaTable_column": "SeaTable 列",
465
+ "SeaTable_view": "SeaTable 视图"
466
+ }
@@ -14,7 +14,9 @@
14
14
  />
15
15
  <missing-glyph />
16
16
 
17
- <glyph glyph-name="sdoc-seatable-view" unicode="&#58991;" d="M384 896c35.2 0 64-28.8 64-64v-320c0-35.2-28.8-64-64-64H64c-35.2 0-64 28.8-64 64V832C0 867.2 28.8 896 64 896h320z m-32-96H96v-256h256V800z m608 96c35.2 0 64-28.8 64-64v-320c0-35.2-28.8-64-64-64H640c-35.2 0-64 28.8-64 64V832c0 35.2 28.8 64 64 64h320z m-32-96h-256v-256h256V800zM384 320c35.2 0 64-28.8 64-64v-320c0-35.2-28.8-64-64-64H64c-35.2 0-64 28.8-64 64V256c0 35.2 28.8 64 64 64h320z m-32-96H96v-256h256v256z m608 96c35.2 0 64-28.8 64-64v-320c0-35.2-28.8-64-64-64H640c-35.2 0-64 28.8-64 64V256c0 35.2 28.8 64 64 64h320z m-32-96h-256v-256h256v256z" horiz-adv-x="1024" />
17
+ <glyph glyph-name="sdoc-seatable-table" unicode="&#58991;" d="M384 896c35.2 0 64-28.8 64-64v-320c0-35.2-28.8-64-64-64H64c-35.2 0-64 28.8-64 64V832C0 867.2 28.8 896 64 896h320z m-32-96H96v-256h256V800z m608 96c35.2 0 64-28.8 64-64v-320c0-35.2-28.8-64-64-64H640c-35.2 0-64 28.8-64 64V832c0 35.2 28.8 64 64 64h320z m-32-96h-256v-256h256V800zM384 320c35.2 0 64-28.8 64-64v-320c0-35.2-28.8-64-64-64H64c-35.2 0-64 28.8-64 64V256c0 35.2 28.8 64 64 64h320z m-32-96H96v-256h256v256z m608 96c35.2 0 64-28.8 64-64v-320c0-35.2-28.8-64-64-64H640c-35.2 0-64 28.8-64 64V256c0 35.2 28.8 64 64 64h320z m-32-96h-256v-256h256v256z" horiz-adv-x="1024" />
18
+
19
+ <glyph glyph-name="sdoc-more-vertical-left" unicode="&#58992;" d="M703.629257 704.370743c-54.294956 0-95.814629 41.519672-95.814628 95.814628s41.519672 95.814629 95.814628 95.814629 95.814629-41.519672 95.814629-95.814629-41.519672-95.814629-95.814629-95.814628z m0-415.196724c-54.294956 0-95.814629 41.519672-95.814628 95.814628s41.519672 95.814629 95.814628 95.814629 95.814629-41.519672 95.814629-95.814629-41.519672-95.814629-95.814629-95.814628z m0-415.196724c-54.294956 0-95.814629 41.519672-95.814628 95.814628s41.519672 95.814629 95.814628 95.814629 95.814629-41.519672 95.814629-95.814629-41.519672-95.814629-95.814629-95.814628zM310.78928 857.674149L16.957752 432.895962c-19.162926-28.744389-19.162926-76.651703 0-105.396092L310.78928-94.084496c19.162926-28.744389 60.682598-44.713493 89.426987-25.550568 28.744389 22.356747 38.325851 63.876419 19.162925 92.620808L125.547665 381.794826l287.443885 405.615262c25.550568 35.13203 25.550568 73.457882-12.775283 95.814628s-67.07024 3.193821-89.426987-25.550567z" horiz-adv-x="1024" />
18
20
 
19
21
  <glyph glyph-name="sdoc-text-style" unicode="&#58990;" d="M147.2 156.8h160l67.2 153.6h278.4L720 156.8h160L598.4 896H428.8L147.2 156.8z m348.8 512h35.2l83.2-227.2H409.6L496 668.8zM774.4-128V32h160v-160h-160zM419.2 32h160v-160h-160V32zM96 32h160v-160H96V32z" horiz-adv-x="1024" />
20
22
 
@@ -1,14 +1,14 @@
1
1
  @font-face {
2
2
  font-family: "sdocfont";
3
3
  /* Project id 4097705 */
4
- src: url('./sdoc-editor-font/iconfont.eot?t=1718674664011');
4
+ src: url('./sdoc-editor-font/iconfont.eot?t=1718766655905');
5
5
  /* IE9 */
6
- src: url('./sdoc-editor-font/iconfont.eot?t=1718674664011#iefix') format('embedded-opentype'),
6
+ src: url('./sdoc-editor-font/iconfont.eot?t=1718766655905#iefix') format('embedded-opentype'),
7
7
  /* IE6-IE8 */
8
- url('./sdoc-editor-font/iconfont.woff2?t=1718674664011') format('woff2'),
9
- url('./sdoc-editor-font/iconfont.woff?t=1718674664011') format('woff'),
10
- url('./sdoc-editor-font/iconfont.ttf?t=1718674664011') format('truetype'),
11
- url('./sdoc-editor-font/iconfont.svg?t=1718674664011#sdocfont') format('svg');
8
+ url('./sdoc-editor-font/iconfont.woff2?t=1718766655905') format('woff2'),
9
+ url('./sdoc-editor-font/iconfont.woff?t=1718766655905') format('woff'),
10
+ url('./sdoc-editor-font/iconfont.ttf?t=1718766655905') format('truetype'),
11
+ url('./sdoc-editor-font/iconfont.svg?t=1718766655905#sdocfont') format('svg');
12
12
  }
13
13
 
14
14
  .sdocfont {
@@ -19,10 +19,14 @@
19
19
  -moz-osx-font-smoothing: grayscale;
20
20
  }
21
21
 
22
- .sdoc-seatable-view:before {
22
+ .sdoc-seatable-table:before {
23
23
  content: "\e66f";
24
24
  }
25
25
 
26
+ .sdoc-more-vertical-left:before {
27
+ content: "\e670";
28
+ }
29
+
26
30
  .sdoc-text-style:before {
27
31
  content: "\e66e";
28
32
  }
@@ -1,12 +0,0 @@
1
- import { SEATABLE_VIEW } from '../../constants/element-type';
2
- class SeaTableView {
3
- constructor(options) {
4
- this.type = options.type || SEATABLE_VIEW;
5
- this.table_id = options.table_id;
6
- this.view_id = options.view_id;
7
- this.children = options.children || [{
8
- text: ''
9
- }];
10
- }
11
- }
12
- export default SeaTableView;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import SeaTableView from './seatable-view';
3
- const renderSeaTableView = (props, editor) => {
4
- return /*#__PURE__*/React.createElement(SeaTableView, Object.assign({}, props, {
5
- editor: editor
6
- }));
7
- };
8
- export default renderSeaTableView;