@seafile/sdoc-editor 0.2.0 → 0.2.2

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.
@@ -16,6 +16,8 @@ import { EditorContainer, EditorContent } from '../layout';
16
16
  import EditableArticle from './editable-article';
17
17
  import { ColorProvider } from '../hooks/use-color-context';
18
18
  import { HeaderToolbar } from '../extension';
19
+ import ReadOnlyArticle from '../views/readonly-article';
20
+ import { isMobile } from '../../utils';
19
21
  var SdocEditor = forwardRef(function (_ref, ref) {
20
22
  var document = _ref.document,
21
23
  isReloading = _ref.isReloading;
@@ -98,6 +100,19 @@ var SdocEditor = forwardRef(function (_ref, ref) {
98
100
  className: "h-100 w-100 d-flex align-items-center justify-content-center"
99
101
  }, /*#__PURE__*/React.createElement(CommonLoading, null));
100
102
  }
103
+ if (isMobile) {
104
+ return /*#__PURE__*/React.createElement(EditorContainer, {
105
+ editor: editor,
106
+ readonly: true
107
+ }, /*#__PURE__*/React.createElement(ColorProvider, null, /*#__PURE__*/React.createElement(EditorContent, {
108
+ docValue: slateValue,
109
+ readonly: true,
110
+ showOutline: false
111
+ }, /*#__PURE__*/React.createElement(ReadOnlyArticle, {
112
+ editor: editor,
113
+ slateValue: slateValue
114
+ }))));
115
+ }
101
116
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorContainer, {
102
117
  editor: editor
103
118
  }, /*#__PURE__*/React.createElement(ColorProvider, null, /*#__PURE__*/React.createElement(HeaderToolbar, {
@@ -83,12 +83,6 @@ var ImagePreviewer = /*#__PURE__*/function (_React$Component) {
83
83
  onCloseRequest: this.props.toggleImagePreviewer,
84
84
  onMovePrevRequest: this.moveToPrevImage,
85
85
  onMoveNextRequest: this.moveToNextImage,
86
- imagePadding: 70,
87
- reactModalStyle: {
88
- overlay: {
89
- zIndex: 1071
90
- }
91
- },
92
86
  reactModalProps: {
93
87
  shouldReturnFocusAfterClose: false
94
88
  }
@@ -33,7 +33,7 @@ export var movedListItemUp = function movedListItemUp(editor, _ref) {
33
33
  } catch (err) {
34
34
  return;
35
35
  }
36
- var condA = hasListChild(editor, liNode);
36
+ var condA = hasListChild(liNode);
37
37
  var condB = !isLastChild(list, liPath);
38
38
  if (condA || condB) {
39
39
  // 创建一个新的兄弟节点
@@ -140,10 +140,10 @@ var withTable = function withTable(editor) {
140
140
  var _column = columns[_j];
141
141
  selectedColumns.push(_column);
142
142
  }
143
- return Object.freeze(_objectSpread(_objectSpread({}, selectedNode), {}, {
143
+ return [Object.freeze(_objectSpread(_objectSpread({}, selectedNode), {}, {
144
144
  children: selectedRows,
145
145
  columns: selectedColumns
146
- }));
146
+ }))];
147
147
  };
148
148
 
149
149
  // copy: mod + c
@@ -191,8 +191,13 @@ var withTable = function withTable(editor) {
191
191
  if (fragment) {
192
192
  var decoded = decodeURIComponent(window.atob(fragment));
193
193
  var parsedData = JSON.parse(decoded);
194
- if (ObjectUtils.isObject(parsedData) && parsedData.type === ELEMENT_TYPE.TABLE) {
195
- insertMultipleRowsAndColumns(newEditor, parsedData.children, parsedData.columns);
194
+ if (Array.isArray(parsedData) && parsedData.some(function (item) {
195
+ return item.type === ELEMENT_TYPE.TABLE;
196
+ })) {
197
+ var tableElement = parsedData.find(function (item) {
198
+ return item.type === ELEMENT_TYPE.TABLE;
199
+ });
200
+ insertMultipleRowsAndColumns(newEditor, tableElement.children, tableElement.columns);
196
201
  return;
197
202
  }
198
203
  }
@@ -2,6 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import { Editor } from '@seafile/slate';
3
3
  import { getNodeType } from '../../core';
4
4
  import { CODE_BLOCK } from '../../constants/element-type';
5
+ import { TEXT_STYLE_MAP } from '../../constants/menus-config';
5
6
  export var isMenuDisabled = function isMenuDisabled(editor, readonly) {
6
7
  if (readonly) return true;
7
8
  if (editor.selection == null) return true;
@@ -23,6 +24,11 @@ export var isMenuDisabled = function isMenuDisabled(editor, readonly) {
23
24
  return false;
24
25
  };
25
26
  export var addMark = function addMark(editor, type) {
27
+ if (type === TEXT_STYLE_MAP.SUPERSCRIPT) {
28
+ removeMark(editor, TEXT_STYLE_MAP.SUBSCRIPT);
29
+ } else if (type === TEXT_STYLE_MAP.SUBSCRIPT) {
30
+ removeMark(editor, TEXT_STYLE_MAP.SUPERSCRIPT);
31
+ }
26
32
  Editor.addMark(editor, type, true);
27
33
  };
28
34
  export var removeMark = function removeMark(editor, type) {
@@ -4,7 +4,8 @@ import { ReactEditor } from '@seafile/slate-react';
4
4
  import copy from 'copy-to-clipboard';
5
5
  import { toggleList } from '../../plugins/list/transforms';
6
6
  import { generateEmptyElement } from '../../core';
7
- import { ORDERED_LIST, UNORDERED_LIST, PARAGRAPH, CHECK_LIST_ITEM, IMAGE, TABLE, CODE_BLOCK, BLOCKQUOTE, LIST_ITEM_CORRELATION_TYPE, ADD_POSITION_OFFSET_TYPE, INSERT_POSITION } from '../../constants';
7
+ import { ORDERED_LIST, UNORDERED_LIST, PARAGRAPH, CHECK_LIST_ITEM, IMAGE, TABLE, CODE_BLOCK, BLOCKQUOTE, LIST_ITEM_CORRELATION_TYPE, ADD_POSITION_OFFSET_TYPE, INSERT_POSITION, ELEMENT_TYPE } from '../../constants';
8
+ import { EMPTY_SELECTED_RANGE } from '../../plugins/table/constants';
8
9
  export var onSetNodeType = function onSetNodeType(editor, element, type) {
9
10
  if (!type) return;
10
11
  if ([ORDERED_LIST, UNORDERED_LIST].includes(type)) {
@@ -40,7 +41,17 @@ export var setSelection = function setSelection(editor, element) {
40
41
  Transforms.select(editor, path);
41
42
  }
42
43
  };
43
- export var onCopyNode = function onCopyNode(editor) {
44
+ export var onCopyNode = function onCopyNode(editor, element) {
45
+ if (element.type === ELEMENT_TYPE.TABLE) {
46
+ var tableSize = [element.children.length, element.children[0].children.length];
47
+ var tableSelectedRange = {
48
+ minRowIndex: 0,
49
+ maxRowIndex: tableSize[0] - 1,
50
+ minColIndex: 0,
51
+ maxColIndex: tableSize[1] - 1
52
+ };
53
+ editor.tableSelectedRange = tableSelectedRange;
54
+ }
44
55
  var newData = editor.setFragmentData(new DataTransfer());
45
56
  copy('copy', {
46
57
  onCopy: function onCopy(clipboardData) {
@@ -50,6 +61,9 @@ export var onCopyNode = function onCopyNode(editor) {
50
61
  });
51
62
  }
52
63
  });
64
+ if (element.type === ELEMENT_TYPE.TABLE) {
65
+ editor.tableSelectedRange = EMPTY_SELECTED_RANGE;
66
+ }
53
67
  };
54
68
  export var onDeleteNode = function onDeleteNode(editor, element) {
55
69
  var path = ReactEditor.findPath(editor, element);
@@ -29,11 +29,11 @@ var SideMenu = function SideMenu(_ref) {
29
29
  // eslint-disable-next-line react-hooks/exhaustive-deps
30
30
  }, []);
31
31
  var onCopy = useCallback(function () {
32
- onCopyNode(editor);
32
+ onCopyNode(editor, slateNode);
33
33
  onReset();
34
- }, [editor, onReset]);
34
+ }, [editor, onReset, slateNode]);
35
35
  var onCut = useCallback(function () {
36
- onCopyNode(editor);
36
+ onCopyNode(editor, slateNode);
37
37
  onDeleteNode(editor, slateNode);
38
38
  onReset();
39
39
  }, [editor, onReset, slateNode]);
@@ -12,8 +12,7 @@ export default function ReadOnlyArticle(_ref) {
12
12
  editor: editor,
13
13
  value: slateValue
14
14
  }, /*#__PURE__*/React.createElement(ArticleContainer, {
15
- editor: editor,
16
- readOnly: true
15
+ editor: editor
17
16
  }, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(SetNodeToDecorations, null), /*#__PURE__*/React.createElement(Editable, {
18
17
  readOnly: true,
19
18
  placeholder: "",
@@ -7,6 +7,7 @@ import CollaboratorsOperation from './collaborators-operation';
7
7
  import MoreOperations from './more-operations';
8
8
  import CommentsOperation from './comments-operation';
9
9
  import ShareOperation from './share-operation';
10
+ import { isMobile } from '../../utils';
10
11
  import './style.css';
11
12
  var DocOperations = function DocOperations(_ref) {
12
13
  var isShowChanges = _ref.isShowChanges,
@@ -14,6 +15,11 @@ var DocOperations = function DocOperations(_ref) {
14
15
  handleViewChangesToggle = _ref.handleViewChangesToggle,
15
16
  handleRevisionPublished = _ref.handleRevisionPublished;
16
17
  var isSdocRevision = context.getSetting('isSdocRevision');
18
+ if (isMobile) {
19
+ return /*#__PURE__*/React.createElement("div", {
20
+ className: "doc-ops"
21
+ }, !isSdocRevision && /*#__PURE__*/React.createElement(ShareOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(MoreOperations, null));
22
+ }
17
23
  return /*#__PURE__*/React.createElement("div", {
18
24
  className: "doc-ops"
19
25
  }, /*#__PURE__*/React.createElement(RevisionOperations, {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
7
7
  "dependencies": {
8
- "@seafile/react-image-lightbox": "2.0.2",
8
+ "@seafile/react-image-lightbox": "2.0.4",
9
9
  "@seafile/slate": "0.91.8",
10
10
  "@seafile/slate-history": "0.86.2",
11
11
  "@seafile/slate-hyperscript": "0.81.7",