@seafile/seafile-editor 0.3.76
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 +119 -0
- package/TODO.md +55 -0
- package/dist/components/add-formula-dialog.js +135 -0
- package/dist/components/add-image-dialog.js +78 -0
- package/dist/components/add-link-dialog.js +148 -0
- package/dist/components/comment-dialog.js +107 -0
- package/dist/components/comment-panel.js +452 -0
- package/dist/components/context-menu.js +112 -0
- package/dist/components/detail-list-view.js +119 -0
- package/dist/components/generate-share-link.js +412 -0
- package/dist/components/internal-link-dialog.js +96 -0
- package/dist/components/loading.js +32 -0
- package/dist/components/markdown-lint.js +87 -0
- package/dist/components/modal-portal.js +46 -0
- package/dist/components/outline.js +130 -0
- package/dist/components/participants-list.js +126 -0
- package/dist/components/related-files-list.js +75 -0
- package/dist/components/shortcut-dialog.js +167 -0
- package/dist/components/side-panel.js +175 -0
- package/dist/components/toast/alert.js +150 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toast/toast.js +179 -0
- package/dist/components/toast/toastManager.js +158 -0
- package/dist/components/toast/toaster.js +76 -0
- package/dist/components/toolbar.js +235 -0
- package/dist/components/topbar-component/button-group.js +31 -0
- package/dist/components/topbar-component/editor-toolbar.js +545 -0
- package/dist/components/topbar-component/file-info.js +65 -0
- package/dist/components/topbar-component/header-list.js +128 -0
- package/dist/components/topbar-component/icon-button.js +99 -0
- package/dist/components/topbar-component/insert-file.js +67 -0
- package/dist/components/topbar-component/table-toolbar.js +175 -0
- package/dist/components/topbar-component/upload-img.js +122 -0
- package/dist/components/user-help.js +205 -0
- package/dist/css/diff-viewer.css +105 -0
- package/dist/css/history-viewer.css +104 -0
- package/dist/css/keyboard-shortcuts.css +59 -0
- package/dist/css/layout.css +110 -0
- package/dist/css/markdown-viewer-slate/file-tags-list.css +76 -0
- package/dist/css/markdown-viewer.css +69 -0
- package/dist/css/plaineditor/markdown-editor.css +12 -0
- package/dist/css/react-mentions-default-style.js +72 -0
- package/dist/css/related-files-list.css +56 -0
- package/dist/css/richeditor/comments-list.css +184 -0
- package/dist/css/richeditor/detail-list-view.css +114 -0
- package/dist/css/richeditor/document-info.css +57 -0
- package/dist/css/richeditor/formula.css +19 -0
- package/dist/css/richeditor/image.css +141 -0
- package/dist/css/richeditor/link.css +7 -0
- package/dist/css/richeditor/navbar-imgbutton.css +79 -0
- package/dist/css/richeditor/participants-list.css +22 -0
- package/dist/css/richeditor/rich-editor-main.css +42 -0
- package/dist/css/richeditor/right-panel.css +84 -0
- package/dist/css/richeditor/side-panel.css +190 -0
- package/dist/css/richeditor/table.css +57 -0
- package/dist/css/richeditor/textlink-hovermenu.css +47 -0
- package/dist/css/richeditor/tree-view.css +67 -0
- package/dist/css/topbar.css +400 -0
- package/dist/editor/code-highlight-package.js +27 -0
- package/dist/editor/controller/block-element-controller.js +376 -0
- package/dist/editor/controller/inline-element-controller.js +129 -0
- package/dist/editor/controller/normalize-controller.js +107 -0
- package/dist/editor/controller/shortcut-controller.js +394 -0
- package/dist/editor/controller/void-element-controller.js +12 -0
- package/dist/editor/custom/custom.js +17 -0
- package/dist/editor/custom/get-event-transfer.js +34 -0
- package/dist/editor/custom/getNodesByTypeAtRange.js +69 -0
- package/dist/editor/custom/insertNodes.js +140 -0
- package/dist/editor/custom/is-empty-paragraph.js +13 -0
- package/dist/editor/custom/set-event-transfer.js +31 -0
- package/dist/editor/custom/split-nodes-at-point.js +162 -0
- package/dist/editor/custom/unwrap-node-by-type-at-range.js +81 -0
- package/dist/editor/editor-component/check-list-item.js +64 -0
- package/dist/editor/editor-component/code-block.js +150 -0
- package/dist/editor/editor-component/formula.js +79 -0
- package/dist/editor/editor-component/image.js +215 -0
- package/dist/editor/editor-component/link.js +11 -0
- package/dist/editor/editor-component/table.js +172 -0
- package/dist/editor/editor-component/textlink-hovermenu.js +136 -0
- package/dist/editor/editor-plugin.js +249 -0
- package/dist/editor/editor-utils/block-element-utils/blockquote-utils.js +96 -0
- package/dist/editor/editor-utils/block-element-utils/code-utils.js +162 -0
- package/dist/editor/editor-utils/block-element-utils/formula-utils.js +58 -0
- package/dist/editor/editor-utils/block-element-utils/index.js +38 -0
- package/dist/editor/editor-utils/block-element-utils/list-utils.js +398 -0
- package/dist/editor/editor-utils/block-element-utils/table-utils.js +418 -0
- package/dist/editor/editor-utils/common-editor-utils.js +587 -0
- package/dist/editor/editor-utils/inline-element-utils/index.js +95 -0
- package/dist/editor/editor-utils/mark-utils.js +25 -0
- package/dist/editor/editor-utils/range-utils.js +9 -0
- package/dist/editor/editor-utils/selection-utils.js +33 -0
- package/dist/editor/editor-utils/text-utils.js +130 -0
- package/dist/editor/editor.js +66 -0
- package/dist/editor/element-model/blockquote.js +16 -0
- package/dist/editor/element-model/image.js +19 -0
- package/dist/editor/element-model/link.js +19 -0
- package/dist/editor/element-model/table.js +50 -0
- package/dist/editor/element-model/text.js +13 -0
- package/dist/editor/load-script.js +83 -0
- package/dist/editor/plain-markdown-editor.js +324 -0
- package/dist/editor/rich-markdown-editor.js +580 -0
- package/dist/editor/seafile-editor.js +326 -0
- package/dist/editor/simple-editor.js +245 -0
- package/dist/editor-api.js +261 -0
- package/dist/index.css +97 -0
- package/dist/lib/slate-hyperscript/creators.js +263 -0
- package/dist/lib/slate-hyperscript/hyperscript.js +92 -0
- package/dist/lib/slate-hyperscript/index.js +3 -0
- package/dist/lib/slate-hyperscript/tokens.js +102 -0
- package/dist/lib/unified/index.js +470 -0
- package/dist/lib/vfile/core.js +172 -0
- package/dist/lib/vfile/index.js +48 -0
- package/dist/seafile-editor-chooser.js +45 -0
- package/dist/seafile-markdown-editor.js +301 -0
- package/dist/seafile-markdown-viewer.js +79 -0
- package/dist/seafile-simple-editor.js +56 -0
- package/dist/utils/copy-to-clipboard.js +47 -0
- package/dist/utils/deserialize-html.js +282 -0
- package/dist/utils/diff/compare-strings.js +46 -0
- package/dist/utils/diff/diff.js +855 -0
- package/dist/utils/diff/index.js +2 -0
- package/dist/utils/render-slate.js +219 -0
- package/dist/utils/seafile-markdown2html.js +62 -0
- package/dist/utils/slate2markdown/deserialize.js +689 -0
- package/dist/utils/slate2markdown/index.js +3 -0
- package/dist/utils/slate2markdown/serialize.js +407 -0
- package/dist/utils/utils.js +28 -0
- package/dist/viewer/diff-viewer.js +98 -0
- package/dist/viewer/markdown-viewer.js +139 -0
- package/dist/viewer/slate-viewer.js +73 -0
- package/dist/viewer/viewer-formula.js +67 -0
- package/dist/viewer/viewer-image.js +93 -0
- package/dist/viewer/viewer-outline.js +118 -0
- package/package.json +215 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +45 -0
- package/public/locales/cs/seafile-editor.json +169 -0
- package/public/locales/de/seafile-editor.json +169 -0
- package/public/locales/en/seafile-editor.json +222 -0
- package/public/locales/es/seafile-editor.json +169 -0
- package/public/locales/es-AR/seafile-editor.json +169 -0
- package/public/locales/es-MX/seafile-editor.json +169 -0
- package/public/locales/fr/seafile-editor.json +169 -0
- package/public/locales/it/seafile-editor.json +169 -0
- package/public/locales/ru/seafile-editor.json +169 -0
- package/public/locales/zh-CN/seafile-editor.json +219 -0
- package/public/manifest.json +15 -0
- package/public/media/scripts/mathjax/tex-svg.js +1 -0
- package/public/media/seafile-editor-font/iconfont.eot +0 -0
- package/public/media/seafile-editor-font/iconfont.svg +164 -0
- package/public/media/seafile-editor-font/iconfont.ttf +0 -0
- package/public/media/seafile-editor-font/iconfont.woff +0 -0
- package/public/media/seafile-editor-font/iconfont.woff2 +0 -0
- package/public/media/seafile-editor-font.css +201 -0
- package/public/media/seafile-logo.png +0 -0
- package/public/media/seafile-ui.css +11169 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
|
|
5
|
+
var replace = require('replace-ext');
|
|
6
|
+
|
|
7
|
+
var buffer = require('is-buffer');
|
|
8
|
+
|
|
9
|
+
module.exports = VFile;
|
|
10
|
+
var own = {}.hasOwnProperty;
|
|
11
|
+
var proto = VFile.prototype;
|
|
12
|
+
proto.toString = toString;
|
|
13
|
+
/* Order of setting (least specific to most), we need this because
|
|
14
|
+
* otherwise `{stem: 'a', path: '~/b.js'}` would throw, as a path
|
|
15
|
+
* is needed before a stem can be set. */
|
|
16
|
+
|
|
17
|
+
var order = ['history', 'path', 'basename', 'stem', 'extname', 'dirname'];
|
|
18
|
+
/* Construct a new file. */
|
|
19
|
+
|
|
20
|
+
function VFile(options) {
|
|
21
|
+
var prop;
|
|
22
|
+
var index;
|
|
23
|
+
var length;
|
|
24
|
+
|
|
25
|
+
if (typeof options === 'number') {
|
|
26
|
+
options = options.toString();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!options) {
|
|
30
|
+
options = {};
|
|
31
|
+
} else if (typeof options === 'string' || buffer(options)) {
|
|
32
|
+
options = {
|
|
33
|
+
contents: options
|
|
34
|
+
};
|
|
35
|
+
} else if ('message' in options && 'messages' in options) {
|
|
36
|
+
return options;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!(this instanceof VFile)) {
|
|
40
|
+
return new VFile(options);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.data = {};
|
|
44
|
+
this.messages = [];
|
|
45
|
+
this.history = [];
|
|
46
|
+
this.cwd = process.cwd();
|
|
47
|
+
/* Set path related properties in the correct order. */
|
|
48
|
+
|
|
49
|
+
index = -1;
|
|
50
|
+
length = order.length;
|
|
51
|
+
|
|
52
|
+
while (++index < length) {
|
|
53
|
+
prop = order[index];
|
|
54
|
+
|
|
55
|
+
if (own.call(options, prop)) {
|
|
56
|
+
this[prop] = options[prop];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/* Set non-path related properties. */
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
for (prop in options) {
|
|
63
|
+
if (order.indexOf(prop) === -1) {
|
|
64
|
+
this[prop] = options[prop];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/* Access full path (`~/index.min.js`). */
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Object.defineProperty(proto, 'path', {
|
|
72
|
+
get: function get() {
|
|
73
|
+
return this.history[this.history.length - 1];
|
|
74
|
+
},
|
|
75
|
+
set: function set(path) {
|
|
76
|
+
assertNonEmpty(path, 'path');
|
|
77
|
+
|
|
78
|
+
if (path !== this.path) {
|
|
79
|
+
this.history.push(path);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
/* Access parent path (`~`). */
|
|
84
|
+
|
|
85
|
+
Object.defineProperty(proto, 'dirname', {
|
|
86
|
+
get: function get() {
|
|
87
|
+
return typeof this.path === 'string' ? path.dirname(this.path) : undefined;
|
|
88
|
+
},
|
|
89
|
+
set: function set(dirname) {
|
|
90
|
+
assertPath(this.path, 'dirname');
|
|
91
|
+
this.path = path.join(dirname || '', this.basename);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
/* Access basename (`index.min.js`). */
|
|
95
|
+
|
|
96
|
+
Object.defineProperty(proto, 'basename', {
|
|
97
|
+
get: function get() {
|
|
98
|
+
return typeof this.path === 'string' ? path.basename(this.path) : undefined;
|
|
99
|
+
},
|
|
100
|
+
set: function set(basename) {
|
|
101
|
+
assertNonEmpty(basename, 'basename');
|
|
102
|
+
assertPart(basename, 'basename');
|
|
103
|
+
this.path = path.join(this.dirname || '', basename);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
/* Access extname (`.js`). */
|
|
107
|
+
|
|
108
|
+
Object.defineProperty(proto, 'extname', {
|
|
109
|
+
get: function get() {
|
|
110
|
+
return typeof this.path === 'string' ? path.extname(this.path) : undefined;
|
|
111
|
+
},
|
|
112
|
+
set: function set(extname) {
|
|
113
|
+
var ext = extname || '';
|
|
114
|
+
assertPart(ext, 'extname');
|
|
115
|
+
assertPath(this.path, 'extname');
|
|
116
|
+
|
|
117
|
+
if (ext) {
|
|
118
|
+
if (ext.charAt(0) !== '.') {
|
|
119
|
+
throw new Error('`extname` must start with `.`');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (ext.indexOf('.', 1) !== -1) {
|
|
123
|
+
throw new Error('`extname` cannot contain multiple dots');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.path = replace(this.path, ext);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
/* Access stem (`index.min`). */
|
|
131
|
+
|
|
132
|
+
Object.defineProperty(proto, 'stem', {
|
|
133
|
+
get: function get() {
|
|
134
|
+
return typeof this.path === 'string' ? path.basename(this.path, this.extname) : undefined;
|
|
135
|
+
},
|
|
136
|
+
set: function set(stem) {
|
|
137
|
+
assertNonEmpty(stem, 'stem');
|
|
138
|
+
assertPart(stem, 'stem');
|
|
139
|
+
this.path = path.join(this.dirname || '', stem + (this.extname || ''));
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
/* Get the value of the file. */
|
|
143
|
+
|
|
144
|
+
function toString(encoding) {
|
|
145
|
+
var value = this.contents || '';
|
|
146
|
+
return buffer(value) ? value.toString(encoding) : String(value);
|
|
147
|
+
}
|
|
148
|
+
/* Assert that `part` is not a path (i.e., does
|
|
149
|
+
* not contain `path.sep`). */
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
function assertPart(part, name) {
|
|
153
|
+
if (part.indexOf(path.sep) !== -1) {
|
|
154
|
+
throw new Error('`' + name + '` cannot be a path: did not expect `' + path.sep + '`');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/* Assert that `part` is not empty. */
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
function assertNonEmpty(part, name) {
|
|
161
|
+
if (!part) {
|
|
162
|
+
throw new Error('`' + name + '` cannot be empty');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/* Assert `path` exists. */
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
function assertPath(path, name) {
|
|
169
|
+
if (!path) {
|
|
170
|
+
throw new Error('Setting `' + name + '` requires `path` to be set too');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var VMessage = require('vfile-message');
|
|
4
|
+
|
|
5
|
+
var VFile = require('./core.js');
|
|
6
|
+
|
|
7
|
+
module.exports = VFile;
|
|
8
|
+
var proto = VFile.prototype;
|
|
9
|
+
proto.message = message;
|
|
10
|
+
proto.info = info;
|
|
11
|
+
proto.fail = fail;
|
|
12
|
+
/* Slight backwards compatibility. Remove in the future. */
|
|
13
|
+
|
|
14
|
+
proto.warn = message;
|
|
15
|
+
/* Create a message with `reason` at `position`.
|
|
16
|
+
* When an error is passed in as `reason`, copies the stack. */
|
|
17
|
+
|
|
18
|
+
function message(reason, position, origin) {
|
|
19
|
+
var filePath = this.path;
|
|
20
|
+
var message = new VMessage(reason, position, origin);
|
|
21
|
+
|
|
22
|
+
if (filePath) {
|
|
23
|
+
message.name = filePath + ':' + message.name;
|
|
24
|
+
message.file = filePath;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
message.fatal = false;
|
|
28
|
+
this.messages.push(message);
|
|
29
|
+
return message;
|
|
30
|
+
}
|
|
31
|
+
/* Fail. Creates a vmessage, associates it with the file,
|
|
32
|
+
* and throws it. */
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
function fail() {
|
|
36
|
+
var message = this.message.apply(this, arguments);
|
|
37
|
+
message.fatal = true;
|
|
38
|
+
throw message;
|
|
39
|
+
}
|
|
40
|
+
/* Info. Creates a vmessage, associates it with the file,
|
|
41
|
+
* and marks the fatality as null. */
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
function info() {
|
|
45
|
+
var message = this.message.apply(this, arguments);
|
|
46
|
+
message.fatal = null;
|
|
47
|
+
return message;
|
|
48
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
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 { Link } from '@reach/router';
|
|
7
|
+
import { withTranslation } from 'react-i18next';
|
|
8
|
+
import { Button } from 'reactstrap';
|
|
9
|
+
|
|
10
|
+
var SFChooser = /*#__PURE__*/function (_React$Component) {
|
|
11
|
+
_inherits(SFChooser, _React$Component);
|
|
12
|
+
|
|
13
|
+
var _super = _createSuper(SFChooser);
|
|
14
|
+
|
|
15
|
+
function SFChooser() {
|
|
16
|
+
_classCallCheck(this, SFChooser);
|
|
17
|
+
|
|
18
|
+
return _super.apply(this, arguments);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
_createClass(SFChooser, [{
|
|
22
|
+
key: "render",
|
|
23
|
+
value: function render() {
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: "col-xs-12 col-sm-12 col-md-12 col-lg-12"
|
|
26
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, "Please select the editor")), /*#__PURE__*/React.createElement(Link, {
|
|
27
|
+
to: "/simple-editor"
|
|
28
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
29
|
+
className: "btn btn-default"
|
|
30
|
+
}, "Simple Editor")), /*#__PURE__*/React.createElement(Link, {
|
|
31
|
+
to: "/markdownviewer"
|
|
32
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
33
|
+
className: 'btn btn-default'
|
|
34
|
+
}, "Markdwon Viewer")), /*#__PURE__*/React.createElement(Link, {
|
|
35
|
+
to: "/seafile-markdown-editor"
|
|
36
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
37
|
+
className: "btn btn-default"
|
|
38
|
+
}, "Markdwon Editor")));
|
|
39
|
+
}
|
|
40
|
+
}]);
|
|
41
|
+
|
|
42
|
+
return SFChooser;
|
|
43
|
+
}(React.Component);
|
|
44
|
+
|
|
45
|
+
export default withTranslation('seafile-editor')(SFChooser);
|
|
@@ -0,0 +1,301 @@
|
|
|
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!
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { SeafileEditor } from './editor/editor';
|
|
9
|
+
import { withTranslation } from 'react-i18next';
|
|
10
|
+
import { serverConfig } from './config';
|
|
11
|
+
import { serialize } from './utils/slate2markdown';
|
|
12
|
+
import Loading from './components/loading';
|
|
13
|
+
import editorApi from './editor-api';
|
|
14
|
+
var repoID = serverConfig.repoID,
|
|
15
|
+
userInfo = serverConfig.userInfo,
|
|
16
|
+
filePath = serverConfig.filePath,
|
|
17
|
+
fileName = serverConfig.fileName,
|
|
18
|
+
seafileCollabServer = serverConfig.seafileCollabServer;
|
|
19
|
+
|
|
20
|
+
var SFRichMdEditor = /*#__PURE__*/function (_React$Component) {
|
|
21
|
+
_inherits(SFRichMdEditor, _React$Component);
|
|
22
|
+
|
|
23
|
+
var _super = _createSuper(SFRichMdEditor);
|
|
24
|
+
|
|
25
|
+
function SFRichMdEditor(props) {
|
|
26
|
+
var _this;
|
|
27
|
+
|
|
28
|
+
_classCallCheck(this, SFRichMdEditor);
|
|
29
|
+
|
|
30
|
+
_this = _super.call(this, props);
|
|
31
|
+
_this.state = {
|
|
32
|
+
markdownContent: '',
|
|
33
|
+
loading: true,
|
|
34
|
+
mode: 'editor',
|
|
35
|
+
editorMode: 'rich',
|
|
36
|
+
fileInfo: {
|
|
37
|
+
repoID: repoID,
|
|
38
|
+
name: fileName,
|
|
39
|
+
path: filePath,
|
|
40
|
+
mtime: null,
|
|
41
|
+
size: 0,
|
|
42
|
+
starred: false,
|
|
43
|
+
permission: '',
|
|
44
|
+
lastModifier: '',
|
|
45
|
+
id: ''
|
|
46
|
+
},
|
|
47
|
+
showDraftSaved: false,
|
|
48
|
+
localDraftDialog: false,
|
|
49
|
+
collabServer: seafileCollabServer ? seafileCollabServer : null,
|
|
50
|
+
collabUsers: userInfo ? [{
|
|
51
|
+
user: userInfo,
|
|
52
|
+
is_editing: false
|
|
53
|
+
}] : [],
|
|
54
|
+
contentChanged: false,
|
|
55
|
+
saving: false,
|
|
56
|
+
relatedFiles: [],
|
|
57
|
+
fileTagList: []
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
_this.setFileInfoMtime = function (fileInfo) {
|
|
61
|
+
_this.setState({
|
|
62
|
+
fileInfo: Object.assign({}, _this.state.fileInfo, {
|
|
63
|
+
mtime: fileInfo.mtime,
|
|
64
|
+
id: fileInfo.id,
|
|
65
|
+
lastModifier: fileInfo.last_modifier_name
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
_this.toggleStar = function () {
|
|
71
|
+
var starrd = _this.state.fileInfo.starred;
|
|
72
|
+
|
|
73
|
+
if (starrd) {
|
|
74
|
+
editorApi.unStarItem().then(function (response) {
|
|
75
|
+
_this.setState({
|
|
76
|
+
fileInfo: Object.assign({}, _this.state.fileInfo, {
|
|
77
|
+
starred: !starrd
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
} else if (!starrd) {
|
|
82
|
+
editorApi.starItem().then(function (response) {
|
|
83
|
+
_this.setState({
|
|
84
|
+
fileInfo: Object.assign({}, _this.state.fileInfo, {
|
|
85
|
+
starred: !starrd
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
_this.setEditorMode = function (type) {
|
|
93
|
+
_this.setState({
|
|
94
|
+
editorMode: type
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
_this.setContent = function (str) {
|
|
99
|
+
_this.setState({
|
|
100
|
+
markdownContent: str
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
_this.setDraftValue = function (type, value) {
|
|
105
|
+
if (type === 'rich') {
|
|
106
|
+
_this.draftRichValue = value;
|
|
107
|
+
} else {
|
|
108
|
+
_this.draftPlainValue = value;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
_this.checkDraft = function () {
|
|
113
|
+
var draftKey = editorApi.getDraftKey();
|
|
114
|
+
var draft = localStorage.getItem(draftKey);
|
|
115
|
+
|
|
116
|
+
var that = _assertThisInitialized(_this);
|
|
117
|
+
|
|
118
|
+
if (draft) {
|
|
119
|
+
that.setState({
|
|
120
|
+
localDraftDialog: true
|
|
121
|
+
});
|
|
122
|
+
that.localDraft = draft;
|
|
123
|
+
localStorage.removeItem(draftKey);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
_this.useDraft = function () {
|
|
128
|
+
_this.setState({
|
|
129
|
+
localDraftDialog: false,
|
|
130
|
+
loading: false,
|
|
131
|
+
markdownContent: _this.localDraft,
|
|
132
|
+
editorMode: 'rich'
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
_this.emitSwitchEditor(true);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
_this.deleteDraft = function () {
|
|
139
|
+
if (_this.state.localDraftDialog) {
|
|
140
|
+
_this.setState({
|
|
141
|
+
localDraftDialog: false,
|
|
142
|
+
loading: false
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
var draftKey = editorApi.getDraftKey();
|
|
146
|
+
localStorage.removeItem(draftKey);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
_this.clearTimer = function () {
|
|
151
|
+
clearTimeout(_this.timer);
|
|
152
|
+
_this.timer = null;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
_this.autoSaveDraft = function () {
|
|
156
|
+
var that = _assertThisInitialized(_this);
|
|
157
|
+
|
|
158
|
+
if (that.timer) {
|
|
159
|
+
return;
|
|
160
|
+
} else {
|
|
161
|
+
that.timer = setTimeout(function () {
|
|
162
|
+
var str = '';
|
|
163
|
+
|
|
164
|
+
if (_this.state.editorMode === 'rich') {
|
|
165
|
+
var value = _this.draftRichValue;
|
|
166
|
+
str = serialize(value);
|
|
167
|
+
} else if (_this.state.editorMode === 'plain') {
|
|
168
|
+
str = _this.draftPlainValue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
var draftKey = editorApi.getDraftKey();
|
|
172
|
+
localStorage.setItem(draftKey, str);
|
|
173
|
+
that.setState({
|
|
174
|
+
showDraftSaved: true
|
|
175
|
+
});
|
|
176
|
+
setTimeout(function () {
|
|
177
|
+
that.setState({
|
|
178
|
+
showDraftSaved: false
|
|
179
|
+
});
|
|
180
|
+
}, 3000);
|
|
181
|
+
that.timer = null;
|
|
182
|
+
}, 60000);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
_this.onContentChanged = function (value) {
|
|
187
|
+
_this.setState({
|
|
188
|
+
contentChanged: value
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
_this.onSaving = function (value) {
|
|
193
|
+
_this.setState({
|
|
194
|
+
saving: value
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
_this.listRelatedFiles = function () {
|
|
199
|
+
editorApi.listRelatedFiles().then(function (res) {
|
|
200
|
+
_this.setState({
|
|
201
|
+
relatedFiles: res.data.related_files
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
_this.listFileTags = function () {
|
|
207
|
+
editorApi.listFileTags(repoID, filePath).then(function (res) {
|
|
208
|
+
var fileTagList = res.data.file_tags;
|
|
209
|
+
|
|
210
|
+
for (var i = 0; i < fileTagList.length; i++) {
|
|
211
|
+
fileTagList[i].id = fileTagList[i].file_tag_id;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
_this.setState({
|
|
215
|
+
fileTagList: fileTagList
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
_this.timer = null;
|
|
221
|
+
_this.localDraft = '';
|
|
222
|
+
_this.autoSave = false;
|
|
223
|
+
_this.draftRichValue = '';
|
|
224
|
+
_this.draftPlainValue = '';
|
|
225
|
+
return _this;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
_createClass(SFRichMdEditor, [{
|
|
229
|
+
key: "componentDidMount",
|
|
230
|
+
value: function componentDidMount() {
|
|
231
|
+
var _this2 = this;
|
|
232
|
+
|
|
233
|
+
editorApi.login().then(function (response) {
|
|
234
|
+
editorApi.getFileInfo().then(function (response) {
|
|
235
|
+
_this2.setState({
|
|
236
|
+
fileInfo: Object.assign({}, _this2.state.fileInfo, {
|
|
237
|
+
mtime: response.data.mtime,
|
|
238
|
+
size: response.data.size,
|
|
239
|
+
starred: response.data.starred,
|
|
240
|
+
lastModifier: response.data.last_modifier_name,
|
|
241
|
+
permission: response.data.permission,
|
|
242
|
+
id: response.data.id
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
editorApi.getFileDownloadLink(repoID, filePath).then(function (res) {
|
|
247
|
+
var downLoadUrl = res.data;
|
|
248
|
+
editorApi.getFileContent(downLoadUrl).then(function (res) {
|
|
249
|
+
_this2.setState({
|
|
250
|
+
markdownContent: res.data,
|
|
251
|
+
loading: false
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
_this2.listRelatedFiles();
|
|
256
|
+
|
|
257
|
+
_this2.listFileTags();
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}, {
|
|
263
|
+
key: "render",
|
|
264
|
+
value: function render() {
|
|
265
|
+
if (this.state.loading) {
|
|
266
|
+
return /*#__PURE__*/React.createElement(Loading, null);
|
|
267
|
+
} else if (this.state.mode === 'editor') {
|
|
268
|
+
return /*#__PURE__*/React.createElement(SeafileEditor, {
|
|
269
|
+
scriptSource: 'media/scripts/mathjax/tex-svg.js',
|
|
270
|
+
fileInfo: this.state.fileInfo,
|
|
271
|
+
markdownContent: this.state.markdownContent,
|
|
272
|
+
editorApi: editorApi,
|
|
273
|
+
collabUsers: this.state.collabUsers,
|
|
274
|
+
setFileInfoMtime: this.setFileInfoMtime,
|
|
275
|
+
toggleStar: this.toggleStar,
|
|
276
|
+
showFileHistory: true,
|
|
277
|
+
setEditorMode: this.setEditorMode,
|
|
278
|
+
setContent: this.setContent,
|
|
279
|
+
editorMode: this.state.editorMode,
|
|
280
|
+
showDraftSaved: this.state.showDraftSaved,
|
|
281
|
+
deleteDraft: this.deleteDraft,
|
|
282
|
+
autoSaveDraft: this.autoSaveDraft,
|
|
283
|
+
setDraftValue: this.setDraftValue,
|
|
284
|
+
clearTimer: this.clearTimer,
|
|
285
|
+
mode: this.state.mode,
|
|
286
|
+
onContentChanged: this.onContentChanged,
|
|
287
|
+
contentChanged: this.state.contentChanged,
|
|
288
|
+
onSaving: this.onSaving,
|
|
289
|
+
markdownLint: true,
|
|
290
|
+
saving: this.state.saving,
|
|
291
|
+
relatedFiles: this.state.relatedFiles,
|
|
292
|
+
fileTagList: this.state.fileTagList
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}]);
|
|
297
|
+
|
|
298
|
+
return SFRichMdEditor;
|
|
299
|
+
}(React.Component);
|
|
300
|
+
|
|
301
|
+
export default withTranslation('seafile-editor')(SFRichMdEditor);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
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 { serverConfig } from './config';
|
|
7
|
+
import editorApi from './editor-api';
|
|
8
|
+
import MarkdownViewer from './viewer/markdown-viewer';
|
|
9
|
+
var repoID = serverConfig.repoID,
|
|
10
|
+
filePath = serverConfig.filePath;
|
|
11
|
+
|
|
12
|
+
var SFMarkdownViwer = /*#__PURE__*/function (_React$Component) {
|
|
13
|
+
_inherits(SFMarkdownViwer, _React$Component);
|
|
14
|
+
|
|
15
|
+
var _super = _createSuper(SFMarkdownViwer);
|
|
16
|
+
|
|
17
|
+
function SFMarkdownViwer() {
|
|
18
|
+
var _this;
|
|
19
|
+
|
|
20
|
+
_classCallCheck(this, SFMarkdownViwer);
|
|
21
|
+
|
|
22
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
|
+
args[_key] = arguments[_key];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
27
|
+
_this.state = {
|
|
28
|
+
value: ''
|
|
29
|
+
};
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_createClass(SFMarkdownViwer, [{
|
|
34
|
+
key: "componentDidMount",
|
|
35
|
+
value: function componentDidMount() {
|
|
36
|
+
var _this2 = this;
|
|
37
|
+
|
|
38
|
+
editorApi.login().then(function (response) {
|
|
39
|
+
editorApi.getFileInfo().then(function (response) {
|
|
40
|
+
_this2.setState({
|
|
41
|
+
fileInfo: Object.assign({}, _this2.state.fileInfo, {
|
|
42
|
+
mtime: response.data.mtime,
|
|
43
|
+
size: response.data.size,
|
|
44
|
+
starred: response.data.starred,
|
|
45
|
+
lastModifier: response.data.last_modifier_name,
|
|
46
|
+
permission: response.data.permission,
|
|
47
|
+
id: response.data.id
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
editorApi.getFileDownloadLink(repoID, filePath).then(function (res) {
|
|
52
|
+
var downLoadUrl = res.data;
|
|
53
|
+
editorApi.getFileContent(downLoadUrl).then(function (res) {
|
|
54
|
+
var markdownContent = res.data;
|
|
55
|
+
|
|
56
|
+
_this2.setState({
|
|
57
|
+
value: markdownContent,
|
|
58
|
+
loading: false
|
|
59
|
+
});
|
|
60
|
+
}); // this.listRelatedFiles();
|
|
61
|
+
// this.listFileTags();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "render",
|
|
68
|
+
value: function render() {
|
|
69
|
+
return /*#__PURE__*/React.createElement(MarkdownViewer, {
|
|
70
|
+
markdownContent: this.state.value,
|
|
71
|
+
scriptSource: 'media/scripts/mathjax/tex-svg.js'
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}]);
|
|
75
|
+
|
|
76
|
+
return SFMarkdownViwer;
|
|
77
|
+
}(React.Component);
|
|
78
|
+
|
|
79
|
+
export default SFMarkdownViwer;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
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 { SimpleEditor } from './editor/editor';
|
|
8
|
+
import editorApi from './editor-api';
|
|
9
|
+
|
|
10
|
+
var SFSimpleMdEditor = /*#__PURE__*/function (_React$Component) {
|
|
11
|
+
_inherits(SFSimpleMdEditor, _React$Component);
|
|
12
|
+
|
|
13
|
+
var _super = _createSuper(SFSimpleMdEditor);
|
|
14
|
+
|
|
15
|
+
function SFSimpleMdEditor() {
|
|
16
|
+
var _this;
|
|
17
|
+
|
|
18
|
+
_classCallCheck(this, SFSimpleMdEditor);
|
|
19
|
+
|
|
20
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21
|
+
args[_key] = arguments[_key];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
25
|
+
_this.state = {
|
|
26
|
+
value: 'a'
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
_this.onRef = function (editor) {
|
|
30
|
+
_this.editor = editor;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return _this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
_createClass(SFSimpleMdEditor, [{
|
|
37
|
+
key: "componentDidMount",
|
|
38
|
+
value: function componentDidMount() {
|
|
39
|
+
editorApi.login();
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "render",
|
|
43
|
+
value: function render() {
|
|
44
|
+
return /*#__PURE__*/React.createElement(SimpleEditor, {
|
|
45
|
+
onRef: this.onRef,
|
|
46
|
+
editorApi: editorApi,
|
|
47
|
+
value: this.state.value,
|
|
48
|
+
focusEnd: true
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}]);
|
|
52
|
+
|
|
53
|
+
return SFSimpleMdEditor;
|
|
54
|
+
}(React.Component);
|
|
55
|
+
|
|
56
|
+
export default withTranslation('seafile-editor')(SFSimpleMdEditor);
|