@seafile/seafile-editor 0.3.97 → 0.3.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_i18n/index.js +20 -0
- 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/{index.css → assets/css/index.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 +19 -33
- 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/rich-editor.css +104 -0
- package/dist/assets/editor/simple-editor.css +77 -0
- package/dist/{css/richeditor → assets/rich-editor}/document-info.css +0 -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 +97 -0
- package/dist/components/outline/outline-item.js +70 -0
- package/dist/components/shortcut-dialog.js +26 -51
- 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/rich-markdown-editor.js +70 -149
- package/dist/editor/simple-editor.js +44 -78
- package/dist/{css/richeditor → example/assets/css}/comments-list.css +0 -45
- package/dist/{css/richeditor → example/assets/css}/detail-list-view.css +0 -0
- package/dist/{css/richeditor → example/assets/css}/participants-list.css +0 -0
- package/dist/{css → example/assets/css}/react-mentions-default-style.js +0 -0
- package/dist/example/assets/css/seafile-editor-main.css +125 -0
- package/dist/example/assets/css/seafile-editor-side.css +89 -0
- package/dist/example/assets/css/side-panel.css +81 -0
- package/dist/{components → example/components}/comment-panel.js +12 -6
- package/dist/{components → example/components}/detail-list-view.js +1 -1
- package/dist/{components → example/components}/participants-list.js +1 -1
- package/dist/{components → example/components}/side-panel.js +5 -7
- package/dist/example/seafile-editor.js +137 -0
- package/dist/index.js +9 -0
- package/dist/index.local.js +58 -0
- package/dist/pages/seafile-editor/index.js +38 -0
- package/dist/{editor → pages/seafile-editor}/seafile-editor.js +19 -35
- package/dist/{seafile-editor-chooser.js → pages/seafile-editor-chooser.js} +0 -0
- package/dist/{seafile-markdown-editor.js → pages/seafile-markdown-editor.js} +5 -5
- package/dist/{seafile-markdown-viewer.js → pages/seafile-markdown-viewer.js} +3 -3
- package/dist/{seafile-simple-editor.js → pages/seafile-simple-editor.js} +5 -2
- package/dist/viewer/diff-viewer.js +1 -1
- package/dist/viewer/markdown-viewer.js +14 -15
- package/dist/viewer/slate-viewer.js +9 -24
- package/dist/viewer/viewer-formula.js +1 -1
- package/package.json +6 -14
- package/public/locales/zh-CN/seafile-editor.json +15 -13
- 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/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/config-0.js +0 -15
- package/dist/css/layout.css +0 -111
- package/dist/css/markdown-viewer-slate/file-tags-list.css +0 -76
- package/dist/css/richeditor/rich-editor-main.css +0 -32
- package/dist/css/richeditor/side-panel.css +0 -183
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import
|
|
5
|
+
import React, { Fragment } from 'react';
|
|
6
|
+
import Toolbar from '../components/toolbar';
|
|
8
7
|
import { withTranslation } from 'react-i18next';
|
|
9
|
-
import { renderNode, renderLeaf,
|
|
10
|
-
import {
|
|
11
|
-
import { withHistory } from 'slate-history';
|
|
8
|
+
import { renderNode, renderLeaf, decorationNode } from './editor-utils/common-editor-utils';
|
|
9
|
+
import { Node, Editor, Range } from 'slate';
|
|
12
10
|
import { serialize } from '../utils/slate2markdown/index';
|
|
13
|
-
import { Editable,
|
|
11
|
+
import { Editable, Slate, ReactEditor } from '@seafile/slate-react';
|
|
14
12
|
import { isRangeCollapsed } from './editor-utils/range-utils';
|
|
15
13
|
import ModalPortal from '../components/modal-portal';
|
|
16
14
|
import TextLinkHoverMenu from './editor-component/textlink-hovermenu';
|
|
17
15
|
import ContextMenu from '../components/context-menu';
|
|
18
|
-
import
|
|
19
|
-
import withInline from './controller/inline-element-controller';
|
|
20
|
-
import withVoid from './controller/void-element-controller';
|
|
21
|
-
import withMarkdownShortcut from './controller/shortcut-controller';
|
|
22
|
-
import normalizeNode from './controller/normalize-controller';
|
|
23
|
-
import Plugin from './editor-plugin';
|
|
24
|
-
import TableUtils from '../editor/editor-utils/block-element-utils/table-utils';
|
|
25
|
-
import UserHelpDialog from '../components/user-help';
|
|
16
|
+
import UserHelp from '../components/user-help';
|
|
26
17
|
import CommentDialog from '../components/comment-dialog';
|
|
27
|
-
import SidePanel from '../components/side-panel';
|
|
18
|
+
import SidePanel from '../example/components/side-panel';
|
|
28
19
|
import toaster from '../components/toast';
|
|
29
|
-
import '
|
|
30
|
-
import '../
|
|
31
|
-
import '../css/
|
|
32
|
-
import '../css/
|
|
33
|
-
import '../css/
|
|
34
|
-
import '../css/
|
|
35
|
-
import '../css/
|
|
36
|
-
import '../css/richeditor/tree-view.css';
|
|
20
|
+
import EditorBuilder from './editor-builder';
|
|
21
|
+
import '../assets/editor/rich-editor.css';
|
|
22
|
+
import '../assets/css/navbar-imgbutton.css';
|
|
23
|
+
import '../assets/css/textlink-hovermenu.css';
|
|
24
|
+
import '../assets/css/image.css';
|
|
25
|
+
import '../assets/css/link.css';
|
|
26
|
+
import '../assets/css/tree-view.css';
|
|
37
27
|
|
|
38
28
|
var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
39
29
|
_inherits(SimpleEditor, _React$Component);
|
|
@@ -123,13 +113,13 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
123
113
|
_this.showHelpDialog = function () {
|
|
124
114
|
_this.setState({
|
|
125
115
|
isShowSidePanel: false,
|
|
126
|
-
|
|
116
|
+
isShowHelpPanel: true
|
|
127
117
|
});
|
|
128
118
|
};
|
|
129
119
|
|
|
130
120
|
_this.hideHelpDialog = function () {
|
|
131
121
|
_this.setState({
|
|
132
|
-
|
|
122
|
+
isShowHelpPanel: false
|
|
133
123
|
});
|
|
134
124
|
};
|
|
135
125
|
|
|
@@ -155,13 +145,13 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
155
145
|
}
|
|
156
146
|
|
|
157
147
|
_this.setState({
|
|
158
|
-
|
|
148
|
+
isShowHelpPanel: false
|
|
159
149
|
});
|
|
160
150
|
};
|
|
161
151
|
|
|
162
152
|
_this.handleCommentOpen = function () {
|
|
163
153
|
_this.setState({
|
|
164
|
-
|
|
154
|
+
isShowHelpPanel: false
|
|
165
155
|
});
|
|
166
156
|
};
|
|
167
157
|
|
|
@@ -175,7 +165,7 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
175
165
|
|
|
176
166
|
_this.insertRepoFile = function () {
|
|
177
167
|
if (_this.props.readOnly) return;
|
|
178
|
-
_this.editorSelection =
|
|
168
|
+
_this.editorSelection = _this.editor.selection;
|
|
179
169
|
_this.props.openDialogs && _this.props.openDialogs('insert_file');
|
|
180
170
|
};
|
|
181
171
|
|
|
@@ -232,26 +222,12 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
232
222
|
_this.props.onChange(value, _this.editor.operations);
|
|
233
223
|
};
|
|
234
224
|
|
|
235
|
-
_this.
|
|
236
|
-
_this.
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
_this.onToggleLinkDialog = function () {
|
|
240
|
-
_this.setState({
|
|
241
|
-
isShowLinkDialog: !_this.state.isShowLinkDialog
|
|
242
|
-
});
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
_this.onToggleFormulaDialog = function () {
|
|
246
|
-
_this.setState({
|
|
247
|
-
isShowFormulaDialog: !_this.state.isShowFormulaDialog
|
|
248
|
-
});
|
|
249
|
-
};
|
|
225
|
+
_this.onFocusEditor = function () {
|
|
226
|
+
var value = _this.state.value;
|
|
250
227
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
});
|
|
228
|
+
if (value.length === 2 && value[0].type === 'paragraph' && Node.text(value[0].children[0]).length === 0) {
|
|
229
|
+
_this.editorRef.firstChild.focus();
|
|
230
|
+
}
|
|
255
231
|
};
|
|
256
232
|
|
|
257
233
|
_this.getCookie = function (key) {
|
|
@@ -319,30 +295,27 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
319
295
|
});
|
|
320
296
|
};
|
|
321
297
|
|
|
322
|
-
_this.
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
_this.editorUtils = new EditorUtils(_this.editor);
|
|
327
|
-
_this.tableUtils = new TableUtils(_this.editor);
|
|
328
|
-
_this.plugin = new Plugin(_this.editor);
|
|
329
|
-
_this.editorRef = null;
|
|
330
|
-
_this.timmer = null;
|
|
331
|
-
_this.contextMenuPosition = {};
|
|
298
|
+
_this.setEditorRef = function (ref) {
|
|
299
|
+
_this.editorRef = ref;
|
|
300
|
+
};
|
|
301
|
+
|
|
332
302
|
_this.state = {
|
|
333
303
|
value: props.value,
|
|
334
304
|
leftNavMode: 'files',
|
|
335
|
-
|
|
305
|
+
isShowHelpPanel: false,
|
|
336
306
|
isShowSidePanel: false,
|
|
337
|
-
isShowLinkDialog: false,
|
|
338
|
-
isShowImageDialog: false,
|
|
339
|
-
isShowFormulaDialog: false,
|
|
340
307
|
isShowContextMenu: false,
|
|
341
308
|
showCommentBtn: false,
|
|
342
309
|
showCommentDialog: false,
|
|
343
310
|
commentPosition: null,
|
|
344
311
|
relistComment: 0
|
|
345
312
|
};
|
|
313
|
+
_this.editor = EditorBuilder.getEditor(props);
|
|
314
|
+
_this.editorUtils = EditorBuilder.getEditorUtils();
|
|
315
|
+
_this.tableUtils = EditorBuilder.getTableUtils();
|
|
316
|
+
_this.plugin = EditorBuilder.getPlugin();
|
|
317
|
+
_this.timmer = null;
|
|
318
|
+
_this.contextMenuPosition = {};
|
|
346
319
|
return _this;
|
|
347
320
|
}
|
|
348
321
|
|
|
@@ -355,35 +328,7 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
355
328
|
}, {
|
|
356
329
|
key: "componentDidMount",
|
|
357
330
|
value: function componentDidMount() {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
var editingUsers = this.props.collabUsers.filter(function (ele) {
|
|
361
|
-
return ele.is_editing === true && ele.myself === undefined;
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
if (editingUsers.length > 0) {
|
|
365
|
-
toaster.danger('Another user is editing this file!', {
|
|
366
|
-
duration: 3
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
var userAgent = navigator.userAgent.toLowerCase();
|
|
371
|
-
|
|
372
|
-
if (userAgent.indexOf('chrome') === -1) {
|
|
373
|
-
toaster.warning(this.props.t('Editing_files_in_this_browser_can_lead_to_slight_display_problems'), {
|
|
374
|
-
duration: 4
|
|
375
|
-
});
|
|
376
|
-
} // get first text node of the document and focus at the start of the text node
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
var _Array$from$ = _slicedToArray(Array.from(Node.texts(this.editor.children[0]))[0], 2),
|
|
380
|
-
textPath = _Array$from$[1];
|
|
381
|
-
|
|
382
|
-
textPath.unshift(0);
|
|
383
|
-
Editor.select(this.editor, {
|
|
384
|
-
path: textPath,
|
|
385
|
-
offset: 0
|
|
386
|
-
});
|
|
331
|
+
EditorBuilder.resetEditor();
|
|
387
332
|
}
|
|
388
333
|
}, {
|
|
389
334
|
key: "componentWillReceiveProps",
|
|
@@ -401,73 +346,55 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
401
346
|
value: function render() {
|
|
402
347
|
var _this2 = this;
|
|
403
348
|
|
|
404
|
-
var
|
|
405
|
-
value = _this$state.value,
|
|
406
|
-
isShowLinkDialog = _this$state.isShowLinkDialog,
|
|
407
|
-
isShowImageDialog = _this$state.isShowImageDialog,
|
|
408
|
-
isShowFormulaDialog = _this$state.isShowFormulaDialog;
|
|
349
|
+
var value = this.state.value;
|
|
409
350
|
var _this$props = this.props,
|
|
410
351
|
t = _this$props.t,
|
|
411
|
-
mode = _this$props.mode,
|
|
412
352
|
editorApi = _this$props.editorApi;
|
|
413
|
-
var _this$
|
|
414
|
-
|
|
415
|
-
isShowSidePanel = _this$
|
|
416
|
-
var mainPanelClass = "seafile-editor-main-panel flex-fill d-flex align-self-end ".concat(!isShowSidePanel && !
|
|
417
|
-
var editor = this.editor
|
|
418
|
-
foucsEditor = this.foucsEditor;
|
|
353
|
+
var _this$state = this.state,
|
|
354
|
+
isShowHelpPanel = _this$state.isShowHelpPanel,
|
|
355
|
+
isShowSidePanel = _this$state.isShowSidePanel;
|
|
356
|
+
var mainPanelClass = "seafile-editor-main-panel flex-fill d-flex align-self-end ".concat(!isShowSidePanel && !isShowHelpPanel ? 'seafile-editor-all-panel' : '');
|
|
357
|
+
var editor = this.editor;
|
|
419
358
|
var toolbarStatus = this.editorUtils.getToolbarStatus();
|
|
420
|
-
var readOnly = this.props.readOnly;
|
|
421
359
|
var selectionCollapsed = isRangeCollapsed(editor.selection);
|
|
422
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
423
|
-
className: "seafile-editor
|
|
424
|
-
}, /*#__PURE__*/React.createElement(Slate, {
|
|
425
|
-
editor: this.editor,
|
|
426
|
-
value: value,
|
|
427
|
-
onChange: this.onChange
|
|
360
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
361
|
+
className: "seafile-rich-editor seafile-editor"
|
|
428
362
|
}, /*#__PURE__*/React.createElement("div", {
|
|
429
|
-
className: "seafile-
|
|
430
|
-
}, /*#__PURE__*/React.createElement(
|
|
431
|
-
onToggleLinkDialog: this.onToggleLinkDialog,
|
|
432
|
-
onToggleImageDialog: this.onToggleImageDialog,
|
|
433
|
-
onToggleFormulaDialog: this.onToggleFormulaDialog,
|
|
434
|
-
toolbarStatus: toolbarStatus,
|
|
363
|
+
className: "seafile-editor-topbar"
|
|
364
|
+
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
435
365
|
toggleSidePanel: this.toggleSidePanel,
|
|
436
366
|
insertRepoFile: this.insertRepoFile,
|
|
437
|
-
isShowLinkDialog: isShowLinkDialog,
|
|
438
|
-
isShowImageDialog: isShowImageDialog,
|
|
439
367
|
isShowSidePanel: isShowSidePanel,
|
|
440
|
-
hasSidePanel: true
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
368
|
+
hasSidePanel: true
|
|
369
|
+
})), /*#__PURE__*/React.createElement(Slate, {
|
|
370
|
+
editor: this.editor,
|
|
371
|
+
value: value,
|
|
372
|
+
onChange: this.onChange
|
|
373
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
445
374
|
className: "seafile-editor-main d-flex"
|
|
446
375
|
}, /*#__PURE__*/React.createElement("div", {
|
|
447
376
|
className: mainPanelClass
|
|
448
377
|
}, /*#__PURE__*/React.createElement("div", {
|
|
449
|
-
className: "editor-container align-self-start",
|
|
378
|
+
className: "seafile-editor-module editor-container align-self-start",
|
|
450
379
|
ref: "editorContainer"
|
|
451
380
|
}, /*#__PURE__*/React.createElement("div", {
|
|
452
|
-
ref:
|
|
453
|
-
|
|
454
|
-
},
|
|
455
|
-
onClick: value.length === 2 && value[0].type === 'paragraph' && Node.text(value[0].children[0]).length === 0 ? foucsEditor : null,
|
|
381
|
+
ref: this.setEditorRef,
|
|
382
|
+
onClick: this.onFocusEditor,
|
|
456
383
|
className: "editor article"
|
|
457
384
|
}, /*#__PURE__*/React.createElement(Editable, {
|
|
385
|
+
autoFocus: true,
|
|
458
386
|
renderElement: function renderElement(props) {
|
|
459
|
-
return renderNode(props, editor
|
|
387
|
+
return renderNode(props, editor);
|
|
460
388
|
},
|
|
461
389
|
className: 'editor-component',
|
|
462
390
|
renderLeaf: renderLeaf,
|
|
463
391
|
onContextMenu: this.onContextMenu,
|
|
464
392
|
onCopy: function onCopy(event) {
|
|
465
|
-
_this2.plugin.onCopy(event, editor);
|
|
393
|
+
return _this2.plugin.onCopy(event, editor);
|
|
466
394
|
},
|
|
467
395
|
onCut: function onCut(event) {
|
|
468
396
|
return _this2.plugin.onCut(event);
|
|
469
397
|
},
|
|
470
|
-
autoFocus: true,
|
|
471
398
|
onKeyDown: this.plugin.onKeyDown,
|
|
472
399
|
decorate: decorationNode,
|
|
473
400
|
onSelect: this.setBtnPosition
|
|
@@ -475,16 +402,9 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
475
402
|
className: "iconfont icon-plus-square seafile-viewer-comment-btn",
|
|
476
403
|
ref: "commentbtn",
|
|
477
404
|
onMouseDown: this.addComment
|
|
478
|
-
})),
|
|
479
|
-
onToggleLinkDialog: this.onToggleLinkDialog,
|
|
480
|
-
editorUtils: this.editorUtils
|
|
481
|
-
})) : null, this.state.isShowContextMenu && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(ContextMenu, {
|
|
482
|
-
tableUtils: this.tableUtils,
|
|
483
|
-
contextMenuPosition: this.contextMenuPosition
|
|
484
|
-
})))), !isShowHelpDialog && isShowSidePanel && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
405
|
+
})))), !isShowHelpPanel && isShowSidePanel && /*#__PURE__*/React.createElement("div", {
|
|
485
406
|
className: "seafile-editor-side-panel flex-shrink-0 align-self-start"
|
|
486
407
|
}, /*#__PURE__*/React.createElement(SidePanel, {
|
|
487
|
-
editor: this,
|
|
488
408
|
document: value,
|
|
489
409
|
issues: this.props.issues,
|
|
490
410
|
scrollToNode: this.scrollToNode,
|
|
@@ -498,20 +418,21 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
498
418
|
fileInfo: this.props.fileInfo,
|
|
499
419
|
participants: this.props.participants,
|
|
500
420
|
onParticipantsChange: this.props.onParticipantsChange
|
|
501
|
-
}))),
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
t: t,
|
|
421
|
+
}))))), /*#__PURE__*/React.createElement(Fragment, null, toolbarStatus.isLinkActive && selectionCollapsed && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(TextLinkHoverMenu, {
|
|
422
|
+
onToggleLinkDialog: this.onToggleLinkDialog,
|
|
423
|
+
editorUtils: this.editorUtils
|
|
424
|
+
})), this.state.isShowContextMenu && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(ContextMenu, {
|
|
425
|
+
tableUtils: this.tableUtils,
|
|
426
|
+
contextMenuPosition: this.contextMenuPosition
|
|
427
|
+
})), this.state.showCommentDialog && /*#__PURE__*/React.createElement(CommentDialog, {
|
|
509
428
|
quote: this.quote,
|
|
510
|
-
|
|
429
|
+
editorApi: editorApi,
|
|
511
430
|
commentPosition: this.state.commentPosition,
|
|
512
431
|
onCommentAdded: this.onCommentAdded,
|
|
513
432
|
toggleCommentDialog: this.toggleCommentDialog
|
|
514
|
-
})
|
|
433
|
+
}), isShowHelpPanel && /*#__PURE__*/React.createElement(UserHelp, {
|
|
434
|
+
hideHelpDialog: this.hideHelpDialog
|
|
435
|
+
})));
|
|
515
436
|
}
|
|
516
437
|
}]);
|
|
517
438
|
|
|
@@ -3,34 +3,24 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import ToolBar from '../components/toolbar';
|
|
7
6
|
import { withTranslation } from 'react-i18next';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { Node, Editor } from 'slate';
|
|
8
|
+
import { Editable, Slate } from '@seafile/slate-react';
|
|
9
|
+
import Toolbar, { HelpGroup } from '../components/toolbar';
|
|
10
|
+
import { renderNode, renderLeaf, decorationNode } from './editor-utils/common-editor-utils';
|
|
11
11
|
import { deserialize, serialize } from '../utils/slate2markdown/index';
|
|
12
|
-
import { Editable, withReact, Slate } from '@seafile/slate-react';
|
|
13
12
|
import { isRangeCollapsed } from './editor-utils/range-utils';
|
|
14
13
|
import ModalPortal from '../components/modal-portal';
|
|
15
14
|
import TextLinkHoverMenu from './editor-component/textlink-hovermenu';
|
|
16
15
|
import ContextMenu from '../components/context-menu';
|
|
17
|
-
import withBlock from './controller/block-element-controller';
|
|
18
|
-
import withInline from './controller/inline-element-controller';
|
|
19
|
-
import withVoid from './controller/void-element-controller';
|
|
20
|
-
import withMarkdownShortcut from './controller/shortcut-controller';
|
|
21
|
-
import normalizeNode from './controller/normalize-controller';
|
|
22
|
-
import Plugin from './editor-plugin';
|
|
23
|
-
import TableUtils from '../editor/editor-utils/block-element-utils/table-utils';
|
|
24
|
-
import IconButton from '../components/topbar-component/icon-button';
|
|
25
16
|
import KeyboardShortcuts from '../components/shortcut-dialog';
|
|
17
|
+
import EditorBuilder from './editor-builder';
|
|
26
18
|
import './code-highlight-package';
|
|
27
|
-
import '../
|
|
28
|
-
import '../css/
|
|
29
|
-
import '../css/
|
|
30
|
-
import '../css/
|
|
31
|
-
import '../css/
|
|
32
|
-
import '../css/richeditor/link.css';
|
|
33
|
-
import '../css/topbar.css';
|
|
19
|
+
import '../assets/editor/simple-editor.css';
|
|
20
|
+
import '../assets/css/image.css';
|
|
21
|
+
import '../assets/css/link.css';
|
|
22
|
+
import '../assets/css/navbar-imgbutton.css';
|
|
23
|
+
import '../assets/css/textlink-hovermenu.css';
|
|
34
24
|
|
|
35
25
|
var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
36
26
|
_inherits(SimpleEditor, _React$Component);
|
|
@@ -65,8 +55,12 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
65
55
|
if (hasChange) _this.contentChanged = true;
|
|
66
56
|
};
|
|
67
57
|
|
|
68
|
-
_this.
|
|
69
|
-
_this.
|
|
58
|
+
_this.onFocusEditor = function () {
|
|
59
|
+
var value = _this.state.value;
|
|
60
|
+
|
|
61
|
+
if (value.length === 1 && value[0].type === 'paragraph' && Node.text(value[0].children[0]).length === 0) {
|
|
62
|
+
_this.editorRef.firstChild.focus();
|
|
63
|
+
}
|
|
70
64
|
};
|
|
71
65
|
|
|
72
66
|
_this.focusText = function () {
|
|
@@ -90,18 +84,6 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
90
84
|
return _this.contentChanged;
|
|
91
85
|
};
|
|
92
86
|
|
|
93
|
-
_this.onToggleLinkDialog = function () {
|
|
94
|
-
_this.setState({
|
|
95
|
-
isShowLinkDialog: !_this.state.isShowLinkDialog
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
_this.onToggleImageDialog = function () {
|
|
100
|
-
_this.setState({
|
|
101
|
-
isShowImageDialog: !_this.state.isShowImageDialog
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
|
|
105
87
|
_this.onContextMenu = function (event) {
|
|
106
88
|
if (_this.tableUtils.isInTable()) {
|
|
107
89
|
event.preventDefault();
|
|
@@ -122,22 +104,21 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
122
104
|
});
|
|
123
105
|
};
|
|
124
106
|
|
|
125
|
-
_this.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
_this.tableUtils = new TableUtils(_this.editor);
|
|
130
|
-
_this.plugin = new Plugin(_this.editor);
|
|
131
|
-
_this.editorRef = null;
|
|
132
|
-
_this.contextMenuPosition = {};
|
|
107
|
+
_this.setEditorRef = function (ref) {
|
|
108
|
+
_this.editorRef = ref;
|
|
109
|
+
};
|
|
110
|
+
|
|
133
111
|
_this.state = {
|
|
134
112
|
value: deserialize(props.value),
|
|
135
|
-
isShowLinkDialog: false,
|
|
136
|
-
isShowImageDialog: false,
|
|
137
113
|
isShowBigImage: false,
|
|
138
114
|
isShowContextMenu: false,
|
|
139
115
|
isShowShortcutDialog: false
|
|
140
116
|
};
|
|
117
|
+
_this.editor = EditorBuilder.getEditor(props);
|
|
118
|
+
_this.editorUtils = EditorBuilder.getEditorUtils();
|
|
119
|
+
_this.tableUtils = EditorBuilder.getTableUtils();
|
|
120
|
+
_this.plugin = EditorBuilder.getPlugin();
|
|
121
|
+
_this.contextMenuPosition = {};
|
|
141
122
|
return _this;
|
|
142
123
|
}
|
|
143
124
|
|
|
@@ -147,6 +128,11 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
147
128
|
this.props.onRef(this);
|
|
148
129
|
this.focusText();
|
|
149
130
|
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "componentWillUnmount",
|
|
133
|
+
value: function componentWillUnmount() {
|
|
134
|
+
EditorBuilder.resetEditor();
|
|
135
|
+
}
|
|
150
136
|
}, {
|
|
151
137
|
key: "getMarkdown",
|
|
152
138
|
value: function getMarkdown() {
|
|
@@ -163,52 +149,33 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
163
149
|
value: function render() {
|
|
164
150
|
var _this2 = this;
|
|
165
151
|
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
isShowLinkDialog = _this$state.isShowLinkDialog,
|
|
169
|
-
isShowImageDialog = _this$state.isShowImageDialog;
|
|
170
|
-
var editor = this.editor,
|
|
171
|
-
foucsEditor = this.foucsEditor;
|
|
152
|
+
var editor = this.editor;
|
|
153
|
+
var value = this.state.value;
|
|
172
154
|
var toolbarStatus = this.editorUtils.getToolbarStatus();
|
|
173
155
|
var _this$props2 = this.props,
|
|
174
156
|
readOnly = _this$props2.readOnly,
|
|
175
157
|
t = _this$props2.t;
|
|
176
158
|
var selectionCollapsed = isRangeCollapsed(editor.selection);
|
|
177
159
|
return /*#__PURE__*/React.createElement("div", {
|
|
178
|
-
className: "seafile-
|
|
179
|
-
}, /*#__PURE__*/React.createElement(
|
|
160
|
+
className: "seafile-simple-editor"
|
|
161
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
162
|
+
className: "seafile-editor-topbar"
|
|
163
|
+
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
164
|
+
isSimpleEditor: true
|
|
165
|
+
}), /*#__PURE__*/React.createElement(HelpGroup, {
|
|
166
|
+
onHelpToggle: this.toggleShortcutDialog
|
|
167
|
+
})), /*#__PURE__*/React.createElement(Slate, {
|
|
180
168
|
editor: this.editor,
|
|
181
169
|
value: value,
|
|
182
170
|
onChange: this.onChange
|
|
183
171
|
}, /*#__PURE__*/React.createElement("div", {
|
|
184
|
-
className: "seafile-
|
|
185
|
-
}, /*#__PURE__*/React.createElement(ToolBar, {
|
|
186
|
-
onToggleLinkDialog: this.onToggleLinkDialog,
|
|
187
|
-
onToggleImageDialog: this.onToggleImageDialog,
|
|
188
|
-
toolbarStatus: toolbarStatus,
|
|
189
|
-
isSimpleEditor: true,
|
|
190
|
-
isShowLinkDialog: isShowLinkDialog,
|
|
191
|
-
isShowImageDialog: isShowImageDialog
|
|
192
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
193
|
-
className: 'btn-group editor-btn-group'
|
|
194
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
195
|
-
isRichEditor: true,
|
|
196
|
-
text: t('Shortcut_help'),
|
|
197
|
-
id: 'helpIcon',
|
|
198
|
-
className: 'use-help-icon',
|
|
199
|
-
icon: 'iconfont icon-use-help',
|
|
200
|
-
onMouseDown: function onMouseDown(event) {
|
|
201
|
-
return _this2.toggleShortcutDialog();
|
|
202
|
-
}
|
|
203
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
204
|
-
className: "editor-container"
|
|
172
|
+
className: "seafile-editor-module editor-container"
|
|
205
173
|
}, /*#__PURE__*/React.createElement("div", {
|
|
206
|
-
ref:
|
|
207
|
-
|
|
208
|
-
},
|
|
209
|
-
onClick: value.length === 1 && value[0].type === 'paragraph' && Node.text(value[0].children[0]).length === 0 ? foucsEditor : null,
|
|
174
|
+
ref: this.setEditorRef,
|
|
175
|
+
onClick: this.onFocusEditor,
|
|
210
176
|
className: "editor article"
|
|
211
177
|
}, /*#__PURE__*/React.createElement(Editable, {
|
|
178
|
+
autoFocus: true,
|
|
212
179
|
renderElement: function renderElement(props) {
|
|
213
180
|
return renderNode(props, editor, readOnly);
|
|
214
181
|
},
|
|
@@ -221,7 +188,6 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
221
188
|
onCut: function onCut(event) {
|
|
222
189
|
return _this2.plugin.onCut(event);
|
|
223
190
|
},
|
|
224
|
-
autoFocus: true,
|
|
225
191
|
onKeyDown: this.plugin.onKeyDown,
|
|
226
192
|
decorate: decorationNode
|
|
227
193
|
})), toolbarStatus.isLinkActive && selectionCollapsed ? /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(TextLinkHoverMenu, {
|
|
@@ -137,48 +137,3 @@
|
|
|
137
137
|
background-color: #eee;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
.comment-dialog {
|
|
141
|
-
width: 500px;
|
|
142
|
-
position: absolute;
|
|
143
|
-
top: 30%;
|
|
144
|
-
right: 0;
|
|
145
|
-
padding: 15px;
|
|
146
|
-
background-color: #fafafa;
|
|
147
|
-
border: 1px solid rgba(0,0,0,.2);
|
|
148
|
-
border-radius: .3rem;
|
|
149
|
-
box-shadow: 0 0 3px #ccc;
|
|
150
|
-
z-index: 1000;
|
|
151
|
-
}
|
|
152
|
-
.comment-dialog-triangle {
|
|
153
|
-
position: absolute;
|
|
154
|
-
left: -5px;
|
|
155
|
-
top: 50%;
|
|
156
|
-
transform: rotate(45deg);
|
|
157
|
-
border: 1px solid rgba(0,0,0,.2);
|
|
158
|
-
border-top: none;
|
|
159
|
-
border-right: none;
|
|
160
|
-
width: 10px;
|
|
161
|
-
height: 10px;
|
|
162
|
-
background-color: #fafafa;
|
|
163
|
-
box-shadow: -1px 1px #ccc;
|
|
164
|
-
}
|
|
165
|
-
.comment-dialog textarea {
|
|
166
|
-
width: 100%;
|
|
167
|
-
min-height: 100px;
|
|
168
|
-
max-height: 300px;
|
|
169
|
-
padding: 5px;
|
|
170
|
-
background-color: #fff;
|
|
171
|
-
}
|
|
172
|
-
.comment-dialog .button-group .btn {
|
|
173
|
-
margin-right: 10px;
|
|
174
|
-
}
|
|
175
|
-
.comment-dialog .comment-dialog-quote {
|
|
176
|
-
margin-top: 10px;
|
|
177
|
-
max-height: 6rem;
|
|
178
|
-
overflow: auto;
|
|
179
|
-
padding-left: 1rem;
|
|
180
|
-
}
|
|
181
|
-
.comment-dialog .comment-dialog-quote ul,
|
|
182
|
-
.comment-dialog .comment-dialog-quote ol {
|
|
183
|
-
padding-left: 1rem;
|
|
184
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|