@seafile/sdoc-editor 0.1.8 → 0.1.9
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/assets/css/simple-editor.css +4 -0
- package/dist/basic-sdk/socket/socket-manager.js +3 -0
- package/dist/components/tip-message/index.js +39 -0
- package/dist/components/tip-message/style.css +9 -0
- package/dist/pages/simple-editor.js +54 -3
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +3 -1
- package/public/locales/zh-CN/sdoc-editor.json +3 -1
- package/dist/assets/css/custom-editor.css +0 -28
|
@@ -156,6 +156,9 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
|
|
|
156
156
|
_this.editor.isRemote = false;
|
|
157
157
|
});
|
|
158
158
|
};
|
|
159
|
+
this.subscribe = function (type, handler) {
|
|
160
|
+
return _this.eventBus.subscribe(type, handler);
|
|
161
|
+
};
|
|
159
162
|
this.dispatchConnectState = function (type, message) {
|
|
160
163
|
_this.eventBus.dispatch(type, message);
|
|
161
164
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { withTranslation } from 'react-i18next';
|
|
7
|
+
import './style.css';
|
|
8
|
+
var TipMessage = /*#__PURE__*/function (_React$Component) {
|
|
9
|
+
_inherits(TipMessage, _React$Component);
|
|
10
|
+
var _super = _createSuper(TipMessage);
|
|
11
|
+
function TipMessage() {
|
|
12
|
+
var _this;
|
|
13
|
+
_classCallCheck(this, TipMessage);
|
|
14
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15
|
+
args[_key] = arguments[_key];
|
|
16
|
+
}
|
|
17
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
18
|
+
_this.render = function () {
|
|
19
|
+
var _this$props = _this.props,
|
|
20
|
+
t = _this$props.t,
|
|
21
|
+
isSaved = _this$props.isSaved,
|
|
22
|
+
isSaving = _this$props.isSaving;
|
|
23
|
+
if (isSaving && !isSaved) {
|
|
24
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
25
|
+
className: "tip-message"
|
|
26
|
+
}, t('Saving'));
|
|
27
|
+
}
|
|
28
|
+
if (!isSaving && isSaved) {
|
|
29
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
30
|
+
className: "tip-message"
|
|
31
|
+
}, t('All_changes_saved'));
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
return _this;
|
|
36
|
+
}
|
|
37
|
+
return _createClass(TipMessage);
|
|
38
|
+
}(React.Component);
|
|
39
|
+
export default withTranslation('sdoc-editor')(TipMessage);
|
|
@@ -7,9 +7,11 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { SDocEditor } from '../basic-sdk';
|
|
9
9
|
import Loading from '../components/loading';
|
|
10
|
+
import TipMessage from '../components/tip-message';
|
|
10
11
|
import Layout, { Header, Content } from '../layout';
|
|
11
12
|
import { generateDefaultDocContent } from '../utils';
|
|
12
13
|
import context from '../context';
|
|
14
|
+
import '../assets/css/simple-editor.css';
|
|
13
15
|
var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
14
16
|
_inherits(SimpleEditor, _React$Component);
|
|
15
17
|
var _super = _createSuper(SimpleEditor);
|
|
@@ -17,6 +19,25 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
17
19
|
var _this;
|
|
18
20
|
_classCallCheck(this, SimpleEditor);
|
|
19
21
|
_this = _super.call(this, props);
|
|
22
|
+
_this.onDocumentSaving = function () {
|
|
23
|
+
_this.setState({
|
|
24
|
+
isSaving: true,
|
|
25
|
+
isSaved: false
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
_this.onDocumentSaved = function () {
|
|
29
|
+
_this.setState({
|
|
30
|
+
isSaving: false,
|
|
31
|
+
isSaved: true
|
|
32
|
+
});
|
|
33
|
+
if (_this.saveTimer) clearTimeout(_this.saveTimer);
|
|
34
|
+
_this.saveTimer = setTimeout(function () {
|
|
35
|
+
_this.setState({
|
|
36
|
+
isSaving: false,
|
|
37
|
+
isSaved: false
|
|
38
|
+
});
|
|
39
|
+
}, 2000);
|
|
40
|
+
};
|
|
20
41
|
_this.onValueChanged = function (value) {
|
|
21
42
|
_this.isValueChanged = true;
|
|
22
43
|
_this.value = value;
|
|
@@ -34,18 +55,24 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
34
55
|
});
|
|
35
56
|
}
|
|
36
57
|
};
|
|
58
|
+
_this.setEditorRef = function (ref) {
|
|
59
|
+
_this.editorRef = ref;
|
|
60
|
+
};
|
|
37
61
|
_this.state = {
|
|
38
62
|
isContextInit: false,
|
|
39
63
|
errorMessage: null,
|
|
40
|
-
document: null
|
|
64
|
+
document: null,
|
|
65
|
+
isSaved: false,
|
|
66
|
+
isSaving: false
|
|
41
67
|
};
|
|
68
|
+
_this.saveTimer = null;
|
|
42
69
|
return _this;
|
|
43
70
|
}
|
|
44
71
|
_createClass(SimpleEditor, [{
|
|
45
72
|
key: "componentDidMount",
|
|
46
73
|
value: function () {
|
|
47
74
|
var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
48
|
-
var contentRes, result;
|
|
75
|
+
var contentRes, result, socketManager;
|
|
49
76
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
50
77
|
while (1) switch (_context.prev = _context.next) {
|
|
51
78
|
case 0:
|
|
@@ -81,6 +108,10 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
81
108
|
document: null
|
|
82
109
|
});
|
|
83
110
|
case 15:
|
|
111
|
+
socketManager = this.editorRef.getSocketManager();
|
|
112
|
+
this.unsubscribeSavingEvent = socketManager.subscribe('is-saving', this.onDocumentSaving);
|
|
113
|
+
this.unsubscribeSavedEvent = socketManager.subscribe('saved', this.onDocumentSaved);
|
|
114
|
+
case 18:
|
|
84
115
|
case "end":
|
|
85
116
|
return _context.stop();
|
|
86
117
|
}
|
|
@@ -91,6 +122,13 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
91
122
|
}
|
|
92
123
|
return componentDidMount;
|
|
93
124
|
}()
|
|
125
|
+
}, {
|
|
126
|
+
key: "componentWillUnmount",
|
|
127
|
+
value: function componentWillUnmount() {
|
|
128
|
+
this.unsubscribeSavingEvent();
|
|
129
|
+
this.unsubscribeSavedEvent();
|
|
130
|
+
clearTimeout(this.saveTimer);
|
|
131
|
+
}
|
|
94
132
|
}, {
|
|
95
133
|
key: "render",
|
|
96
134
|
value: function render() {
|
|
@@ -108,9 +146,22 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
108
146
|
}
|
|
109
147
|
var config = context.getEditorConfig();
|
|
110
148
|
var isOpenSocket = context.getSetting('isOpenSocket');
|
|
111
|
-
|
|
149
|
+
var _this$state2 = this.state,
|
|
150
|
+
isSaved = _this$state2.isSaved,
|
|
151
|
+
isSaving = _this$state2.isSaving;
|
|
152
|
+
return /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement("div", {
|
|
153
|
+
className: "doc-info"
|
|
154
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
155
|
+
className: "doc-name"
|
|
156
|
+
}, config.docName), /*#__PURE__*/React.createElement(TipMessage, {
|
|
157
|
+
isSaving: isSaving,
|
|
158
|
+
isSaved: isSaved
|
|
159
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
160
|
+
className: "doc-ops"
|
|
161
|
+
}, !isOpenSocket && /*#__PURE__*/React.createElement("button", {
|
|
112
162
|
onClick: this.onSave
|
|
113
163
|
}, "Save"))), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(SDocEditor, {
|
|
164
|
+
ref: this.setEditorRef,
|
|
114
165
|
config: config,
|
|
115
166
|
document: document,
|
|
116
167
|
isOpenSocket: isOpenSocket,
|
package/package.json
CHANGED
|
@@ -225,5 +225,7 @@
|
|
|
225
225
|
"Insert_column": "Insert column",
|
|
226
226
|
"The_link_address_is_required": "The link address is required.",
|
|
227
227
|
"The_link_title_is_required": "The link title is required.",
|
|
228
|
-
"The_link_address_is_invalid": "The link address is invalid, please enter a correct connection address."
|
|
228
|
+
"The_link_address_is_invalid": "The link address is invalid, please enter a correct connection address.",
|
|
229
|
+
"All_changes_saved": "All changes saved",
|
|
230
|
+
"Saving": "Saving..."
|
|
229
231
|
}
|
|
@@ -221,5 +221,7 @@
|
|
|
221
221
|
},
|
|
222
222
|
"The_link_address_is_required": "链接地址是必填项。",
|
|
223
223
|
"The_link_title_is_required": "链接标题是必填项。",
|
|
224
|
-
"The_link_address_is_invalid": "链接地址不合法,请输入一个正确的链接地址。"
|
|
224
|
+
"The_link_address_is_invalid": "链接地址不合法,请输入一个正确的链接地址。",
|
|
225
|
+
"All_changes_saved": "所有更改均已保存",
|
|
226
|
+
"Saving": "保存中..."
|
|
225
227
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
html, body {
|
|
2
|
-
height: 100%;
|
|
3
|
-
width: 100%;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
#root {
|
|
7
|
-
height: 100%;
|
|
8
|
-
width: 100%;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.markdown-wrapper {
|
|
12
|
-
flex: 1;
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
min-height: 0;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.markdown-header {
|
|
19
|
-
display: flex;
|
|
20
|
-
justify-content: flex-end;
|
|
21
|
-
padding: 0 1rem;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.markdown-content {
|
|
25
|
-
flex: 1;
|
|
26
|
-
min-height: 0;
|
|
27
|
-
display: flex;
|
|
28
|
-
}
|