@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,261 @@
|
|
|
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: "listRelatedFiles",
|
|
231
|
+
value: function listRelatedFiles() {
|
|
232
|
+
return this.seafileAPI.listRelatedFiles(this.repoID, this.filePath);
|
|
233
|
+
}
|
|
234
|
+
}, {
|
|
235
|
+
key: "markdownLint",
|
|
236
|
+
value: function markdownLint(slateValue) {
|
|
237
|
+
return this.seafileAPI.markdownLint(slateValue);
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
240
|
+
key: "searchUsers",
|
|
241
|
+
value: function searchUsers(searchParam) {
|
|
242
|
+
return this.seafileAPI.searchUsers(searchParam);
|
|
243
|
+
}
|
|
244
|
+
}, {
|
|
245
|
+
key: "listRepoRelatedUsers",
|
|
246
|
+
value: function listRepoRelatedUsers() {
|
|
247
|
+
return this.seafileAPI.listRepoRelatedUsers(this.repoID);
|
|
248
|
+
}
|
|
249
|
+
}]);
|
|
250
|
+
|
|
251
|
+
return EditorApi;
|
|
252
|
+
}();
|
|
253
|
+
|
|
254
|
+
var repoID = serverConfig.repoID,
|
|
255
|
+
fileName = serverConfig.fileName,
|
|
256
|
+
dirPath = serverConfig.dirPath,
|
|
257
|
+
name = serverConfig.name,
|
|
258
|
+
filePath = serverConfig.filePath,
|
|
259
|
+
contact_email = serverConfig.contact_email;
|
|
260
|
+
var editorApi = new EditorApi(repoID, fileName, dirPath, name, filePath, serviceUrl, username, contact_email);
|
|
261
|
+
export default editorApi;
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
4
|
+
import { Element, Node, Range, Text, createEditor as makeEditor } from 'slate';
|
|
5
|
+
import { AnchorToken, FocusToken, Token, addAnchorToken, addFocusToken, getAnchorOffset, getFocusOffset } from './tokens';
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the descedants of a node by normalizing the children that can be
|
|
8
|
+
* passed into a hyperscript creator function.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
var STRINGS = new WeakSet();
|
|
12
|
+
|
|
13
|
+
var resolveDescendants = function resolveDescendants(children) {
|
|
14
|
+
var nodes = [];
|
|
15
|
+
|
|
16
|
+
var addChild = function addChild(child) {
|
|
17
|
+
if (child == null) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var prev = nodes[nodes.length - 1];
|
|
22
|
+
|
|
23
|
+
if (typeof child === 'string') {
|
|
24
|
+
var text = {
|
|
25
|
+
text: child
|
|
26
|
+
};
|
|
27
|
+
STRINGS.add(text);
|
|
28
|
+
child = text;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (Text.isText(child)) {
|
|
32
|
+
var c = child; // HACK: fix typescript complaining
|
|
33
|
+
|
|
34
|
+
if (Text.isText(prev) && STRINGS.has(prev) && STRINGS.has(c) && Text.equals(prev, c, {
|
|
35
|
+
loose: true
|
|
36
|
+
})) {
|
|
37
|
+
prev.text += c.text;
|
|
38
|
+
} else {
|
|
39
|
+
nodes.push(c);
|
|
40
|
+
}
|
|
41
|
+
} else if (Element.isElement(child)) {
|
|
42
|
+
nodes.push(child);
|
|
43
|
+
} else if (child instanceof Token) {
|
|
44
|
+
var n = nodes[nodes.length - 1];
|
|
45
|
+
|
|
46
|
+
if (!Text.isText(n)) {
|
|
47
|
+
addChild('');
|
|
48
|
+
n = nodes[nodes.length - 1];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (child instanceof AnchorToken) {
|
|
52
|
+
addAnchorToken(n, child);
|
|
53
|
+
} else if (child instanceof FocusToken) {
|
|
54
|
+
addFocusToken(n, child);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
throw new Error("Unexpected hyperscript child object: ".concat(child));
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
var _iterator = _createForOfIteratorHelper(children.flat(Infinity)),
|
|
62
|
+
_step;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
66
|
+
var child = _step.value;
|
|
67
|
+
addChild(child);
|
|
68
|
+
}
|
|
69
|
+
} catch (err) {
|
|
70
|
+
_iterator.e(err);
|
|
71
|
+
} finally {
|
|
72
|
+
_iterator.f();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return nodes;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Create an anchor token.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
export function createAnchor(tagName, attributes, children) {
|
|
83
|
+
return new AnchorToken(attributes);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Create an anchor and a focus token.
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
export function createCursor(tagName, attributes, children) {
|
|
90
|
+
return [new AnchorToken(attributes), new FocusToken(attributes)];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create an `Element` object.
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
export function createElement(tagName, attributes, children) {
|
|
97
|
+
return _objectSpread(_objectSpread({}, attributes), {}, {
|
|
98
|
+
children: resolveDescendants(children)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Create a focus token.
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
export function createFocus(tagName, attributes, children) {
|
|
106
|
+
return new FocusToken(attributes);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Create a fragment.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
export function createFragment(tagName, attributes, children) {
|
|
113
|
+
return resolveDescendants(children);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Create a `Selection` object.
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
export function createSelection(tagName, attributes, children) {
|
|
120
|
+
var anchor = children.find(function (c) {
|
|
121
|
+
return c instanceof AnchorToken;
|
|
122
|
+
});
|
|
123
|
+
var focus = children.find(function (c) {
|
|
124
|
+
return c instanceof FocusToken;
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (!anchor || !anchor.offset || !anchor.path) {
|
|
128
|
+
throw new Error('The <selection> hyperscript tag must have an <anchor> tag as a child with \`path\` and \`offset\` attributes defined.');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (!focus || !focus.offset || !focus.path) {
|
|
132
|
+
throw new Error('The <selection> hyperscript tag must have a <focus> tag as a child with \`path\` and \`offset\` attributes defined.');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return _objectSpread({
|
|
136
|
+
anchor: {
|
|
137
|
+
offset: anchor.offset,
|
|
138
|
+
path: anchor.path
|
|
139
|
+
},
|
|
140
|
+
focus: {
|
|
141
|
+
offset: focus.offset,
|
|
142
|
+
path: focus.path
|
|
143
|
+
}
|
|
144
|
+
}, attributes);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Create a `Text` object.
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
export function createText(tagName, attributes, children) {
|
|
151
|
+
var nodes = resolveDescendants(children);
|
|
152
|
+
|
|
153
|
+
if (nodes.length > 1) {
|
|
154
|
+
throw new Error('The <text> hyperscript tag must only contain a single nodes worth of children.');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
var _nodes = _slicedToArray(nodes, 1),
|
|
158
|
+
node = _nodes[0];
|
|
159
|
+
|
|
160
|
+
if (node == null) {
|
|
161
|
+
node = {
|
|
162
|
+
text: ''
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!Text.isText(node)) {
|
|
167
|
+
throw new Error('The <text> hyperscript tag can only contain text content as children.');
|
|
168
|
+
} // COMPAT: If they used the <text> tag we want to guarantee that it won't be
|
|
169
|
+
// merge with other string children.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
STRINGS.delete(node);
|
|
173
|
+
Object.assign(node, attributes);
|
|
174
|
+
return node;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create a top-level `Editor` object.
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
export function createEditor(tagName, attributes, children) {
|
|
181
|
+
var otherChildren = [];
|
|
182
|
+
var selectionChild;
|
|
183
|
+
|
|
184
|
+
var _iterator2 = _createForOfIteratorHelper(children),
|
|
185
|
+
_step2;
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
189
|
+
var child = _step2.value;
|
|
190
|
+
|
|
191
|
+
if (Range.isRange(child)) {
|
|
192
|
+
selectionChild = child;
|
|
193
|
+
} else {
|
|
194
|
+
otherChildren.push(child);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
} catch (err) {
|
|
198
|
+
_iterator2.e(err);
|
|
199
|
+
} finally {
|
|
200
|
+
_iterator2.f();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
var descendants = resolveDescendants(otherChildren);
|
|
204
|
+
var selection = {};
|
|
205
|
+
var editor = makeEditor();
|
|
206
|
+
Object.assign(editor, attributes);
|
|
207
|
+
editor.children = descendants; // Search the document's texts to see if any of them have tokens associated
|
|
208
|
+
// that need incorporated into the selection.
|
|
209
|
+
|
|
210
|
+
var _iterator3 = _createForOfIteratorHelper(Node.texts(editor)),
|
|
211
|
+
_step3;
|
|
212
|
+
|
|
213
|
+
try {
|
|
214
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
215
|
+
var _step3$value = _slicedToArray(_step3.value, 2),
|
|
216
|
+
node = _step3$value[0],
|
|
217
|
+
path = _step3$value[1];
|
|
218
|
+
|
|
219
|
+
var anchor = getAnchorOffset(node);
|
|
220
|
+
var focus = getFocusOffset(node);
|
|
221
|
+
|
|
222
|
+
if (anchor != null) {
|
|
223
|
+
var _anchor = _slicedToArray(anchor, 1),
|
|
224
|
+
offset = _anchor[0];
|
|
225
|
+
|
|
226
|
+
selection.anchor = {
|
|
227
|
+
path: path,
|
|
228
|
+
offset: offset
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (focus != null) {
|
|
233
|
+
var _focus = _slicedToArray(focus, 1),
|
|
234
|
+
_offset = _focus[0];
|
|
235
|
+
|
|
236
|
+
selection.focus = {
|
|
237
|
+
path: path,
|
|
238
|
+
offset: _offset
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
} catch (err) {
|
|
243
|
+
_iterator3.e(err);
|
|
244
|
+
} finally {
|
|
245
|
+
_iterator3.f();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (selection.anchor && !selection.focus) {
|
|
249
|
+
throw new Error('Slate hyperscript ranges must have both \`<anchor />\` and \`<focus />\` defined if one is defined, but you only defined \`<anchor />\`. For collapsed selections, use \`<cursor />\` instead.');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!selection.anchor && selection.focus) {
|
|
253
|
+
throw new Error('Slate hyperscript ranges must have both \`<anchor />\` and \`<focus />\` defined if one is defined, but you only defined \`<focus />\`. For collapsed selections, use \`<cursor />\` instead.');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (selectionChild != null) {
|
|
257
|
+
editor.selection = selectionChild;
|
|
258
|
+
} else if (Range.isRange(selection)) {
|
|
259
|
+
editor.selection = selection;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return editor;
|
|
263
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import isPlainObject from 'is-plain-object';
|
|
3
|
+
import { createAnchor, createCursor, createEditor, createElement, createFocus, createFragment, createSelection, createText } from './creators';
|
|
4
|
+
/**
|
|
5
|
+
* The default creators for Slate objects.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var DEFAULT_CREATORS = {
|
|
9
|
+
anchor: createAnchor,
|
|
10
|
+
cursor: createCursor,
|
|
11
|
+
editor: createEditor,
|
|
12
|
+
element: createElement,
|
|
13
|
+
focus: createFocus,
|
|
14
|
+
fragment: createFragment,
|
|
15
|
+
selection: createSelection,
|
|
16
|
+
text: createText
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
var createHyperscript = function createHyperscript() {
|
|
20
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
21
|
+
var _options$elements = options.elements,
|
|
22
|
+
elements = _options$elements === void 0 ? {} : _options$elements;
|
|
23
|
+
var elementCreators = normalizeElements(elements);
|
|
24
|
+
|
|
25
|
+
var creators = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_CREATORS), elementCreators), options.creators);
|
|
26
|
+
|
|
27
|
+
var jsx = createFactory(creators);
|
|
28
|
+
return jsx;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Create a Slate hyperscript function with `options`.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
var createFactory = function createFactory(creators) {
|
|
36
|
+
var jsx = function jsx(tagName, attributes) {
|
|
37
|
+
for (var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
38
|
+
children[_key - 2] = arguments[_key];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var creator = creators[tagName];
|
|
42
|
+
|
|
43
|
+
if (!creator) {
|
|
44
|
+
throw new Error("No hyperscript creator found for tag: <".concat(tagName, ">"));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (attributes == null) {
|
|
48
|
+
attributes = {};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!isPlainObject(attributes)) {
|
|
52
|
+
children = [attributes].concat(children);
|
|
53
|
+
attributes = {};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
children = children.filter(function (child) {
|
|
57
|
+
return Boolean(child);
|
|
58
|
+
}).flat();
|
|
59
|
+
var ret = creator(tagName, attributes, children);
|
|
60
|
+
return ret;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return jsx;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Normalize a dictionary of element shorthands into creator functions.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
var normalizeElements = function normalizeElements(elements) {
|
|
71
|
+
var creators = {};
|
|
72
|
+
|
|
73
|
+
var _loop = function _loop(tagName) {
|
|
74
|
+
var props = elements[tagName];
|
|
75
|
+
|
|
76
|
+
if (typeof props !== 'object') {
|
|
77
|
+
throw new Error("Properties specified for a hyperscript shorthand should be an object, but for the custom element <".concat(tagName, "> tag you passed: ").concat(props));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
creators[tagName] = function (tagName, attributes, children) {
|
|
81
|
+
return createElement('element', _objectSpread(_objectSpread({}, props), attributes), children);
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
for (var tagName in elements) {
|
|
86
|
+
_loop(tagName);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return creators;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export { createHyperscript };
|