@seafile/sdoc-editor 0.5.67-beta → 0.5.68

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 (35) hide show
  1. package/dist/basic-sdk/assets/css/dropdown-menu.css +1 -1
  2. package/dist/basic-sdk/constants/index.js +2 -1
  3. package/dist/basic-sdk/extension/commons/dropdown-menu-item/index.js +8 -2
  4. package/dist/basic-sdk/extension/constants/element-type.js +0 -3
  5. package/dist/basic-sdk/extension/constants/index.js +2 -2
  6. package/dist/basic-sdk/extension/plugins/header/menu/index.js +1 -2
  7. package/dist/basic-sdk/extension/plugins/index.js +2 -3
  8. package/dist/basic-sdk/extension/plugins/link/menu/index.js +10 -2
  9. package/dist/basic-sdk/extension/plugins/link/plugin.js +20 -2
  10. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +1 -9
  11. package/dist/basic-sdk/extension/plugins/table/menu/horizontal-align-popover/index.js +71 -0
  12. package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.css +11 -0
  13. package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +34 -4
  14. package/dist/basic-sdk/extension/plugins/table/menu/vertical-align-popover/index.js +73 -0
  15. package/dist/basic-sdk/extension/plugins/table/menu/vertical-align-popover/style.css +22 -0
  16. package/dist/basic-sdk/extension/plugins/table/render/table-root.js +4 -2
  17. package/dist/basic-sdk/extension/render/custom-element.js +13 -8
  18. package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +2 -1
  19. package/dist/basic-sdk/utils/rebase.js +14 -93
  20. package/dist/basic-sdk/views/sdoc-diff-viewer.js +7 -1
  21. package/dist/components/doc-operations/more-operations.js +1 -2
  22. package/dist/components/doc-operations/revision-operations/index.js +0 -1
  23. package/package.json +1 -1
  24. package/public/locales/cs/sdoc-editor.json +5 -1
  25. package/public/locales/de/sdoc-editor.json +5 -1
  26. package/public/locales/en/sdoc-editor.json +4 -1
  27. package/public/locales/es/sdoc-editor.json +5 -1
  28. package/public/locales/fr/sdoc-editor.json +5 -1
  29. package/public/locales/it/sdoc-editor.json +5 -1
  30. package/public/locales/ru/sdoc-editor.json +5 -1
  31. package/public/locales/zh_CN/sdoc-editor.json +4 -1
  32. package/dist/basic-sdk/extension/plugins/group/index.js +0 -7
  33. package/dist/basic-sdk/extension/plugins/group/render-elem.js +0 -17
  34. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-text-align-menu.js +0 -44
  35. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/column-vertical-alignment-menu.js +0 -49
@@ -45,7 +45,7 @@
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: flex-start;
48
+ justify-content: space-between;
49
49
  flex: 1;
50
50
  font-size: 14px;
51
51
  }
@@ -56,4 +56,5 @@ export const REBASE_ORIGIN = {
56
56
  MY: 'my'
57
57
  };
58
58
  export const REBASE_MARKS = [REBASE_MARK_KEY.ORIGIN, REBASE_MARK_KEY.REBASE_TYPE, REBASE_MARK_KEY.MODIFY_TYPE, REBASE_MARK_KEY.OLD_ELEMENT];
59
- export { Z_INDEX };
59
+ export { Z_INDEX };
60
+ export const DIFF_VIEWER = 'diff_viewer';
@@ -1,6 +1,7 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import classnames from 'classnames';
4
+ import MenuShortcutPrompt from '../menu-shortcut-indicator';
4
5
  import './index.css';
5
6
  const DropdownMenuItem = _ref => {
6
7
  let {
@@ -8,7 +9,8 @@ const DropdownMenuItem = _ref => {
8
9
  onClick,
9
10
  menuConfig,
10
11
  children,
11
- className
12
+ className,
13
+ shortcut
12
14
  } = _ref;
13
15
  const {
14
16
  t
@@ -32,8 +34,12 @@ const DropdownMenuItem = _ref => {
32
34
  onClick: disabled ? () => {} : onClick || (() => {})
33
35
  }, /*#__PURE__*/React.createElement("div", {
34
36
  className: "sdoc-dropdown-item-content"
37
+ }, /*#__PURE__*/React.createElement("div", {
38
+ className: "sdoc-dropdown-item-left"
35
39
  }, iconClass && /*#__PURE__*/React.createElement("i", {
36
40
  className: classnames(iconClass, 'sdoc-dropdown-item-content-icon')
37
- }), /*#__PURE__*/React.createElement("span", null, t(menuConfig.text))), isShowChildren && children);
41
+ }), /*#__PURE__*/React.createElement("span", null, t(menuConfig.text))), shortcut && /*#__PURE__*/React.createElement(MenuShortcutPrompt, {
42
+ shortcuts: shortcut
43
+ })), isShowChildren && children);
38
44
  };
39
45
  export default DropdownMenuItem;
@@ -34,8 +34,5 @@ export const COLUMN = 'column';
34
34
  export const FONT_SIZE = 'font-size';
35
35
  export const FONT_SIZE_INCREASE = 'font-size-increase';
36
36
  export const FONT_SIZE_REDUCE = 'font-size-reduce';
37
-
38
- // block
39
- export const GROUP = 'group';
40
37
  export const TOP_LEVEL_TYPES = [BLOCKQUOTE, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST_ITEM, PARAGRAPH, CODE_BLOCK, TABLE];
41
38
  export const INLINE_LEVEL_TYPES = [IMAGE, LINK, MENTION, MENTION_TEMP];
@@ -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, GROUP } 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 } 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, GROUP };
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 };
@@ -6,6 +6,7 @@ import { getHeaderType, isMenuDisabled, setHeaderType } from '../helpers';
6
6
  import { HEADERS, HEADER_TITLE_MAP, MAC_HOTKEYS, PARAGRAPH, SDOC_FONT_SIZE, SUBTITLE, TITLE, WIN_HOTKEYS } from '../../../constants';
7
7
  import Tooltip from '../../../../../components/tooltip';
8
8
  import { focusEditor } from '../../../core';
9
+ import { isMac } from '../../../../../utils';
9
10
  import './style.css';
