@seafile/seafile-editor 0.3.99 → 0.3.102
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/README.md +42 -110
- package/dist/assets/css/comment-dialog.css +50 -0
- package/dist/{css → assets/css}/diff-viewer.css +0 -0
- package/dist/{css/richeditor → assets/css}/formula.css +0 -0
- package/dist/{css → assets/css}/history-viewer.css +0 -0
- package/dist/{css/richeditor → assets/css}/image.css +0 -0
- package/dist/assets/css/issue-card.css +43 -0
- package/dist/{css → assets/css}/keyboard-shortcuts.css +0 -0
- package/dist/{css/richeditor → assets/css}/link.css +0 -0
- package/dist/{css/plaineditor → assets/css}/markdown-editor.css +0 -0
- package/dist/{css → assets/css}/markdown-viewer.css +0 -0
- package/dist/{css/richeditor → assets/css}/navbar-imgbutton.css +0 -0
- package/dist/assets/css/outline.css +29 -0
- package/dist/{css/richeditor → assets/css}/table.css +0 -0
- package/dist/{css/richeditor → assets/css}/textlink-hovermenu.css +0 -0
- package/dist/{css → assets/css}/topbar.css +38 -146
- package/dist/{css/richeditor → assets/css}/tree-view.css +0 -0
- package/dist/{css/richeditor/right-panel.css → assets/css/user-help.css} +9 -9
- package/dist/assets/editor/plain-editor.css +30 -0
- package/dist/assets/editor/simple-editor.css +77 -0
- package/dist/components/add-formula-dialog.js +6 -4
- package/dist/components/add-image-dialog.js +3 -1
- package/dist/components/add-link-dialog.js +4 -3
- package/dist/components/comment-dialog.js +12 -6
- package/dist/components/markdown-lint.js +1 -0
- package/dist/components/outline/index.js +104 -0
- package/dist/components/outline/outline-item.js +70 -0
- package/dist/components/shortcut-dialog.js +1 -1
- package/dist/components/{topbar-component → toolbar}/header-list.js +0 -0
- package/dist/components/toolbar/help-group.js +40 -0
- package/dist/components/toolbar/index.js +4 -0
- package/dist/components/{topbar-component/upload-img.js → toolbar/insert-image.js} +18 -15
- package/dist/components/toolbar/insert-table.js +155 -0
- package/dist/components/toolbar/table-group.js +82 -0
- package/dist/components/{toolbar.js → toolbar/toolbar.js} +102 -64
- package/dist/components/{topbar-component → toolbar/widgets}/button-group.js +0 -0
- package/dist/components/toolbar/widgets/button-item.js +144 -0
- package/dist/components/toolbar/widgets/drop-list.js +101 -0
- package/dist/components/user-help.js +16 -10
- package/dist/editor/controller/block-element-controller.js +6 -2
- package/dist/editor/controller/inline-element-controller.js +6 -2
- package/dist/editor/editor-builder.js +107 -0
- package/dist/editor/editor-component/formula.js +4 -2
- package/dist/editor/editor-component/image.js +10 -6
- package/dist/editor/editor-component/table.js +1 -1
- package/dist/editor/editor-plugin.js +3 -1
- package/dist/editor/editor.js +1 -32
- package/dist/editor/index.js +97 -0
- package/dist/editor/markdown-editor.js +323 -0
- package/dist/editor/plain-markdown-editor.js +5 -4
- package/dist/editor/simple-editor.js +44 -78
- package/dist/index.js +9 -0
- package/dist/utils/slate2markdown/serialize.js +12 -1
- package/dist/viewer/diff-viewer.js +1 -1
- package/dist/viewer/markdown-viewer.js +16 -15
- package/dist/viewer/slate-viewer.js +40 -28
- package/dist/viewer/viewer-formula.js +1 -1
- package/package.json +18 -17
- package/dist/components/comment-panel.js +0 -431
- package/dist/components/detail-list-view.js +0 -104
- package/dist/components/generate-share-link.js +0 -412
- package/dist/components/internal-link-dialog.js +0 -96
- package/dist/components/outline.js +0 -130
- package/dist/components/participants-list.js +0 -126
- package/dist/components/side-panel.js +0 -174
- package/dist/components/topbar-component/icon-button.js +0 -99
- package/dist/components/topbar-component/insert-file.js +0 -67
- package/dist/components/topbar-component/table-toolbar.js +0 -175
- package/dist/css/layout.css +0 -111
- package/dist/css/markdown-viewer-slate/file-tags-list.css +0 -76
- package/dist/css/react-mentions-default-style.js +0 -76
- package/dist/css/richeditor/comments-list.css +0 -184
- package/dist/css/richeditor/detail-list-view.css +0 -105
- package/dist/css/richeditor/document-info.css +0 -57
- package/dist/css/richeditor/participants-list.css +0 -22
- package/dist/css/richeditor/rich-editor-main.css +0 -32
- package/dist/css/richeditor/side-panel.css +0 -183
- package/dist/editor/rich-markdown-editor.js +0 -521
- package/dist/editor/seafile-editor.js +0 -325
- package/dist/editor-api.js +0 -256
- package/dist/index.css +0 -97
- package/dist/seafile-editor-chooser.js +0 -45
- package/dist/seafile-markdown-editor.js +0 -289
- package/dist/seafile-markdown-viewer.js +0 -78
- package/dist/seafile-simple-editor.js +0 -56
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import toaster from '../components/toast';
|
|
8
|
-
import { withTranslation } from 'react-i18next';
|
|
9
|
-
import { Text } from 'slate';
|
|
10
|
-
import '../css/layout.css';
|
|
11
|
-
import '../css/topbar.css';
|
|
12
|
-
import RichMarkdownEditor from './rich-markdown-editor';
|
|
13
|
-
import PlainMarkdownEditor from './plain-markdown-editor';
|
|
14
|
-
import { serialize, deserialize } from '../utils/slate2markdown';
|
|
15
|
-
|
|
16
|
-
var SeafileEditor = /*#__PURE__*/function (_React$Component) {
|
|
17
|
-
_inherits(SeafileEditor, _React$Component);
|
|
18
|
-
|
|
19
|
-
var _super = _createSuper(SeafileEditor);
|
|
20
|
-
|
|
21
|
-
function SeafileEditor(props) {
|
|
22
|
-
var _this;
|
|
23
|
-
|
|
24
|
-
_classCallCheck(this, SeafileEditor);
|
|
25
|
-
|
|
26
|
-
_this = _super.call(this, props);
|
|
27
|
-
|
|
28
|
-
_this.switchToPlainTextEditor = function () {
|
|
29
|
-
// TODO: performance, change to do serialize in async way
|
|
30
|
-
if (_this.props.editorMode === 'rich') {
|
|
31
|
-
var value = _this.state.richValue;
|
|
32
|
-
var str = serialize(value);
|
|
33
|
-
|
|
34
|
-
_this.props.setEditorMode('plain');
|
|
35
|
-
|
|
36
|
-
_this.setState({
|
|
37
|
-
initialPlainValue: str,
|
|
38
|
-
currentContent: str
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (_this.props.collabServer) {
|
|
43
|
-
_this.props.emitSwitchEditor(false);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
_this.switchToRichTextEditor = function () {
|
|
48
|
-
// TODO: performance, change to do deserialize in async way
|
|
49
|
-
_this.setState({
|
|
50
|
-
richValue: deserialize(_this.state.currentContent)
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
_this.props.setEditorMode('rich');
|
|
54
|
-
|
|
55
|
-
if (_this.props.collabServer) {
|
|
56
|
-
_this.props.emitSwitchEditor(false);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
_this.onUnload = function (event) {
|
|
61
|
-
if (!_this.props.contentChanged) return;
|
|
62
|
-
var confirmationMessage = 'Leave this page? The system may not save your changes.';
|
|
63
|
-
|
|
64
|
-
_this.props.clearTimer();
|
|
65
|
-
|
|
66
|
-
_this.props.deleteDraft && _this.props.deleteDraft();
|
|
67
|
-
event.returnValue = confirmationMessage;
|
|
68
|
-
return confirmationMessage;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
_this.onChange = function (value, operations) {
|
|
72
|
-
if (_this.props.editorMode === 'rich') {
|
|
73
|
-
_this.setState({
|
|
74
|
-
richValue: value
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
_this.props.setDraftValue('rich', _this.state.richValue);
|
|
78
|
-
|
|
79
|
-
var ops = operations.filter(function (o) {
|
|
80
|
-
return o.type !== 'set_selection' && o.type !== 'set_value';
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
if (ops.length !== 0) {
|
|
84
|
-
_this.props.onContentChanged(true);
|
|
85
|
-
|
|
86
|
-
if (_this.autoSave) _this.props.autoSaveDraft();
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
_this.setState({
|
|
90
|
-
currentContent: value
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
_this.props.onContentChanged(true);
|
|
94
|
-
|
|
95
|
-
_this.props.setDraftValue('rich', _this.state.richValue);
|
|
96
|
-
|
|
97
|
-
_this.props.autoSaveDraft();
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
_this.saveContent = function (str) {
|
|
102
|
-
_this.props.editorApi.saveContent(str).then(function () {
|
|
103
|
-
_this.props.onSaving(false);
|
|
104
|
-
|
|
105
|
-
_this.props.onContentChanged(false); // remove markdown lint temporarily
|
|
106
|
-
// if (this.props.markdownLint) {
|
|
107
|
-
// const slateValue = this.state.richValue;
|
|
108
|
-
// this.props.editorApi.markdownLint(JSON.stringify(slateValue)).then((res) => {
|
|
109
|
-
// this.setState({
|
|
110
|
-
// issues: res.data
|
|
111
|
-
// });
|
|
112
|
-
// });
|
|
113
|
-
// }
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
_this.lastModifyTime = new Date();
|
|
117
|
-
toaster.success(_this.props.t('file_saved'), {
|
|
118
|
-
duration: 2
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
_this.props.editorApi.getFileInfo().then(function (res) {
|
|
122
|
-
_this.props.setFileInfoMtime(res.data);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
_this.addParticipants();
|
|
126
|
-
}, function () {
|
|
127
|
-
_this.props.onSaving(false);
|
|
128
|
-
|
|
129
|
-
toaster.danger(_this.props.t('file_failed_to_save'), {
|
|
130
|
-
duration: 2
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
_this.props.onSaving(true);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
_this.addParticipants = function () {
|
|
138
|
-
if (_this.isParticipant || !window.showParticipants) return;
|
|
139
|
-
var _this$props$editorApi = _this.props.editorApi,
|
|
140
|
-
userName = _this$props$editorApi.userName,
|
|
141
|
-
addFileParticipants = _this$props$editorApi.addFileParticipants;
|
|
142
|
-
var participants = _this.props.participants;
|
|
143
|
-
|
|
144
|
-
if (participants && participants.length !== 0) {
|
|
145
|
-
_this.isParticipant = participants.every(function (participant) {
|
|
146
|
-
return participant.email === userName;
|
|
147
|
-
});
|
|
148
|
-
if (_this.isParticipant) return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
var emails = [userName];
|
|
152
|
-
addFileParticipants(emails).then(function (res) {
|
|
153
|
-
_this.isParticipant = true;
|
|
154
|
-
|
|
155
|
-
_this.props.onParticipantsChange();
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
_this.onRichEditorSave = function () {
|
|
160
|
-
if (_this.props.isSaving) return;
|
|
161
|
-
var value = _this.state.richValue;
|
|
162
|
-
var str = serialize(value);
|
|
163
|
-
|
|
164
|
-
_this.saveContent(str);
|
|
165
|
-
|
|
166
|
-
_this.props.clearTimer();
|
|
167
|
-
|
|
168
|
-
_this.props.deleteDraft && _this.props.deleteDraft();
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
_this.resetRichValue = function () {
|
|
172
|
-
var value = _this.state.richValue;
|
|
173
|
-
|
|
174
|
-
_this.setState({
|
|
175
|
-
richValue: value
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
_this.onPlainEditorSave = function () {
|
|
180
|
-
if (_this.props.isSaving) return;
|
|
181
|
-
var str = _this.state.currentContent;
|
|
182
|
-
|
|
183
|
-
_this.saveContent(str);
|
|
184
|
-
|
|
185
|
-
_this.props.clearTimer();
|
|
186
|
-
|
|
187
|
-
_this.props.deleteDraft && _this.props.deleteDraft();
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
_this.resetContentChanged = function () {
|
|
191
|
-
if (_this.props.contentChanged) {
|
|
192
|
-
_this.props.onContentChanged(false);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
_this.autoSave = true;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
var markdownContent = _this.props.markdownContent;
|
|
199
|
-
var isEditMode = _this.props.mode === 'editor';
|
|
200
|
-
var isDraft = _this.props.isDraft;
|
|
201
|
-
_this.lastModifyTime = null;
|
|
202
|
-
_this.autoSave = false;
|
|
203
|
-
_this.isParticipant = false;
|
|
204
|
-
window.seafileEditor = _assertThisInitialized(_this);
|
|
205
|
-
_this.state = {
|
|
206
|
-
isTreeDataLoaded: false,
|
|
207
|
-
initialPlainValue: '',
|
|
208
|
-
// for plain editor
|
|
209
|
-
currentContent: markdownContent,
|
|
210
|
-
// for plain editor and viewer
|
|
211
|
-
richValue: isEditMode || isDraft ? deserialize(markdownContent) : deserialize(''),
|
|
212
|
-
// for rich editor
|
|
213
|
-
issues: {
|
|
214
|
-
issue_list: []
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
return _this;
|
|
218
|
-
} // componentWillReceiveProps(nextProps) {
|
|
219
|
-
// if (this.props.markdownContent !== nextProps.markdownContent) {
|
|
220
|
-
// this.setState({ richValue: deserialize(nextProps.markdownContent) });
|
|
221
|
-
// }
|
|
222
|
-
// }
|
|
223
|
-
// from rich editor to plain editor
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
_createClass(SeafileEditor, [{
|
|
227
|
-
key: "componentDidMount",
|
|
228
|
-
value: function componentDidMount() {
|
|
229
|
-
// window.seafileEditor = this;
|
|
230
|
-
window.addEventListener('beforeunload', this.onUnload);
|
|
231
|
-
}
|
|
232
|
-
}, {
|
|
233
|
-
key: "componentWillMount",
|
|
234
|
-
value:
|
|
235
|
-
/*
|
|
236
|
-
* when seafileEditor first mounted check the content
|
|
237
|
-
* if the content is empty add h1 to document
|
|
238
|
-
* */
|
|
239
|
-
function componentWillMount() {
|
|
240
|
-
if (this.props.editorMode === 'rich') {
|
|
241
|
-
var document = this.state.richValue;
|
|
242
|
-
var firstNode = document[0];
|
|
243
|
-
/**
|
|
244
|
-
* if the markdown content is empty, the rich value contains
|
|
245
|
-
* only a paragraph which contains a empty text node
|
|
246
|
-
*
|
|
247
|
-
*/
|
|
248
|
-
|
|
249
|
-
if (document.length === 1 && firstNode.type === 'paragraph' && firstNode.children.length === 1 && Text.isText(firstNode.children[0]) && firstNode.children[0].text.length === 0) {
|
|
250
|
-
var headerContent = this.props.fileInfo.name.slice(0, this.props.fileInfo.name.lastIndexOf('.'));
|
|
251
|
-
var header = {
|
|
252
|
-
type: 'header_one',
|
|
253
|
-
children: [{
|
|
254
|
-
text: headerContent,
|
|
255
|
-
marks: []
|
|
256
|
-
}]
|
|
257
|
-
};
|
|
258
|
-
document.push(header);
|
|
259
|
-
document.shift();
|
|
260
|
-
this.setState({
|
|
261
|
-
richValue: document
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}, {
|
|
267
|
-
key: "render",
|
|
268
|
-
value: function render() {
|
|
269
|
-
var dom = '';
|
|
270
|
-
|
|
271
|
-
if (this.props.editorMode === 'rich') {
|
|
272
|
-
dom = /*#__PURE__*/React.createElement(RichMarkdownEditor, {
|
|
273
|
-
editorApi: this.props.editorApi,
|
|
274
|
-
onChange: this.onChange,
|
|
275
|
-
onSave: this.onRichEditorSave,
|
|
276
|
-
value: this.state.richValue,
|
|
277
|
-
resetRichValue: this.resetRichValue,
|
|
278
|
-
contentChanged: this.props.contentChanged,
|
|
279
|
-
saving: this.props.saving,
|
|
280
|
-
switchToMarkDownViewer: this.switchToMarkDownViewer,
|
|
281
|
-
switchToPlainTextEditor: this.switchToPlainTextEditor,
|
|
282
|
-
fileInfo: this.props.fileInfo,
|
|
283
|
-
toggleStar: this.props.toggleStar,
|
|
284
|
-
issues: this.state.issues,
|
|
285
|
-
resetContentChanged: this.resetContentChanged,
|
|
286
|
-
collabUsers: this.props.collabUsers,
|
|
287
|
-
mode: this.props.editorMode,
|
|
288
|
-
draftID: this.props.draftID,
|
|
289
|
-
isDraft: this.props.isDraft,
|
|
290
|
-
openDialogs: this.props.openDialogs,
|
|
291
|
-
readOnly: this.props.readOnly,
|
|
292
|
-
fileTagList: this.props.fileTagList,
|
|
293
|
-
participants: this.props.participants,
|
|
294
|
-
onParticipantsChange: this.props.onParticipantsChange
|
|
295
|
-
});
|
|
296
|
-
} else if (this.props.editorMode === 'plain') {
|
|
297
|
-
dom = /*#__PURE__*/React.createElement(PlainMarkdownEditor, {
|
|
298
|
-
editorApi: this.props.editorApi,
|
|
299
|
-
initialValue: this.state.initialPlainValue,
|
|
300
|
-
currentContent: this.state.currentContent,
|
|
301
|
-
contentChanged: this.props.contentChanged,
|
|
302
|
-
switchToRichTextEditor: this.switchToRichTextEditor,
|
|
303
|
-
switchToMarkDownViewer: this.switchToMarkDownViewer,
|
|
304
|
-
onSave: this.onPlainEditorSave,
|
|
305
|
-
onChange: this.onChange,
|
|
306
|
-
fileInfo: this.props.fileInfo,
|
|
307
|
-
toggleStar: this.props.toggleStar,
|
|
308
|
-
collabUsers: this.props.collabUsers,
|
|
309
|
-
mode: this.props.editorMode,
|
|
310
|
-
draftID: this.props.draftID,
|
|
311
|
-
isDraft: this.props.isDraft
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return dom;
|
|
316
|
-
}
|
|
317
|
-
}]);
|
|
318
|
-
|
|
319
|
-
return SeafileEditor;
|
|
320
|
-
}(React.Component);
|
|
321
|
-
|
|
322
|
-
SeafileEditor.defaultProps = {
|
|
323
|
-
userInfo: null
|
|
324
|
-
};
|
|
325
|
-
export default withTranslation('seafile-editor')(SeafileEditor);
|
package/dist/editor-api.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import { SeafileAPI } from 'seafile-js';
|
|
4
|
-
import { serverConfig } from './config';
|
|
5
|
-
var serviceUrl = serverConfig.serviceUrl,
|
|
6
|
-
username = serverConfig.username,
|
|
7
|
-
password = serverConfig.password;
|
|
8
|
-
var seafileAPI = new SeafileAPI();
|
|
9
|
-
seafileAPI.init({
|
|
10
|
-
server: serviceUrl,
|
|
11
|
-
username: username,
|
|
12
|
-
password: password
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
function getImageFileNameWithTimestamp(file) {
|
|
16
|
-
var d = Date.now();
|
|
17
|
-
return 'image-' + d.toString() + file.name.slice(file.name.lastIndexOf('.'));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var EditorApi = /*#__PURE__*/function () {
|
|
21
|
-
function EditorApi(repoID, fileName, dirPath, name, filePath, serviceUrl, username, contact_email, repoName) {
|
|
22
|
-
var _this = this;
|
|
23
|
-
|
|
24
|
-
_classCallCheck(this, EditorApi);
|
|
25
|
-
|
|
26
|
-
this.uploadLocalImage = function (imageFile) {
|
|
27
|
-
return _this.seafileAPI.getUploadLink(_this.repoID, '/').then(function (res) {
|
|
28
|
-
var uploadLink = res.data + '?ret-json=1';
|
|
29
|
-
var newFile = new File([imageFile], getImageFileNameWithTimestamp(imageFile), {
|
|
30
|
-
type: imageFile.type
|
|
31
|
-
});
|
|
32
|
-
var formData = new FormData();
|
|
33
|
-
formData.append('parent_dir', '/');
|
|
34
|
-
formData.append('relative_path', 'images/auto-upload');
|
|
35
|
-
formData.append('file', newFile);
|
|
36
|
-
return _this.seafileAPI.uploadImage(uploadLink, formData);
|
|
37
|
-
}).then(function (res) {
|
|
38
|
-
return _this._getImageURL(res.data[0].name);
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
this.getDraftKey = function () {
|
|
43
|
-
return _this.repoID + _this.filePath;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
this.addFileParticipants = function (emails) {
|
|
47
|
-
return _this.seafileAPI.addFileParticipants(_this.repoID, _this.filePath, emails);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
this.seafileAPI = seafileAPI;
|
|
51
|
-
this.repoID = repoID;
|
|
52
|
-
this.filePath = filePath;
|
|
53
|
-
this.serviceUrl = serviceUrl;
|
|
54
|
-
this.dirPath = dirPath;
|
|
55
|
-
this.fileName = fileName;
|
|
56
|
-
this.userName = username;
|
|
57
|
-
this.contact_email = contact_email;
|
|
58
|
-
this.name = name;
|
|
59
|
-
this.repoName = repoName;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
_createClass(EditorApi, [{
|
|
63
|
-
key: "login",
|
|
64
|
-
value: function login() {
|
|
65
|
-
return this.seafileAPI.login();
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "saveContent",
|
|
69
|
-
value: function saveContent(content) {
|
|
70
|
-
var _this2 = this;
|
|
71
|
-
|
|
72
|
-
return this.seafileAPI.getUpdateLink(this.repoID, this.dirPath).then(function (res) {
|
|
73
|
-
var uploadLink = res.data;
|
|
74
|
-
return _this2.seafileAPI.updateFile(uploadLink, _this2.filePath, _this2.fileName, content);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}, {
|
|
78
|
-
key: "unStarItem",
|
|
79
|
-
value: function unStarItem() {
|
|
80
|
-
return this.seafileAPI.unstarItem(this.repoID, this.filePath);
|
|
81
|
-
}
|
|
82
|
-
}, {
|
|
83
|
-
key: "starItem",
|
|
84
|
-
value: function starItem() {
|
|
85
|
-
return this.seafileAPI.starItem(this.repoID, this.filePath);
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "createShareLink",
|
|
89
|
-
value: function createShareLink(userPassword, userValidDays) {
|
|
90
|
-
return this.seafileAPI.createShareLink(this.repoID, this.filePath, userPassword, userValidDays);
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "getShareLink",
|
|
94
|
-
value: function getShareLink() {
|
|
95
|
-
return this.seafileAPI.getShareLink(this.repoID, this.filePath);
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "deleteShareLink",
|
|
99
|
-
value: function deleteShareLink(token) {
|
|
100
|
-
return this.seafileAPI.deleteShareLink(token);
|
|
101
|
-
}
|
|
102
|
-
}, {
|
|
103
|
-
key: "getCommentsNumber",
|
|
104
|
-
value: function getCommentsNumber() {
|
|
105
|
-
return this.seafileAPI.getCommentsNumber(this.repoID, this.filePath);
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
key: "postComment",
|
|
109
|
-
value: function postComment(comment, detail) {
|
|
110
|
-
return this.seafileAPI.postComment(this.repoID, this.filePath, comment, detail);
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
key: "listComments",
|
|
114
|
-
value: function listComments() {
|
|
115
|
-
return this.seafileAPI.listComments(this.repoID, this.filePath);
|
|
116
|
-
}
|
|
117
|
-
}, {
|
|
118
|
-
key: "updateComment",
|
|
119
|
-
value: function updateComment(commentID, resolved, detail, newComment) {
|
|
120
|
-
return this.seafileAPI.updateComment(this.repoID, commentID, resolved, detail, newComment);
|
|
121
|
-
}
|
|
122
|
-
}, {
|
|
123
|
-
key: "deleteComment",
|
|
124
|
-
value: function deleteComment(commentID) {
|
|
125
|
-
return this.seafileAPI.deleteComment(this.repoID, commentID);
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "getUserAvatar",
|
|
129
|
-
value: function getUserAvatar(size) {
|
|
130
|
-
return this.seafileAPI.getUserAvatar(this.userName, size);
|
|
131
|
-
}
|
|
132
|
-
}, {
|
|
133
|
-
key: "getParentDectionaryUrl",
|
|
134
|
-
value: function getParentDectionaryUrl() {
|
|
135
|
-
return this.serviceUrl + '/#common/lib/' + this.repoID + '/';
|
|
136
|
-
}
|
|
137
|
-
}, {
|
|
138
|
-
key: "_getImageURL",
|
|
139
|
-
value: function _getImageURL(fileName) {
|
|
140
|
-
var url = this.serviceUrl + '/lib/' + this.repoID + '/file/images/auto-upload/' + fileName + '?raw=1';
|
|
141
|
-
return url;
|
|
142
|
-
}
|
|
143
|
-
}, {
|
|
144
|
-
key: "getFileContent",
|
|
145
|
-
value: function getFileContent(url) {
|
|
146
|
-
return this.seafileAPI.getFileContent(url);
|
|
147
|
-
}
|
|
148
|
-
}, {
|
|
149
|
-
key: "getFileURL",
|
|
150
|
-
value: function getFileURL(fileNode) {
|
|
151
|
-
var url;
|
|
152
|
-
|
|
153
|
-
if (fileNode.type === 'file') {
|
|
154
|
-
if (fileNode.isImage()) {
|
|
155
|
-
url = this.serviceUrl + '/lib/' + this.repoID + '/file' + encodeURIComponent(fileNode.path()) + '?raw=1';
|
|
156
|
-
} else {
|
|
157
|
-
url = this.serviceUrl + '/lib/' + this.repoID + '/file' + encodeURIComponent(fileNode.path());
|
|
158
|
-
}
|
|
159
|
-
} else {
|
|
160
|
-
url = this.serviceUrl + '/#common/lib/' + this.repoID + encodeURIComponent(fileNode.path());
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return url;
|
|
164
|
-
}
|
|
165
|
-
}, {
|
|
166
|
-
key: "isInternalFileLink",
|
|
167
|
-
value: function isInternalFileLink(url) {
|
|
168
|
-
var re = new RegExp("".concat(this.serviceUrl, "/lib/[0-9a-f-]{36}/file.*"));
|
|
169
|
-
return re.test(url);
|
|
170
|
-
}
|
|
171
|
-
}, {
|
|
172
|
-
key: "listFileHistoryRecords",
|
|
173
|
-
value: function listFileHistoryRecords(page, perPage) {
|
|
174
|
-
return this.seafileAPI.listFileHistoryRecords(this.repoID, this.filePath, page, perPage);
|
|
175
|
-
}
|
|
176
|
-
}, {
|
|
177
|
-
key: "getFileHistoryVersion",
|
|
178
|
-
value: function getFileHistoryVersion(commitID) {
|
|
179
|
-
return this.seafileAPI.getFileRevision(this.repoID, commitID, this.filePath);
|
|
180
|
-
}
|
|
181
|
-
}, {
|
|
182
|
-
key: "getFileInfo",
|
|
183
|
-
value: function getFileInfo() {
|
|
184
|
-
return this.seafileAPI.getFileInfo(this.repoID, this.filePath);
|
|
185
|
-
}
|
|
186
|
-
}, {
|
|
187
|
-
key: "isInternalDirLink",
|
|
188
|
-
value: function isInternalDirLink(url) {
|
|
189
|
-
var re = new RegExp("".concat(this.serviceUrl, "/#[a-z-]*?/lib/[0-9a-f-]{36}.*"));
|
|
190
|
-
return re.test(url);
|
|
191
|
-
}
|
|
192
|
-
}, {
|
|
193
|
-
key: "getFiles",
|
|
194
|
-
value: function getFiles() {
|
|
195
|
-
// return promise
|
|
196
|
-
return this.seafileAPI.listDir(this.repoID, this.dirPath, {
|
|
197
|
-
recursive: true
|
|
198
|
-
}).then(function (response) {
|
|
199
|
-
var files = response.data.map(function (item) {
|
|
200
|
-
return {
|
|
201
|
-
name: item.name,
|
|
202
|
-
type: item.type === 'dir' ? 'dir' : 'file',
|
|
203
|
-
parent_path: item.parent_dir
|
|
204
|
-
};
|
|
205
|
-
});
|
|
206
|
-
return files;
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}, {
|
|
210
|
-
key: "getInternalLink",
|
|
211
|
-
value: function getInternalLink() {
|
|
212
|
-
return this.seafileAPI.getInternalLink(this.repoID, this.filePath);
|
|
213
|
-
}
|
|
214
|
-
}, {
|
|
215
|
-
key: "getFileDownloadLink",
|
|
216
|
-
value: function getFileDownloadLink(repoID, filePath) {
|
|
217
|
-
return this.seafileAPI.getFileDownloadLink(repoID, filePath);
|
|
218
|
-
}
|
|
219
|
-
}, {
|
|
220
|
-
key: "fileMetaData",
|
|
221
|
-
value: function fileMetaData() {
|
|
222
|
-
return this.seafileAPI.fileMetaData(this.repoID, this.filePath);
|
|
223
|
-
}
|
|
224
|
-
}, {
|
|
225
|
-
key: "listFileTags",
|
|
226
|
-
value: function listFileTags() {
|
|
227
|
-
return this.seafileAPI.listFileTags(this.repoID, this.filePath);
|
|
228
|
-
}
|
|
229
|
-
}, {
|
|
230
|
-
key: "markdownLint",
|
|
231
|
-
value: function markdownLint(slateValue) {
|
|
232
|
-
return this.seafileAPI.markdownLint(slateValue);
|
|
233
|
-
}
|
|
234
|
-
}, {
|
|
235
|
-
key: "searchUsers",
|
|
236
|
-
value: function searchUsers(searchParam) {
|
|
237
|
-
return this.seafileAPI.searchUsers(searchParam);
|
|
238
|
-
}
|
|
239
|
-
}, {
|
|
240
|
-
key: "listRepoRelatedUsers",
|
|
241
|
-
value: function listRepoRelatedUsers() {
|
|
242
|
-
return this.seafileAPI.listRepoRelatedUsers(this.repoID);
|
|
243
|
-
}
|
|
244
|
-
}]);
|
|
245
|
-
|
|
246
|
-
return EditorApi;
|
|
247
|
-
}();
|
|
248
|
-
|
|
249
|
-
var repoID = serverConfig.repoID,
|
|
250
|
-
fileName = serverConfig.fileName,
|
|
251
|
-
dirPath = serverConfig.dirPath,
|
|
252
|
-
name = serverConfig.name,
|
|
253
|
-
filePath = serverConfig.filePath,
|
|
254
|
-
contact_email = serverConfig.contact_email;
|
|
255
|
-
var editorApi = new EditorApi(repoID, fileName, dirPath, name, filePath, serviceUrl, username, contact_email);
|
|
256
|
-
export default editorApi;
|
package/dist/index.css
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
* {
|
|
2
|
-
margin: 0;
|
|
3
|
-
padding: 0;
|
|
4
|
-
}
|
|
5
|
-
html,
|
|
6
|
-
input,
|
|
7
|
-
textarea {
|
|
8
|
-
font-family: 'Roboto', sans-serif;
|
|
9
|
-
line-height: 1.4;
|
|
10
|
-
background: #eee;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
body {
|
|
14
|
-
overflow-y: hidden;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
p {
|
|
18
|
-
margin: 0;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
:not(pre) > code {
|
|
22
|
-
font-family: monospace;
|
|
23
|
-
background-color: #eee;
|
|
24
|
-
padding: 3px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
img {
|
|
28
|
-
max-width: 100%;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
img.active {
|
|
32
|
-
box-shadow: 0 0 0 2px blue;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
input {
|
|
36
|
-
box-sizing: border-box;
|
|
37
|
-
font-size: 0.85em;
|
|
38
|
-
width: 100%;
|
|
39
|
-
padding: 0.5em;
|
|
40
|
-
border: 2px solid #ddd;
|
|
41
|
-
background: #fafafa;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
input:focus {
|
|
45
|
-
outline: 0;
|
|
46
|
-
border-color: blue;
|
|
47
|
-
}
|
|
48
|
-
input[type="checkbox"] {
|
|
49
|
-
width: auto;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.lds-ripple {
|
|
54
|
-
display: inline-block;
|
|
55
|
-
position: relative;
|
|
56
|
-
width: 64px;
|
|
57
|
-
height: 64px;
|
|
58
|
-
}
|
|
59
|
-
.lds-ripple div {
|
|
60
|
-
position: absolute;
|
|
61
|
-
border: 4px solid #eb8205;
|
|
62
|
-
opacity: 1;
|
|
63
|
-
border-radius: 50%;
|
|
64
|
-
animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
|
|
65
|
-
}
|
|
66
|
-
.lds-ripple div:nth-child(2) {
|
|
67
|
-
animation-delay: -0.5s;
|
|
68
|
-
}
|
|
69
|
-
@keyframes lds-ripple {
|
|
70
|
-
0% {
|
|
71
|
-
top: 28px;
|
|
72
|
-
left: 28px;
|
|
73
|
-
width: 0;
|
|
74
|
-
height: 0;
|
|
75
|
-
opacity: 1;
|
|
76
|
-
}
|
|
77
|
-
100% {
|
|
78
|
-
top: -1px;
|
|
79
|
-
left: -1px;
|
|
80
|
-
width: 58px;
|
|
81
|
-
height: 58px;
|
|
82
|
-
opacity: 0;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
.empty-loading-page {
|
|
86
|
-
position: fixed;
|
|
87
|
-
height: 100%;
|
|
88
|
-
width: 100%;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.page-centered {
|
|
92
|
-
position: fixed;
|
|
93
|
-
top: 50%;
|
|
94
|
-
left: 50%;
|
|
95
|
-
/* bring your own prefixes */
|
|
96
|
-
transform: translate(-50%, -50%);
|
|
97
|
-
}
|