@seafile/sdoc-editor 0.5.67 → 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 (28) 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/plugins/header/menu/index.js +1 -2
  5. package/dist/basic-sdk/extension/plugins/link/menu/index.js +10 -2
  6. package/dist/basic-sdk/extension/plugins/link/plugin.js +20 -2
  7. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +1 -9
  8. package/dist/basic-sdk/extension/plugins/table/menu/horizontal-align-popover/index.js +71 -0
  9. package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.css +11 -0
  10. package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +34 -4
  11. package/dist/basic-sdk/extension/plugins/table/menu/vertical-align-popover/index.js +73 -0
  12. package/dist/basic-sdk/extension/plugins/table/menu/vertical-align-popover/style.css +22 -0
  13. package/dist/basic-sdk/extension/plugins/table/render/table-root.js +4 -2
  14. package/dist/basic-sdk/extension/render/custom-element.js +12 -2
  15. package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +2 -1
  16. package/dist/basic-sdk/views/sdoc-diff-viewer.js +7 -1
  17. package/dist/components/doc-operations/more-operations.js +1 -2
  18. package/package.json +1 -1
  19. package/public/locales/cs/sdoc-editor.json +5 -1
  20. package/public/locales/de/sdoc-editor.json +5 -1
  21. package/public/locales/en/sdoc-editor.json +4 -1
  22. package/public/locales/es/sdoc-editor.json +5 -1
  23. package/public/locales/fr/sdoc-editor.json +5 -1
  24. package/public/locales/it/sdoc-editor.json +5 -1
  25. package/public/locales/ru/sdoc-editor.json +5 -1
  26. package/public/locales/zh_CN/sdoc-editor.json +4 -1
  27. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-text-align-menu.js +0 -44
  28. 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;
@@ -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 = {
@@ -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;
@@ -6,6 +6,7 @@ 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
  {
@@ -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);
@@ -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
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.5.67",
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,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;