10
11
  class HeaderMenu extends React.Component {
11
12
  constructor(props) {
@@ -80,8 +81,6 @@ class HeaderMenu extends React.Component {
80
81
  this.menu = ref;
81
82
  });
82
83
  _defineProperty(this, "getToolTip", type => {
83
- // chrome in Mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
84
- const isMac = window.navigator.userAgent.indexOf('Macintosh') !== -1;
85
84
  return isMac ? MAC_HOTKEYS[type] : WIN_HOTKEYS[type];
86
85
  });
87
86
  this.state = {
@@ -19,9 +19,8 @@ import SearchReplacePlugin from './search-replace';
19
19
  import MentionPlugin from './mention';
20
20
  import QuickInsertPlugin from './quick-insert';
21
21
  import ColumnPlugin from './column';
22
- import GroupPlugin from './group';
23
- const Plugins = [MarkDownPlugin, HtmlPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, SearchReplacePlugin, GroupPlugin];
22
+ const Plugins = [MarkDownPlugin, HtmlPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, SearchReplacePlugin];
24
23
  const WikiPlugins = [MarkDownPlugin, HtmlPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, SearchReplacePlugin, QuickInsertPlugin];
25
24
  const CommentPlugins = [MarkDownPlugin, HtmlPlugin, ParagraphPlugin, TextPlugin, ListPlugin, ImagePlugin, LinkPlugin, MentionPlugin, BlockquotePlugin];
26
25
  export default Plugins;
27
- export { MarkDownPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, HtmlPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, SearchReplacePlugin, MentionPlugin, QuickInsertPlugin, CommentPlugins, WikiPlugins, ColumnPlugin, GroupPlugin };
26
+ export { MarkDownPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, HtmlPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, SearchReplacePlugin, MentionPlugin, QuickInsertPlugin, CommentPlugins, WikiPlugins, ColumnPlugin };
@@ -1,10 +1,11 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import React, { useCallback } from 'react';
2
+ import React, { useCallback, useMemo } from 'react';
3
3
  import { MENUS_CONFIG_MAP, ELEMENT_TYPE } from '../../../constants';
4
4
  import { isMenuDisabled } from '../helpers';
5
5
  import DropdownMenuItem from '../../../commons/dropdown-menu-item';
6
6
  import { COMMENT_EDITOR, INTERNAL_EVENT } from '../../../../constants';
7
7
  import { MenuItem } from '../../../commons';
8
+ import { isMac } from '../../../../../utils';
8
9
  const LinkMenu = _ref => {
9
10
  let {
10
11
  editor,
@@ -39,10 +40,17 @@ const LinkMenu = _ref => {
39
40
  menuProps.id = 'sdoc-comment-editor' + menuConfig.id;
40
41
  return /*#__PURE__*/React.createElement(MenuItem, menuProps);
41
42
  }
43
+
44
+ // eslint-disable-next-line react-hooks/rules-of-hooks
45
+ const printShortCutTexts = useMemo(() => {
46
+ const printTexts = isMac ? ['⌘', 'k'] : ['Ctrl', 'k'];
47
+ return printTexts;
48
+ }, []);
42
49
  return /*#__PURE__*/React.createElement(DropdownMenuItem, {
43
50
  disabled: disabled,
44
51
  menuConfig: menuConfig,
45
- onClick: openLinkDialog
52
+ onClick: openLinkDialog,
53
+ shortcut: printShortCutTexts
46
54
  });
47
55
  };
48
56
  export default LinkMenu;
@@ -1,17 +1,21 @@
1
1
  import { Transforms, Node, Editor, Range, Element } from '@seafile/slate';
2
2
  import isUrl from 'is-url';
3
+ import isHotkey from 'is-hotkey';
3
4
  import context from '../../../../context';
4
5
  import { insertSdocFileLink } from '../sdoc-link/helpers';
5
6
  import { genLinkNode, isSdocFile } from './helpers';
6
7
  import { getNodeType, getSelectedNodeByType } from '../../core';
7
8
  import { isImage, isSameDomain } from '../../utils';
8
- import { LINK, ORDERED_LIST, UNORDERED_LIST } from '../../constants';
9
+ import { ELEMENT_TYPE, LINK, ORDERED_LIST, UNORDERED_LIST } from '../../constants';
10
+ import EventBus from '../../../utils/event-bus';
11
+ import { INTERNAL_EVENT } from '../../../constants';
9
12
  const withLink = editor => {
10
13
  const {
11
14
  normalizeNode,
12
15
  isInline,
13
16
  insertData,
14
- insertFragment
17
+ insertFragment,
18
+ onHotKeyDown
15
19
  } = editor;
16
20
  const newEditor = editor;
17
21
 
@@ -63,6 +67,20 @@ const withLink = editor => {
63
67
  }
64
68
  return insertFragment(data);
65
69
  };
70
+ newEditor.onHotKeyDown = e => {
71
+ const {
72
+ selection
73
+ } = newEditor;
74
+ const isCollapsed = Range.isCollapsed(selection);
75
+ if (isHotkey('mod+k', e) && isCollapsed) {
76
+ const eventBus = EventBus.getInstance();
77
+ eventBus.dispatch(INTERNAL_EVENT.INSERT_ELEMENT, {
78
+ type: ELEMENT_TYPE.LINK,
79
+ newEditor
80
+ });
81
+ }
82
+ return onHotKeyDown && onHotKeyDown(e);
83
+ };
66
84
 
67
85
  // Rewrite normalizeNode
68
86
  newEditor.normalizeNode = _ref => {
@@ -3,8 +3,6 @@ import { withTranslation } from 'react-i18next';
3
3
  import { MenuGroup } from '../../../../commons';
4
4
  import { isAllInTable } from '../../helpers';
5
5
  import CellBackgroundColorMenu from './cell-bg-color-menu';
6
- import CellTextAlignMenu from './cell-text-align-menu';
7
- import ColumnVerticalAlignmentMenu from './column-vertical-alignment-menu';
8
6
  import './index.css';
9
7
  const ActiveTableMenu = _ref => {
10
8
  let {
@@ -16,13 +14,7 @@ const ActiveTableMenu = _ref => {
16
14
  if (!isAllInTable(editor)) return null;
17
15
  return /*#__PURE__*/React.createElement(MenuGroup, {
18
16
  className: "menu-group sdoc-table-menu-group"
19
- }, /*#__PURE__*/React.createElement(CellTextAlignMenu, {
20
- editor: editor,
21
- readonly: readonly
22
- }), /*#__PURE__*/React.createElement(ColumnVerticalAlignmentMenu, {
23
- editor: editor,
24
- readonly: readonly
25
- }), /*#__PURE__*/React.createElement(CellBackgroundColorMenu, {
17
+ }, /*#__PURE__*/React.createElement(CellBackgroundColorMenu, {
26
18
  editor: editor,
27
19
  isRichEditor: isRichEditor,
28
20
  className: className,
@@ -0,0 +1,71 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { UncontrolledPopover } from 'reactstrap';
4
+ import classNames from 'classnames';
5
+ import { TABLE_CELL_STYLE } from '../../constants';
6
+ import { setCellStyle } from '../../helpers';
7
+ import { focusEditor } from '../../../../core';
8
+ import '../vertical-align-popover/style.css';
9
+ const HorizontalAlignPopover = _ref => {
10
+ let {
11
+ target,
12
+ editor,
13
+ readonly,
14
+ horizontalAlign
15
+ } = _ref;
16
+ const {
17
+ t
18
+ } = useTranslation();
19
+ const setTextAlignStyle = useCallback(textAlign => {
20
+ if (readonly) return;
21
+ setCellStyle(editor, {
22
+ [TABLE_CELL_STYLE.TEXT_ALIGN]: textAlign
23
+ });
24
+ const focusPoint = editor.selection.focus;
25
+ // prevent select all text in the editor
26
+ focusEditor(editor, focusPoint);
27
+ // Select last focus point
28
+ setTimeout(() => {
29
+ focusEditor(editor, focusPoint);
30
+ }, 0);
31
+ }, [editor, readonly]);
32
+ return /*#__PURE__*/React.createElement(UncontrolledPopover, {
33
+ target: target,
34
+ trigger: "hover",
35
+ placement: "right-start",
36
+ hideArrow: true,
37
+ fade: false
38
+ }, /*#__PURE__*/React.createElement("div", {
39
+ className: "sdoc-dropdown-menu sdoc-table-alignment-menu"
40
+ }, /*#__PURE__*/React.createElement("div", {
41
+ className: "sdoc-dropdown-menu-item",
42
+ onMouseDown: () => setTextAlignStyle('left')
43
+ }, /*#__PURE__*/React.createElement("div", {
44
+ className: "sdoc-checked"
45
+ }, /*#__PURE__*/React.createElement("i", {
46
+ className: classNames('sdocfont sdoc-check-mark', {
47
+ active: !horizontalAlign || horizontalAlign === 'left'
48
+ })
49
+ })), /*#__PURE__*/React.createElement("span", {
50
+ className: "active"
51
+ }, t('Left'))), /*#__PURE__*/React.createElement("div", {
52
+ className: "sdoc-dropdown-menu-item",
53
+ onMouseDown: () => setTextAlignStyle('center')
54
+ }, /*#__PURE__*/React.createElement("div", {
55
+ className: "sdoc-checked"
56
+ }, /*#__PURE__*/React.createElement("i", {
57
+ className: classNames('sdocfont sdoc-check-mark', {
58
+ active: horizontalAlign === 'center'
59
+ })
60
+ })), /*#__PURE__*/React.createElement("span", null, t('Center'))), /*#__PURE__*/React.createElement("div", {
61
+ className: "sdoc-dropdown-menu-item",
62
+ onMouseDown: () => setTextAlignStyle('right')
63
+ }, /*#__PURE__*/React.createElement("div", {
64
+ className: "sdoc-checked"
65
+ }, /*#__PURE__*/React.createElement("i", {
66
+ className: classNames('sdocfont sdoc-check-mark', {
67
+ active: horizontalAlign === 'right'
68
+ })
69
+ })), /*#__PURE__*/React.createElement("span", null, t('Right')))));
70
+ };
71
+ export default HorizontalAlignPopover;
@@ -26,3 +26,14 @@
26
26
  .sdoc-table-context-menu .dropdown-item:disabled .insert-number-input {
27
27
  color: #adb5bd;
28
28
  }
29
+
30
+ .side-extendable {
31
+ display: flex;
32
+ justify-content: space-between;
33
+ padding-right: 12px;
34
+ }
35
+
36
+ .side-extendable .sdoc-right-slide {
37
+ color: #999;
38
+ transform: scale(.6);
39
+ }
@@ -5,11 +5,14 @@ import ObjectUtils from '../../../../../utils/object-utils';
5
5
  import { ElementPopover } from '../../../../commons';
6
6
  import { ELEMENT_TYPE } from '../../../../constants';
7
7
  import { getSelectedNodeByType } from '../../../../core';
8
- import { TABLE_MAX_COLUMNS, TABLE_MAX_ROWS, TABLE_ELEMENT, TABLE_ELEMENT_POSITION, EMPTY_SELECTED_RANGE } from '../../constants';
8
+ import { TABLE_MAX_COLUMNS, TABLE_MAX_ROWS, TABLE_ELEMENT, TABLE_ELEMENT_POSITION, EMPTY_SELECTED_RANGE, TABLE_CELL_STYLE } from '../../constants';
9
9
  import { insertTableElement, removeTableElement, combineCells, isTableWidthFitScreen, fitTableColumnToScreen } from '../../helpers';
10
10
  import InsertTableElement from './insert-table-element';
11
11
  import EventBus from '../../../../../utils/event-bus';
12
12
  import { INTERNAL_EVENT } from '../../../../../constants';
13
+ import VerticalAlignPopover from '../vertical-align-popover';
14
+ import HorizontalAlignPopover from '../horizontal-align-popover';
15
+ import KebabToCamel from '../../../../../utils/Kebab-to-camel';
13
16
  import './index.css';
14
17
  class TableContextMenu extends React.Component {
15
18
  constructor(props) {
@@ -71,6 +74,8 @@ class TableContextMenu extends React.Component {
71
74
  };
72
75
  this.position = null;
73
76
  this.eventBus = EventBus.getInstance();
77
+ this.horizontalAlignRef = React.createRef();
78
+ this.verticalAlignRef = React.createRef();
74
79
  }
75
80
  componentDidMount() {
76
81
  this.position = this.props.contextMenuPosition;
@@ -97,13 +102,15 @@ class TableContextMenu extends React.Component {
97
102
  return colspan > 1 || rowspan > 1;
98
103
  }
99
104
  render() {
105
+ var _tableCellNode$style, _tableCellNode$style2;
100
106
  const {
101
107
  contextStyle,
102
108
  isDisableFitTableWidthToScreen
103
109
  } = this.state;
104
110
  const {
105
111
  editor,
106
- t
112
+ t,
113
+ readonly
107
114
  } = this.props;
108
115
  const currentTable = getSelectedNodeByType(editor, ELEMENT_TYPE.TABLE);
109
116
  if (!currentTable) return null;
@@ -120,7 +127,9 @@ class TableContextMenu extends React.Component {
120
127
  const enableCombineCell = !ObjectUtils.isSameObject(tableSelectedRange, EMPTY_SELECTED_RANGE);
121
128
  const enableSplitCell = !enableCombineCell;
122
129
  const isMergedCell = this.isMergedCell();
123
-
130
+ const tableCellNode = getSelectedNodeByType(editor, ELEMENT_TYPE.TABLE_CELL);
131
+ const horizontalAlign = tableCellNode === null || tableCellNode === void 0 ? void 0 : (_tableCellNode$style = tableCellNode.style) === null || _tableCellNode$style === void 0 ? void 0 : _tableCellNode$style[TABLE_CELL_STYLE.TEXT_ALIGN];
132
+ const verticalAlign = tableCellNode === null || tableCellNode === void 0 ? void 0 : (_tableCellNode$style2 = tableCellNode.style) === null || _tableCellNode$style2 === void 0 ? void 0 : _tableCellNode$style2[KebabToCamel(TABLE_CELL_STYLE.ALIGN_ITEMS)];
124
133
  // Check if the table width is fit to screen
125
134
  // Use queueMicrotask to resolve the issue that the table cell combined or split, the table width is not updated immediately
126
135
  queueMicrotask(() => {
@@ -173,7 +182,28 @@ class TableContextMenu extends React.Component {
173
182
  className: "dropdown-item",
174
183
  disabled: !isMergedCell || !enableSplitCell,
175
184
  onMouseDown: this.toggleSplitCellSettingDialog
176
- }, t('Split_cell')), /*#__PURE__*/React.createElement("div", {
185
+ }, t('Split_cell')), /*#__PURE__*/React.createElement("button", {
186
+ ref: this.horizontalAlignRef,
187
+ className: "dropdown-item side-extendable",
188
+ onClick: e => console.log('123')
189
+ }, /*#__PURE__*/React.createElement("span", null, t('Horizontal_align')), /*#__PURE__*/React.createElement("i", {
190
+ className: "sdocfont sdoc-right-slide"
191
+ })), /*#__PURE__*/React.createElement(HorizontalAlignPopover, {
192
+ target: this.horizontalAlignRef,
193
+ editor: editor,
194
+ readonly: readonly,
195
+ horizontalAlign: horizontalAlign
196
+ }), /*#__PURE__*/React.createElement("button", {
197
+ ref: this.verticalAlignRef,
198
+ className: "dropdown-item side-extendable"
199
+ }, /*#__PURE__*/React.createElement("span", null, t('Vertical_align')), /*#__PURE__*/React.createElement("i", {
200
+ className: "sdocfont sdoc-right-slide"
201
+ })), /*#__PURE__*/React.createElement(VerticalAlignPopover, {
202
+ target: this.verticalAlignRef,
203
+ editor: editor,
204
+ readonly: readonly,
205
+ verticalAlign: verticalAlign
206
+ }), /*#__PURE__*/React.createElement("div", {
177
207
  className: 'seafile-divider dropdown-divider'
178
208
  }), /*#__PURE__*/React.createElement("button", {
179
209
  className: "dropdown-item",
@@ -0,0 +1,73 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { UncontrolledPopover } from 'reactstrap';
4
+ import classNames from 'classnames';
5
+ import KebabToCamel from '../../../../../utils/Kebab-to-camel';
6
+ import { setCellStyle } from '../../helpers';
7
+ import { TABLE_CELL_STYLE } from '../../constants';
8
+ import { focusEditor } from '../../../../core';
9
+ import './style.css';
10
+ const VerticalAlignPopover = _ref => {
11
+ let {
12
+ target,
13
+ editor,
14
+ readonly,
15
+ verticalAlign
16
+ } = _ref;
17
+ const {
18
+ t
19
+ } = useTranslation();
20
+ const setVerticalAlignStyle = useCallback(position => {
21
+ if (readonly) return;
22
+ const alignItems = KebabToCamel(TABLE_CELL_STYLE.ALIGN_ITEMS);
23
+ setCellStyle(editor, {
24
+ [alignItems]: position
25
+ });
26
+ const focusPoint = editor.selection.focus;
27
+ // prevent select all text in the editor
28
+ focusEditor(editor, focusPoint);
29
+ // Select last focus point
30
+ setTimeout(() => {
31
+ focusEditor(editor, focusPoint);
32
+ }, 0);
33
+ }, [editor, readonly]);
34
+ return /*#__PURE__*/React.createElement(UncontrolledPopover, {
35
+ target: target,
36
+ trigger: "hover",
37
+ placement: "right-start",
38
+ hideArrow: true,
39
+ fade: false
40
+ }, /*#__PURE__*/React.createElement("div", {
41
+ className: "sdoc-dropdown-menu sdoc-table-alignment-menu"
42
+ }, /*#__PURE__*/React.createElement("div", {
43
+ className: "sdoc-dropdown-menu-item",
44
+ onMouseDown: () => setVerticalAlignStyle('flex-start')
45
+ }, /*#__PURE__*/React.createElement("div", {
46
+ className: "sdoc-checked"
47
+ }, /*#__PURE__*/React.createElement("i", {
48
+ className: classNames('sdocfont sdoc-check-mark', {
49
+ active: !verticalAlign || verticalAlign === 'flex-start'
50
+ })
51
+ })), /*#__PURE__*/React.createElement("span", {
52
+ className: "active"
53
+ }, t('Top_align'))), /*#__PURE__*/React.createElement("div", {
54
+ className: "sdoc-dropdown-menu-item",
55
+ onMouseDown: () => setVerticalAlignStyle('center')
56
+ }, /*#__PURE__*/React.createElement("div", {
57
+ className: "sdoc-checked"
58
+ }, /*#__PURE__*/React.createElement("i", {
59
+ className: classNames('sdocfont sdoc-check-mark', {
60
+ active: verticalAlign === 'center'
61
+ })
62
+ })), /*#__PURE__*/React.createElement("span", null, t('Center_align'))), /*#__PURE__*/React.createElement("div", {
63
+ className: "sdoc-dropdown-menu-item",
64
+ onMouseDown: () => setVerticalAlignStyle('flex-end')
65
+ }, /*#__PURE__*/React.createElement("div", {
66
+ className: "sdoc-checked"
67
+ }, /*#__PURE__*/React.createElement("i", {
68
+ className: classNames('sdocfont sdoc-check-mark', {
69
+ active: verticalAlign === 'flex-end'
70
+ })
71
+ })), /*#__PURE__*/React.createElement("span", null, t('Bottom_align')))));
72
+ };
73
+ export default VerticalAlignPopover;
@@ -0,0 +1,22 @@
1
+ .sdoc-context-menu .sdoc-dropdown-menu {
2
+ display: flex;
3
+ flex-direction: column;
4
+ }
5
+
6
+ .sdoc-table-alignment-menu .sdoc-dropdown-menu-item {
7
+ padding: 4px 10px !important;
8
+ }
9
+
10
+ .sdoc-table-alignment-menu .sdoc-dropdown-menu-item .sdoc-checked {
11
+ margin-right: 6px;
12
+ width: 16px;
13
+ height: 16px;
14
+ }
15
+ .sdoc-table-alignment-menu .sdoc-dropdown-menu-item .sdoc-check-mark {
16
+ display: none;
17
+ font-size: 16px !important;
18
+ color: #6f59ff;
19
+ }
20
+ .sdoc-table-alignment-menu .sdoc-dropdown-menu-item .sdoc-check-mark.active {
21
+ display: inline;
22
+ }
@@ -1,7 +1,7 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useState, useRef, useCallback } from 'react';
3
3
  import classnames from 'classnames';
4
- import { useSlateStatic } from '@seafile/slate-react';
4
+ import { useReadOnly, useSlateStatic } from '@seafile/slate-react';
5
5
  import { TableRootContext, TableRootScrollLeftContext, useContextMenu } from './hooks';
6
6
  import { TableContextMenu } from '../menu';
7
7
  const TableRoot = _ref => {
@@ -11,6 +11,7 @@ const TableRoot = _ref => {
11
11
  children
12
12
  } = _ref;
13
13
  const editor = useSlateStatic();
14
+ const readonly = useReadOnly();
14
15
  const tableScrollWrapper = useRef(null);
15
16
  const [scrollLeft, setScrollLeft] = useState(0);
16
17
  const allWidth = columns.reduce((pre, cur) => pre + cur.width, 0);
@@ -44,7 +45,8 @@ const TableRoot = _ref => {
44
45
  onContextMenu: onContextMenu
45
46
  }, children)), isShowContextMenu && /*#__PURE__*/React.createElement(TableContextMenu, {
46
47
  editor: editor,
47
- contextMenuPosition: menuPosition
48
+ contextMenuPosition: menuPosition,
49
+ readonly: readonly
48
50
  })));
49
51
  };
50
52
  export default TableRoot;
@@ -1,11 +1,12 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import { useReadOnly, useSlateStatic } from '@seafile/slate-react';
3
3
  import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, LIST_ITEM, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST, CODE_BLOCK, CODE_LINE, IMAGE, IMAGE_BLOCK, ELEMENT_TYPE, SDOC_LINK, FILE_LINK, TITLE, SUBTITLE, CALL_OUT, SUPPORTED_SIDE_OPERATION_TYPE, MENTION, MENTION_TEMP, FILE_LINK_INSET_INPUT_TEMP, QUICK_INSERT } from '../constants';
4
- import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, MentionPlugin, QuickInsertPlugin, ColumnPlugin, GroupPlugin } from '../plugins';
4
+ import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin, CalloutPlugin, MentionPlugin, QuickInsertPlugin, ColumnPlugin } from '../plugins';
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
8
  import { COLUMN } from '../constants/element-type';
9
+ import { WIKI_EDITOR, DIFF_VIEWER } from '../../constants';
9
10
  const CustomRenderElement = props => {
10
11
  const editor = useSlateStatic();
11
12
  const readonly = useReadOnly();
@@ -27,12 +28,21 @@ const CustomRenderElement = props => {
27
28
  case PARAGRAPH:
28
29
  {
29
30
  const parentNode = getParentNode(editor.children, element.id);
31
+ const placeholder = editor.editorType === DIFF_VIEWER ? '' : undefined;
30
32
  if (parentNode && parentNode.type === LIST_ITEM) {
31
33
  const [renderParagraph] = ParagraphPlugin.renderElements;
32
- return renderParagraph(props);
34
+ return renderParagraph(_objectSpread(_objectSpread({}, props), {}, {
35
+ placeholder
36
+ }));
33
37
  }
38
+ // Update the placeholder for the wiki editor
39
+ if (editor.editorType === WIKI_EDITOR) props = _objectSpread(_objectSpread({}, props), {}, {
40
+ placeholder: 'Enter_text_or_press_forward_slash_to_insert_element'
41
+ });
34
42
  const [renderParagraph] = ParagraphPlugin.renderElements;
35
- return renderParagraph(props);
43
+ return renderParagraph(_objectSpread(_objectSpread({}, props), {}, {
44
+ placeholder
45
+ }));
36
46
  }
37
47
  case TITLE:
38
48
  {
@@ -165,11 +175,6 @@ const CustomRenderElement = props => {
165
175
  const [renderColumn] = ColumnPlugin.renderElements;
166
176
  return renderColumn(props, editor);
167
177
  }
168
- case ELEMENT_TYPE.GROUP:
169
- {
170
- const [renderGroup] = GroupPlugin.renderElements;
171
- return renderGroup(props);
172
- }
173
178
  default:
174
179
  {
175
180
  const [renderParagraph] = ParagraphPlugin.renderElements;
@@ -72,8 +72,9 @@ const SideToolbar = () => {
72
72
  const node = ReactEditor.toSlateNode(editor, dom);
73
73
  const top = getDomTopHeight(editor, dom, node);
74
74
  const isEmpty = isVoidNode(node);
75
+ const offsetY = !editor.editorType ? -1 : 0; // editorType is undefined means sdoc editor
75
76
  setSidePosition({
76
- top: top + scrollRef.current.scrollTop,
77
+ top: top + scrollRef.current.scrollTop + offsetY,
77
78
  left: 20
78
79
  });
79
80
  setSlateNode(node);
@@ -25,77 +25,6 @@ export const hasConflict = content => {
25
25
  }
26
26
  return flag;
27
27
  };
28
- const expandGroup = content => {
29
- if ([ELEMENT_TYPE.UNORDERED_LIST, ELEMENT_TYPE.ORDERED_LIST].includes(content.type)) {
30
- return [_objectSpread(_objectSpread({}, content), {}, {
31
- children: content.children.map(item => {
32
- if (item.type === ELEMENT_TYPE.GROUP) {
33
- return expandGroup(item);
34
- }
35
- return item;
36
- }).flat(1)
37
- })];
38
- }
39
- return content.type === ELEMENT_TYPE.GROUP ? content.children : [content];
40
- };
41
- const mergeChanges = changes => {
42
- if (!Array.isArray(changes) || changes.length === 0) return changes;
43
- let value = [];
44
- let i = 0;
45
- // while (i < changes.length) {
46
- // const change = changes[i];
47
- // const lastChange = value[value.length - 1];
48
- // if (change && lastChange && change[REBASE_MARK_KEY.MODIFY_TYPE] === lastChange[REBASE_MARK_KEY.MODIFY_TYPE] && [MODIFY_TYPE.ADD, MODIFY_TYPE.DELETE].includes(change[REBASE_MARK_KEY.MODIFY_TYPE])) {
49
- // if (lastChange.type === ELEMENT_TYPE.GROUP) {
50
- // change[REBASE_MARK_KEY.MODIFY_TYPE] && delete change[REBASE_MARK_KEY.MODIFY_TYPE];
51
- // lastChange.children.push(change);
52
- // } else {
53
- // value = value.slice(0, value.length - 1);
54
- // const modifyType = change[REBASE_MARK_KEY.MODIFY_TYPE];
55
- // lastChange[REBASE_MARK_KEY.MODIFY_TYPE] && delete lastChange[REBASE_MARK_KEY.MODIFY_TYPE];
56
- // change[REBASE_MARK_KEY.MODIFY_TYPE] && delete change[REBASE_MARK_KEY.MODIFY_TYPE];
57
- // value.push({
58
- // id: lastChange.id + '_group',
59
- // type: ELEMENT_TYPE.GROUP,
60
- // [REBASE_MARK_KEY.MODIFY_TYPE]: modifyType,
61
- // children: [lastChange, change],
62
- // });
63
- // }
64
- // i++;
65
- // } else {
66
- // value.push(change);
67
- // i++;
68
- // }
69
- // }
70
-
71
- // also add
72
-
73
- while (i < changes.length) {
74
- const change = changes[i];
75
- const lastChange = value[value.length - 1];
76
- if (change && lastChange && change[REBASE_MARK_KEY.MODIFY_TYPE] === MODIFY_TYPE.ADD && lastChange[REBASE_MARK_KEY.MODIFY_TYPE] === MODIFY_TYPE.DELETE) {
77
- value = value.slice(0, value.length - 1);
78
- lastChange[REBASE_MARK_KEY.MODIFY_TYPE] && delete lastChange[REBASE_MARK_KEY.MODIFY_TYPE];
79
- change[REBASE_MARK_KEY.MODIFY_TYPE] && delete change[REBASE_MARK_KEY.MODIFY_TYPE];
80
- value.push({
81
- id: change.id.endsWith('_group') ? change.id : change.id + '_group',
82
- type: ELEMENT_TYPE.GROUP,
83
- [REBASE_MARK_KEY.MODIFY_TYPE]: MODIFY_TYPE.MODIFY,
84
- children: expandGroup(change),
85
- [REBASE_MARK_KEY.OLD_ELEMENT]: {
86
- id: lastChange.id.endsWith('_group') ? lastChange.id : lastChange.id + '_group',
87
- type: ELEMENT_TYPE.GROUP,
88
- children: expandGroup(lastChange)
89
- }
90
- });
91
- i++;
92
- } else {
93
- value.push(change);
94
- i++;
95
- }
96
- }
97
- return value;
98
- };
99
28
  const getChanges = (masterContent, revisionContent) => {
100
29
  const {
101
30
  map: masterContentMap,
@@ -114,21 +43,15 @@ const getChanges = (masterContent, revisionContent) => {
114
43
  removed
115
44
  } = idDiff;
116
45
  if (added) {
117
- // merge consecutive identical operations
118
- content.push({
119
- id: value[0].id + '_group',
120
- type: ELEMENT_TYPE.GROUP,
121
- [REBASE_MARK_KEY.MODIFY_TYPE]: MODIFY_TYPE.ADD,
122
- children: value.map(item => currentContentMap[item])
123
- });
46
+ const addedList = value.map(item => _objectSpread(_objectSpread({}, currentContentMap[item]), {}, {
47
+ [REBASE_MARK_KEY.MODIFY_TYPE]: MODIFY_TYPE.ADD
48
+ }));
49
+ content.push(...addedList);
124
50
  } else if (removed) {
125
- // merge consecutive identical operations
126
- content.push({
127
- id: value[0].id + '_group',
128
- type: ELEMENT_TYPE.GROUP,
129
- [REBASE_MARK_KEY.MODIFY_TYPE]: MODIFY_TYPE.DELETE,
130
- children: value.map(item => currentContentMap[item])
131
- });
51
+ const deletedList = value.map(item => _objectSpread(_objectSpread({}, masterContentMap[item]), {}, {
52
+ [REBASE_MARK_KEY.MODIFY_TYPE]: MODIFY_TYPE.DELETE
53
+ }));
54
+ content.push(...deletedList);
132
55
  } else {
133
56
  value.forEach(elementId => {
134
57
  if (ObjectUtils.isSameObject(masterContentMap[elementId], currentContentMap[elementId])) {
@@ -153,7 +76,7 @@ const getChanges = (masterContent, revisionContent) => {
153
76
  });
154
77
  }
155
78
  });
156
- return mergeChanges(content);
79
+ return content;
157
80
  };
158
81
  const getMergeElement = (diffElement, baseElement) => {
159
82
  const modifyType = diffElement[REBASE_MARK_KEY.MODIFY_TYPE];
@@ -163,7 +86,7 @@ const getMergeElement = (diffElement, baseElement) => {
163
86
  // revision does not have this element, master has this element
164
87
  if (modifyType === MODIFY_TYPE.DELETE) {
165
88
  // base content does not have this element, indicating that it is newly added by master and needs to be retained, and will not be counted as a conflict.
166
- if (!baseElement) return expandGroup(newElement);
89
+ if (!baseElement) return [newElement];
167
90
 
168
91
  // base content has this element, master modified it, indicating that revision deleted it, and the user manually selected the conflict
169
92
  if (!ObjectUtils.isSameObject(baseElement, diffElement, [REBASE_MARK_KEY.MODIFY_TYPE])) {
@@ -178,7 +101,7 @@ const getMergeElement = (diffElement, baseElement) => {
178
101
  // revision has this element, master does not have this element
179
102
  if (modifyType === MODIFY_TYPE.ADD) {
180
103
  // base content does not have this element, indicating that it is newly added by revision and needs to be retained, and will not be counted as a conflict.
181
- if (!baseElement) return expandGroup(newElement);
104
+ if (!baseElement) return [newElement];
182
105
 
183
106
  // master deleted it, revision modified it, and the user manually selected the conflict
184
107
  if (!ObjectUtils.isSameObject(baseElement, diffElement, [REBASE_MARK_KEY.MODIFY_TYPE])) {
@@ -238,10 +161,10 @@ const getMergeElement = (diffElement, baseElement) => {
238
161
  [REBASE_MARK_KEY.ORIGIN]: REBASE_ORIGIN.MY
239
162
  })];
240
163
  }
241
- if (ObjectUtils.isSameObject(masterElement, baseElement)) return expandGroup(newElement);
164
+ if (ObjectUtils.isSameObject(masterElement, baseElement)) return [newElement];
242
165
  if (ObjectUtils.isSameObject(newElement, baseElement)) return [masterElement];
243
166
  if (ObjectUtils.isSameObject(masterElement, newElement, ['type'])) {
244
- if (ObjectUtils.isSameObject(masterElement, baseElement, ['type'])) return expandGroup(newElement);
167
+ if (ObjectUtils.isSameObject(masterElement, baseElement, ['type'])) return [newElement];
245
168
  if (ObjectUtils.isSameObject(newElement, baseElement, ['type'])) return [masterElement];
246
169
  }
247
170
 
@@ -252,7 +175,7 @@ const getMergeElement = (diffElement, baseElement) => {
252
175
  })];
253
176
  }
254
177
  newElement[REBASE_MARK_KEY.OLD_ELEMENT] && delete newElement[REBASE_MARK_KEY.OLD_ELEMENT];
255
- return expandGroup(newElement);
178
+ return [newElement];
256
179
  };
257
180
  const getMergeContent = (baseContent, diffChanges) => {
258
181
  const {
@@ -311,9 +234,7 @@ export const getRebase = (masterContent, baseContent, revisionContent) => {
311
234
  };
312
235
  }
313
236
  const diffChanges = getChanges(masterContent, revisionContent);
314
- console.log('diffChanges: ', diffChanges);
315
237
  const content = getMergeContent(baseContent, diffChanges);
316
- console.log('content: ', content);
317
238
  return {
318
239
  canMerge: canMerge(content, revisionContent.children),
319
240
  isNeedReplaceMaster: true,
@@ -1,7 +1,10 @@
1
1
  import React, { useEffect } from 'react';
2
+ import { createDefaultEditor } from '../extension';
3
+ import withNodeId from '../node-id';
2
4
  import { getDiff } from '../utils/diff';
3
5
  import SDocViewer from './sdoc-viewer';
4
6
  import context from '../../context';
7
+ import { DIFF_VIEWER } from '../constants';
5
8
  import '../../assets/css/diff-viewer.css';
6
9
  const DiffViewer = _ref => {
7
10
  let {
@@ -9,6 +12,8 @@ const DiffViewer = _ref => {
9
12
  lastContent,
10
13
  didMountCallback
11
14
  } = _ref;
15
+ const editor = withNodeId(createDefaultEditor());
16
+ editor.editorType = DIFF_VIEWER;
12
17
  context.initApi();
13
18
  const diff = getDiff(currentContent, lastContent);
14
19
  useEffect(() => {
@@ -22,7 +27,8 @@ const DiffViewer = _ref => {
22
27
  },
23
28
  showToolbar: false,
24
29
  showOutline: false,
25
- showComment: false
30
+ showComment: false,
31
+ editor: editor
26
32
  });
27
33
  };
28
34
  export default DiffViewer;
@@ -7,6 +7,7 @@ import { EXTERNAL_EVENT } from '../../constants';
7
7
  import context from '../../context';
8
8
  import { INTERNAL_EVENT } from '../../basic-sdk/constants';
9
9
  import MenuShortcutPrompt from '../../basic-sdk/extension/commons/menu-shortcut-indicator';
10
+ import { isMac } from '../../utils';
10
11
  const MoreOperations = _ref => {
11
12
  let {
12
13
  t
@@ -56,8 +57,6 @@ const MoreOperations = _ref => {
56
57
  window.location.href = historyURL;
57
58
  }, [docPerm, historyURL, isSdocRevision]);
58
59
  const printShortCutTexts = useMemo(() => {
59
- // chrome in Mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
60
- const isMac = window.navigator.userAgent.indexOf('Macintosh') !== -1;
61
60
  const printTexts = isMac ? ['⌘', 'P'] : ['Ctrl', 'P'];
62
61
  return printTexts;
63
62
  }, []);
@@ -33,7 +33,6 @@ const RevisionOperations = _ref => {
33
33
  loadDocument
34
34
  } = useDocument();
35
35
  useEffect(() => {
36
- return;
37
36
  if (!isSdocRevision) return;
38
37
  if (isShowChanges) return;
39
38
  if (isPublished) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.5.67beta",
3
+ "version": "0.5.68",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -456,5 +456,9 @@
456
456
  "Print": "Print",
457
457
  "Enter_more_character_start_search": "Enter more characters to start search",
458
458
  "Create_file_name_sdoc": "Create {{file_name_sdoc}}",
459
- "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?"
459
+ "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?",
460
+ "Fit_table_to_page_width": "Fit table to page width",
461
+ "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
462
+ "Vertical_align": "Vertical alignment",
463
+ "Horizontal_align": "Horizontal alignment"
460
464
  }
@@ -456,5 +456,9 @@
456
456
  "Print": "Drucken",
457
457
  "Enter_more_character_start_search": "Enter more characters to start search",
458
458
  "Create_file_name_sdoc": "Create {{file_name_sdoc}}",
459
- "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?"
459
+ "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?",
460
+ "Fit_table_to_page_width": "Fit table to page width",
461
+ "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
462
+ "Vertical_align": "Vertical alignment",
463
+ "Horizontal_align": "Horizontal alignment"
460
464
  }
@@ -457,5 +457,8 @@
457
457
  "Enter_more_character_start_search": "Enter more characters to start search",
458
458
  "Create_file_name_sdoc": "Create {{file_name_sdoc}}",
459
459
  "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?",
460
- "Fit_table_to_page_width": "Fit table to page width"
460
+ "Fit_table_to_page_width": "Fit table to page width",
461
+ "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
462
+ "Vertical_align": "Vertical alignment",
463
+ "Horizontal_align": "Horizontal alignment"
461
464
  }
@@ -456,5 +456,9 @@
456
456
  "Print": "Print",
457
457
  "Enter_more_character_start_search": "Enter more characters to start search",
458
458
  "Create_file_name_sdoc": "Create {{file_name_sdoc}}",
459
- "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?"
459
+ "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?",
460
+ "Fit_table_to_page_width": "Fit table to page width",
461
+ "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
462
+ "Vertical_align": "Vertical alignment",
463
+ "Horizontal_align": "Horizontal alignment"
460
464
  }
@@ -456,5 +456,9 @@
456
456
  "Print": "Imprimer",
457
457
  "Enter_more_character_start_search": "Enter more characters to start search",
458
458
  "Create_file_name_sdoc": "Create {{file_name_sdoc}}",
459
- "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?"
459
+ "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?",
460
+ "Fit_table_to_page_width": "Fit table to page width",
461
+ "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
462
+ "Vertical_align": "Vertical alignment",
463
+ "Horizontal_align": "Horizontal alignment"
460
464
  }
@@ -456,5 +456,9 @@
456
456
  "Print": "Print",
457
457
  "Enter_more_character_start_search": "Enter more characters to start search",
458
458
  "Create_file_name_sdoc": "Create {{file_name_sdoc}}",
459
- "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?"
459
+ "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?",
460
+ "Fit_table_to_page_width": "Fit table to page width",
461
+ "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
462
+ "Vertical_align": "Vertical alignment",
463
+ "Horizontal_align": "Horizontal alignment"
460
464
  }
@@ -456,5 +456,9 @@
456
456
  "Print": "Печать",
457
457
  "Enter_more_character_start_search": "Введите больше символов, чтобы начать поиск",
458
458
  "Create_file_name_sdoc": "Создать {{file_name_sdoc}}",
459
- "Source_document_changed_tip": "Original document has concurrent modifications. Do you like to merge these modifications to the revision?"
459
+ "Source_document_changed_tip": "Исходный документ имеет параллельные изменения. Хотите объединить эти изменения в ревизию?",
460
+ "Fit_table_to_page_width": "Подогнать таблицу по ширине страницы",
461
+ "Enter_text_or_press_forward_slash_to_insert_element": "Enter text or press '/' to insert element",
462
+ "Vertical_align": "Vertical alignment",
463
+ "Horizontal_align": "Horizontal alignment"
460
464
  }
@@ -457,5 +457,8 @@
457
457
  "Enter_more_character_start_search": "输入更多字符开始搜索",
458
458
  "Create_file_name_sdoc": "新建 {{file_name_sdoc}}",
459
459
  "Source_document_changed_tip": "源文档有并发的改动。你需要合并这些改动到修订稿吗?",
460
- "Fit_table_to_page_width": "自动适应页面宽度"
460
+ "Fit_table_to_page_width": "自动适应页面宽度",
461
+ "Enter_text_or_press_forward_slash_to_insert_element": "输入文本或按下 '/' 插入元素",
462
+ "Vertical_align": "垂直对齐",
463
+ "Horizontal_align": "水平对齐"
461
464
  }
@@ -1,7 +0,0 @@
1
- import { ELEMENT_TYPE } from '../../constants';
2
- import { renderGroup } from './render-elem';
3
- const GroupPlugin = {
4
- type: ELEMENT_TYPE.GROUP,
5
- renderElements: [renderGroup]
6
- };
7
- export default GroupPlugin;
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- const Group = _ref => {
3
- let {
4
- element,
5
- attributes,
6
- children,
7
- className
8
- } = _ref;
9
- return /*#__PURE__*/React.createElement("div", Object.assign({
10
- "data-id": element.id
11
- }, attributes, {
12
- className: className
13
- }), children);
14
- };
15
- export const renderGroup = props => {
16
- return /*#__PURE__*/React.createElement(Group, props);
17
- };
@@ -1,44 +0,0 @@
1
- import React, { useCallback, useRef } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import CommonMenu from './common-menu';
4
- import { setCellStyle } from '../../helpers';
5
- import { TABLE_CELL_STYLE } from '../../constants';
6
- const CellTextAlignMenu = _ref => {
7
- let {
8
- editor,
9
- readonly
10
- } = _ref;
11
- const textAlignRef = useRef(null);
12
- const {
13
- t
14
- } = useTranslation();
15
- const setTextAlignStyle = useCallback(textAlign => {
16
- if (readonly) return;
17
- setCellStyle(editor, {
18
- [TABLE_CELL_STYLE.TEXT_ALIGN]: textAlign
19
- });
20
- textAlignRef.current && textAlignRef.current.hidePopover();
21
- }, [editor, readonly]);
22
- return /*#__PURE__*/React.createElement(CommonMenu, {
23
- id: "text-align",
24
- iconClass: "sdocfont sdoc-align-left",
25
- ref: textAlignRef,
26
- disabled: readonly
27
- }, /*#__PURE__*/React.createElement("div", {
28
- className: "sdoc-dropdown-menu-item",
29
- onClick: () => setTextAlignStyle('left')
30
- }, /*#__PURE__*/React.createElement("i", {
31
- className: "sdocfont sdoc-align-left mr-2"
32
- }), t('Left')), /*#__PURE__*/React.createElement("div", {
33
- className: "sdoc-dropdown-menu-item",
34
- onClick: () => setTextAlignStyle('center')
35
- }, /*#__PURE__*/React.createElement("i", {
36
- className: "sdocfont sdoc-align-center mr-2"
37
- }), t('Center')), /*#__PURE__*/React.createElement("div", {
38
- className: "sdoc-dropdown-menu-item",
39
- onClick: () => setTextAlignStyle('right')
40
- }, /*#__PURE__*/React.createElement("i", {
41
- className: "sdocfont sdoc-align-right mr-2"
42
- }), t('Right')));
43
- };
44
- export default CellTextAlignMenu;
@@ -1,49 +0,0 @@
1
- import React, { useCallback, useRef } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import CommonMenu from './common-menu';
4
- import { setCellStyle } from '../../helpers';
5
- import { TABLE_CELL_STYLE } from '../../constants';
6
- import KebabToCamel from '../../../../../utils/Kebab-to-camel';
7
- import { focusEditor } from '../../../../core';
8
- const ColumnVerticalAlignmentMenu = _ref => {
9
- let {
10
- editor,
11
- readonly
12
- } = _ref;
13
- const textAlignRef = useRef(null);
14
- const {
15
- t
16
- } = useTranslation();
17
- const setVerticalAlignStyle = useCallback(position => {
18
- if (readonly) return;
19
- const alignItems = KebabToCamel(TABLE_CELL_STYLE.ALIGN_ITEMS);
20
- setCellStyle(editor, {
21
- [alignItems]: position
22
- });
23
- const focusPoint = editor.selection.focus;
24
- focusEditor(editor, focusPoint);
25
- textAlignRef.current && textAlignRef.current.hidePopover();
26
- }, [editor, readonly]);
27
- return /*#__PURE__*/React.createElement(CommonMenu, {
28
- id: "vertical-align",
29
- iconClass: "sdocfont sdoc-top-alignment",
30
- ref: textAlignRef,
31
- disabled: readonly
32
- }, /*#__PURE__*/React.createElement("div", {
33
- className: "sdoc-dropdown-menu-item",
34
- onClick: () => setVerticalAlignStyle('flex-start')
35
- }, /*#__PURE__*/React.createElement("i", {
36
- className: "sdocfont sdoc-top-alignment mr-2"
37
- }), t('Top_align')), /*#__PURE__*/React.createElement("div", {
38
- className: "sdoc-dropdown-menu-item",
39
- onClick: () => setVerticalAlignStyle('center')
40
- }, /*#__PURE__*/React.createElement("i", {
41
- className: "sdocfont sdoc-center-alignment mr-2"
42
- }), t('Center_align')), /*#__PURE__*/React.createElement("div", {
43
- className: "sdoc-dropdown-menu-item",
44
- onClick: () => setVerticalAlignStyle('flex-end')
45
- }, /*#__PURE__*/React.createElement("i", {
46
- className: "sdocfont sdoc-bottom-alignment mr-2"
47
- }), t('Bottom_align')));
48
- };
49
- export default ColumnVerticalAlignmentMenu;