@seafile/sdoc-editor 0.1.107 → 0.1.110
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.
- package/dist/basic-sdk/extension/plugins/code-block/plugin.js +18 -0
- package/dist/basic-sdk/extension/plugins/table/dialog/custom-table-size-dialog/index.js +21 -7
- package/dist/basic-sdk/extension/plugins/table/dialog/custom-table-size-dialog/number-input.js +1 -1
- package/dist/basic-sdk/socket/socket-manager.js +3 -0
- package/dist/components/doc-operations/index.js +2 -5
- package/dist/components/doc-operations/share-operation/index.js +15 -0
- package/dist/components/tip-message/index.js +10 -0
- package/dist/components/toast/toastManager.js +1 -1
- package/dist/constants/index.js +1 -0
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +3 -1
- package/public/locales/zh-CN/sdoc-editor.json +3 -1
|
@@ -97,6 +97,13 @@ var withCodeBlock = function withCodeBlock(editor) {
|
|
|
97
97
|
node = _ref2[0],
|
|
98
98
|
path = _ref2[1];
|
|
99
99
|
var type = getNodeType(node);
|
|
100
|
+
if (type === 'code-line' && path.length <= 1) {
|
|
101
|
+
Transforms.setNodes(newEditor, {
|
|
102
|
+
type: 'paragraph'
|
|
103
|
+
}, {
|
|
104
|
+
at: path
|
|
105
|
+
});
|
|
106
|
+
}
|
|
100
107
|
if (type === CODE_BLOCK) {
|
|
101
108
|
// code-block is the last node in the editor and needs to be followed by a p node
|
|
102
109
|
var isLast = isLastNode(newEditor, node);
|
|
@@ -116,6 +123,17 @@ var withCodeBlock = function withCodeBlock(editor) {
|
|
|
116
123
|
mode: 'highest'
|
|
117
124
|
});
|
|
118
125
|
}
|
|
126
|
+
if (node.children.length > 1) {
|
|
127
|
+
node.children.forEach(function (child, index) {
|
|
128
|
+
if (child.type !== 'code-line') {
|
|
129
|
+
Transforms.setNodes(newEditor, {
|
|
130
|
+
type: 'code-line'
|
|
131
|
+
}, {
|
|
132
|
+
at: [].concat(_toConsumableArray(path), [index])
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
119
137
|
}
|
|
120
138
|
|
|
121
139
|
// Perform default behavior
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React, { Component } from 'react';
|
|
6
6
|
import { withTranslation } from 'react-i18next';
|
|
7
|
-
import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Label } from 'reactstrap';
|
|
7
|
+
import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Label, Alert } from 'reactstrap';
|
|
8
8
|
import { TABLE_MAX_ROWS, TABLE_MAX_COLUMNS } from '../../constants';
|
|
9
9
|
import NumberInput from './number-input';
|
|
10
10
|
import './index.css';
|
|
@@ -22,25 +22,33 @@ var CustomTableSizeDialog = /*#__PURE__*/function (_Component) {
|
|
|
22
22
|
var _this$state = _this.state,
|
|
23
23
|
rows = _this$state.rows,
|
|
24
24
|
cols = _this$state.cols;
|
|
25
|
+
if (!rows || !cols || parseInt(rows) < 1 || parseInt(rows) > 50 || parseInt(cols) < 1 || parseInt(cols) > 50) {
|
|
26
|
+
_this.setState({
|
|
27
|
+
errorMessage: 'Valid_values_for_rows_and_columns'
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
25
31
|
_this.props.submit([parseInt(rows), parseInt(cols)]);
|
|
26
32
|
};
|
|
27
33
|
_this.rowsChange = function (event) {
|
|
28
34
|
var value = event.target.value;
|
|
29
35
|
if (value === _this.state.rows) return;
|
|
30
36
|
_this.setState({
|
|
31
|
-
rows: value
|
|
37
|
+
rows: value,
|
|
38
|
+
errorMessage: ''
|
|
32
39
|
});
|
|
33
40
|
};
|
|
34
41
|
_this.colsChange = function (event) {
|
|
35
42
|
var value = event.target.value;
|
|
36
43
|
if (value === _this.state.cols) return;
|
|
37
44
|
_this.setState({
|
|
38
|
-
cols: value
|
|
45
|
+
cols: value,
|
|
46
|
+
errorMessage: ''
|
|
39
47
|
});
|
|
40
48
|
};
|
|
41
49
|
_this.state = {
|
|
42
|
-
rows: '
|
|
43
|
-
cols: '
|
|
50
|
+
rows: '1',
|
|
51
|
+
cols: '5'
|
|
44
52
|
};
|
|
45
53
|
return _this;
|
|
46
54
|
}
|
|
@@ -50,7 +58,8 @@ var CustomTableSizeDialog = /*#__PURE__*/function (_Component) {
|
|
|
50
58
|
var t = this.props.t;
|
|
51
59
|
var _this$state2 = this.state,
|
|
52
60
|
rows = _this$state2.rows,
|
|
53
|
-
cols = _this$state2.cols
|
|
61
|
+
cols = _this$state2.cols,
|
|
62
|
+
errorMessage = _this$state2.errorMessage;
|
|
54
63
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
55
64
|
isOpen: true,
|
|
56
65
|
toggle: this.toggle,
|
|
@@ -66,6 +75,7 @@ var CustomTableSizeDialog = /*#__PURE__*/function (_Component) {
|
|
|
66
75
|
}, /*#__PURE__*/React.createElement(Label, {
|
|
67
76
|
className: "mb-2"
|
|
68
77
|
}, t('Rows')), /*#__PURE__*/React.createElement(NumberInput, {
|
|
78
|
+
min: 1,
|
|
69
79
|
max: TABLE_MAX_ROWS,
|
|
70
80
|
value: rows,
|
|
71
81
|
onChange: this.rowsChange
|
|
@@ -74,10 +84,14 @@ var CustomTableSizeDialog = /*#__PURE__*/function (_Component) {
|
|
|
74
84
|
}, /*#__PURE__*/React.createElement(Label, {
|
|
75
85
|
className: "mb-2"
|
|
76
86
|
}, t('Columns')), /*#__PURE__*/React.createElement(NumberInput, {
|
|
87
|
+
min: 1,
|
|
77
88
|
max: TABLE_MAX_COLUMNS,
|
|
78
89
|
value: cols,
|
|
79
90
|
onChange: this.colsChange
|
|
80
|
-
})))
|
|
91
|
+
}))), errorMessage && /*#__PURE__*/React.createElement(Alert, {
|
|
92
|
+
className: "mt-2 mb-0",
|
|
93
|
+
color: "danger"
|
|
94
|
+
}, t(errorMessage))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
81
95
|
color: "secondary",
|
|
82
96
|
onClick: this.toggle
|
|
83
97
|
}, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
@@ -48,6 +48,9 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
|
|
|
48
48
|
// Put the failed operation into the pending list and re-execute it
|
|
49
49
|
_this.pendingOperationList.unshift(operations);
|
|
50
50
|
_this.sendNextOperations();
|
|
51
|
+
} else if (error_type === 'document_content_load_failed') {
|
|
52
|
+
// After a short-term reconnection, the content of the document fails to load
|
|
53
|
+
_this.dispatchConnectState(error_type);
|
|
51
54
|
} else if (error_type === 'operation_exec_error') {
|
|
52
55
|
_this.editor.isRemote = true;
|
|
53
56
|
revertOperationList(_this.editor, [operations]);
|
|
@@ -6,6 +6,7 @@ import HistoryOperation from './history-operation';
|
|
|
6
6
|
import CollaboratorsOperation from './collaborators-operation';
|
|
7
7
|
import MoreOperations from './more-operations';
|
|
8
8
|
import CommentsOperation from './comments-operation';
|
|
9
|
+
import ShareOperation from './share-operation';
|
|
9
10
|
import './style.css';
|
|
10
11
|
var DocOperations = function DocOperations(_ref) {
|
|
11
12
|
var isShowChanges = _ref.isShowChanges,
|
|
@@ -16,10 +17,6 @@ var DocOperations = function DocOperations(_ref) {
|
|
|
16
17
|
}, /*#__PURE__*/React.createElement(RevisionOperations, {
|
|
17
18
|
isShowChanges: isShowChanges,
|
|
18
19
|
toggleViewChanges: toggleViewChanges
|
|
19
|
-
}), /*#__PURE__*/React.createElement(CommentsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(
|
|
20
|
-
className: "op-item"
|
|
21
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
22
|
-
className: "sdocfont sdoc-share"
|
|
23
|
-
})), /*#__PURE__*/React.createElement(HistoryOperation, null), /*#__PURE__*/React.createElement(CollaboratorsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(MoreOperations, null));
|
|
20
|
+
}), /*#__PURE__*/React.createElement(CommentsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(ShareOperation, null), /*#__PURE__*/React.createElement(HistoryOperation, null), /*#__PURE__*/React.createElement(CollaboratorsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(MoreOperations, null));
|
|
24
21
|
};
|
|
25
22
|
export default withTranslation('sdoc-editor')(DocOperations);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { EventBus } from '../../../basic-sdk';
|
|
3
|
+
import { EXTERNAL_EVENT } from '../../../constants';
|
|
4
|
+
export default function ShareOperation() {
|
|
5
|
+
var onShareToggle = useCallback(function () {
|
|
6
|
+
var eventBus = EventBus.getInstance();
|
|
7
|
+
eventBus.dispatch(EXTERNAL_EVENT.SHARE_SDOC);
|
|
8
|
+
}, []);
|
|
9
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
10
|
+
className: "op-item",
|
|
11
|
+
onClick: onShareToggle
|
|
12
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
13
|
+
className: "sdocfont sdoc-share"
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
@@ -22,6 +22,14 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
|
|
|
22
22
|
duration: null
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
+
_this.onDocumentLoadError = function () {
|
|
26
|
+
var t = _this.props.t;
|
|
27
|
+
var message = t('Document_content_load_failed');
|
|
28
|
+
toaster.danger(message, {
|
|
29
|
+
hasCloseButton: true,
|
|
30
|
+
duration: null
|
|
31
|
+
});
|
|
32
|
+
};
|
|
25
33
|
_this.onDisconnect = function () {
|
|
26
34
|
var _this$props = _this.props,
|
|
27
35
|
t = _this$props.t,
|
|
@@ -111,12 +119,14 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
|
|
|
111
119
|
|
|
112
120
|
// op execute error
|
|
113
121
|
this.unsubscribeOpExecError = eventBus.subscribe('operation_exec_error', this.onOperationExecuteError);
|
|
122
|
+
this.unsubscribeDocumentLoadError = eventBus.subscribe('document_content_load_failed', this.onDocumentLoadError);
|
|
114
123
|
}
|
|
115
124
|
}, {
|
|
116
125
|
key: "componentWillUnmount",
|
|
117
126
|
value: function componentWillUnmount() {
|
|
118
127
|
this.unsubscribeSavingEvent();
|
|
119
128
|
this.unsubscribeSavedEvent();
|
|
129
|
+
this.unsubscribeDocumentLoadError();
|
|
120
130
|
clearTimeout(this.saveTimer);
|
|
121
131
|
}
|
|
122
132
|
}]);
|
package/dist/constants/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export var EXTERNAL_EVENT = {
|
|
|
2
2
|
INTERNAL_LINK_CLICK: 'internal_link_click',
|
|
3
3
|
TOGGLE_STAR: 'toggle_star',
|
|
4
4
|
UNMARK_AS_DRAFT: 'unmark_as_draft',
|
|
5
|
+
SHARE_SDOC: 'share_sdoc',
|
|
5
6
|
CANCEL_TABLE_SELECT_RANGE: 'cancel_table_select_range',
|
|
6
7
|
SET_TABLE_SELECT_RANGE: 'set_table_select_range'
|
|
7
8
|
};
|
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"Code_block": "Code block",
|
|
26
26
|
"Insert_link": "Insert link",
|
|
27
27
|
"Insert_table": "Insert table",
|
|
28
|
+
"Valid_values_for_rows_and_columns": "Valid values for the number of rows and columns are 0 to 50",
|
|
28
29
|
"Save": "Save",
|
|
29
30
|
"More": "More",
|
|
30
31
|
"Invalid_url": "Invalid URL",
|
|
@@ -338,5 +339,6 @@
|
|
|
338
339
|
"Reduce_font_size": "Reduce font size",
|
|
339
340
|
"Font": "Font",
|
|
340
341
|
"All_fonts": "All fonts",
|
|
341
|
-
"Default_font": "Default font"
|
|
342
|
+
"Default_font": "Default font",
|
|
343
|
+
"Document_content_load_failed": "Document content failed to load, please refresh the page to try again"
|
|
342
344
|
}
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"Code_block": "代码块",
|
|
26
26
|
"Insert_link": "添加链接",
|
|
27
27
|
"Insert_table": "添加表格",
|
|
28
|
+
"Valid_values_for_rows_and_columns": "行数和列数的有效值为 0 到 50",
|
|
28
29
|
"Save": "保存",
|
|
29
30
|
"More": "更多",
|
|
30
31
|
"Invalid_url": "无效链接",
|
|
@@ -340,5 +341,6 @@
|
|
|
340
341
|
"Reduce_font_size": "减小字号",
|
|
341
342
|
"Font": "字体",
|
|
342
343
|
"All_fonts": "所有字体",
|
|
343
|
-
"Default_font": "默认字体"
|
|
344
|
+
"Default_font": "默认字体",
|
|
345
|
+
"Document_content_load_failed": "文档内容加载失败, 请刷新页面重新访问"
|
|
344
346
|
}
|