@seafile/sdoc-editor 0.1.112 → 0.1.113
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.
|
@@ -22,10 +22,10 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
22
22
|
_useState2 = _slicedToArray(_useState, 2),
|
|
23
23
|
isFirstLoad = _useState2[0],
|
|
24
24
|
setFirstLoad = _useState2[1];
|
|
25
|
-
var _useState3 = useState(
|
|
25
|
+
var _useState3 = useState(true),
|
|
26
26
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
isLoadingSdoc = _useState4[0],
|
|
28
|
+
setLoadingSdoc = _useState4[1];
|
|
29
29
|
var _useState5 = useState(''),
|
|
30
30
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
31
31
|
errorMessage = _useState6[0],
|
|
@@ -54,6 +54,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
54
54
|
}, []);
|
|
55
55
|
var initDocumentData = useCallback(function (isFirstLoad) {
|
|
56
56
|
setShowChanges(false);
|
|
57
|
+
setLoadingSdoc(true);
|
|
57
58
|
context.getFileContent().then(function (res) {
|
|
58
59
|
var result = res.data || generateDefaultDocContent();
|
|
59
60
|
if (result && !result.children) {
|
|
@@ -64,21 +65,28 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
67
|
setDocument(result);
|
|
67
|
-
|
|
68
|
+
setLoadingSdoc(false);
|
|
68
69
|
isFirstLoad && setFirstLoad(false);
|
|
69
70
|
}).catch(function (error) {
|
|
70
71
|
// eslint-disable-next-line
|
|
71
72
|
console.log(error);
|
|
72
73
|
setErrorMessage('Load_doc_content_error');
|
|
74
|
+
if (error && error.response) {
|
|
75
|
+
var _ref2 = error.response.data || {},
|
|
76
|
+
error_type = _ref2.error_type;
|
|
77
|
+
if (error_type === 'content_invalid') {
|
|
78
|
+
setErrorMessage('Sdoc_format_invalid');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
73
81
|
setDocument(null);
|
|
74
|
-
|
|
75
|
-
isFirstLoad && setFirstLoad(false);
|
|
82
|
+
setLoadingSdoc(false);
|
|
76
83
|
});
|
|
77
84
|
|
|
78
85
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
79
86
|
}, []);
|
|
80
87
|
var initChangesData = useCallback(function () {
|
|
81
88
|
setShowChanges(true);
|
|
89
|
+
setLoadingSdoc(true);
|
|
82
90
|
context.getSeadocRevisionDownloadLinks().then(function (res) {
|
|
83
91
|
var originFileDownloadLink = res.data.origin_file_download_link;
|
|
84
92
|
return fetch(originFileDownloadLink);
|
|
@@ -87,10 +95,10 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
87
95
|
}).then(function (originContent) {
|
|
88
96
|
setLastContent(originContent);
|
|
89
97
|
setErrorMessage(null);
|
|
90
|
-
|
|
98
|
+
setLoadingSdoc(false);
|
|
91
99
|
}).catch(function (error) {
|
|
92
100
|
setErrorMessage('Load_doc_content_error');
|
|
93
|
-
|
|
101
|
+
setLoadingSdoc(false);
|
|
94
102
|
});
|
|
95
103
|
|
|
96
104
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -102,7 +110,6 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
102
110
|
children: newestValue
|
|
103
111
|
})));
|
|
104
112
|
}
|
|
105
|
-
setContextInit(false);
|
|
106
113
|
if (isShowChanges) {
|
|
107
114
|
initChangesData();
|
|
108
115
|
return;
|
|
@@ -111,13 +118,15 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
111
118
|
|
|
112
119
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
120
|
}, [document]);
|
|
114
|
-
if (isFirstLoad && !
|
|
121
|
+
if (isFirstLoad && !errorMessage) {
|
|
115
122
|
return /*#__PURE__*/React.createElement(Loading, null);
|
|
116
123
|
}
|
|
117
124
|
if (isFirstLoad && errorMessage) {
|
|
118
125
|
return /*#__PURE__*/React.createElement("div", {
|
|
119
|
-
className: "
|
|
120
|
-
},
|
|
126
|
+
className: "error-page"
|
|
127
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
className: "error-tip"
|
|
129
|
+
}, t(errorMessage)));
|
|
121
130
|
}
|
|
122
131
|
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
|
|
123
132
|
isStarred: isStarred,
|
|
@@ -126,11 +135,13 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
126
135
|
}), /*#__PURE__*/React.createElement(DocOperations, {
|
|
127
136
|
isShowChanges: isShowChanges,
|
|
128
137
|
toggleViewChanges: toggleViewChanges
|
|
129
|
-
})), /*#__PURE__*/React.createElement(Content, null,
|
|
138
|
+
})), /*#__PURE__*/React.createElement(Content, null, isLoadingSdoc && /*#__PURE__*/React.createElement("div", {
|
|
130
139
|
className: "w-100 h-100 d-flex align-items-center justify-content-center"
|
|
131
|
-
}, /*#__PURE__*/React.createElement(Loading, null)), !
|
|
132
|
-
className: "
|
|
133
|
-
},
|
|
140
|
+
}, /*#__PURE__*/React.createElement(Loading, null)), !isLoadingSdoc && errorMessage && /*#__PURE__*/React.createElement("div", {
|
|
141
|
+
className: "error-page"
|
|
142
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
className: "error-tip"
|
|
144
|
+
}, t(errorMessage))), !isLoadingSdoc && /*#__PURE__*/React.createElement(React.Fragment, null, isShowChanges ? /*#__PURE__*/React.createElement(DiffViewer, {
|
|
134
145
|
currentContent: currentContent,
|
|
135
146
|
lastContent: lastContent
|
|
136
147
|
}) : /*#__PURE__*/React.createElement(SDocEditor, {
|
package/package.json
CHANGED
|
@@ -276,6 +276,7 @@
|
|
|
276
276
|
"Failed_to_execute_operation_on_server": "Failed to execute operation on server",
|
|
277
277
|
"Start_revise_tip": "Create a temporary document and modify on it, merge it back after reviewing changes",
|
|
278
278
|
"Load_doc_content_error": "Load doc content error",
|
|
279
|
+
"Sdoc_format_invalid": "The content of the document does not conform to the sdoc specification",
|
|
279
280
|
"Draft": "Draft",
|
|
280
281
|
"Unmark_as_draft": "Unmark as draft",
|
|
281
282
|
"Background_color": "Background color",
|
|
@@ -276,6 +276,7 @@
|
|
|
276
276
|
"Failed_to_execute_operation_on_server": "无法在服务器上执行操作",
|
|
277
277
|
"Start_revise_tip": "创建一个临时文档并对其进行修订,检查更改后将其合并回来",
|
|
278
278
|
"Load_doc_content_error": "加载文档内容错误",
|
|
279
|
+
"Sdoc_format_invalid": "文档内容不符合 sdoc 规范",
|
|
279
280
|
"Draft": "草稿",
|
|
280
281
|
"Unmark_as_draft": "取消草稿标记",
|
|
281
282
|
"Background_color": "背景色",
|