@seafile/sdoc-editor 0.5.41 → 0.5.43
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/basic-sdk/constants/index.js +2 -1
- package/dist/basic-sdk/editor/comment-article.js +9 -10
- package/dist/basic-sdk/editor/editable-article.js +8 -9
- package/dist/basic-sdk/extension/commons/{history-files → file-insert-dialog}/index.js +115 -95
- package/dist/basic-sdk/extension/commons/file-insert-dialog/style.css +76 -0
- package/dist/basic-sdk/extension/commons/insert-element-dialog/index.js +9 -8
- package/dist/basic-sdk/extension/commons/menu-shortcut-indicator/style.css +5 -7
- package/dist/basic-sdk/extension/constants/element-type.js +1 -0
- package/dist/basic-sdk/extension/constants/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.css +9 -0
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +41 -24
- package/dist/basic-sdk/extension/plugins/image/helpers.js +26 -2
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +10 -4
- package/dist/basic-sdk/extension/plugins/sdoc-link/helpers.js +62 -13
- package/dist/basic-sdk/extension/plugins/sdoc-link/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/sdoc-link/plugin.js +33 -23
- package/dist/basic-sdk/extension/plugins/sdoc-link/{render-elem.css → render/render-elem.css} +5 -1
- package/dist/basic-sdk/extension/plugins/sdoc-link/{render-elem.js → render/render-elem.js} +6 -6
- package/dist/basic-sdk/extension/plugins/sdoc-link/render/render-file-link-temp-input.js +26 -0
- package/dist/basic-sdk/extension/render/custom-element.js +6 -1
- package/dist/basic-sdk/extension/toolbar/context-toolbar/index.js +9 -1
- package/dist/basic-sdk/utils/diff.js +24 -0
- package/dist/components/doc-operations/more-operations.js +13 -10
- package/dist/components/doc-operations/revision-operations/changes-count/index.js +16 -15
- package/dist/components/doc-operations/revision-operations/index.js +1 -1
- package/dist/components/doc-operations/style.css +15 -0
- package/dist/pages/published-revision-viewer.js +1 -1
- package/dist/pages/simple-editor.js +1 -1
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +3 -1
- package/public/locales/zh_CN/sdoc-editor.json +3 -1
- package/dist/basic-sdk/extension/commons/history-files/index.css +0 -70
|
@@ -24,7 +24,8 @@ export const INTERNAL_EVENT = {
|
|
|
24
24
|
TABLE_SHOW_DRAG_HANDLER: 'table_show_drag_handler',
|
|
25
25
|
TABLE_HIDE_DRAG_HANDLER: 'table_show_drag_handler',
|
|
26
26
|
ON_PRINT: 'on_print',
|
|
27
|
-
COMMENT_EDITOR_POST_COMMENT: 'comment_editor_post_comment'
|
|
27
|
+
COMMENT_EDITOR_POST_COMMENT: 'comment_editor_post_comment',
|
|
28
|
+
CLOSE_FILE_INSET_DIALOG: 'close_file_insert_dialog'
|
|
28
29
|
};
|
|
29
30
|
export const REVISION_DIFF_KEY = 'diff';
|
|
30
31
|
export const REVISION_DIFF_VALUE = '1';
|
|
@@ -9,7 +9,7 @@ import { useCursors } from '../cursor/use-cursors';
|
|
|
9
9
|
import { INTERNAL_EVENT } from '../constants';
|
|
10
10
|
import { usePipDecorate } from '../decorates';
|
|
11
11
|
import EventBus from '../utils/event-bus';
|
|
12
|
-
import { IMAGE } from '../extension/constants';
|
|
12
|
+
import { IMAGE, IMAGE_BLOCK } from '../extension/constants';
|
|
13
13
|
import RenderCommentEditorCustomRenderElement from '../extension/render/render-comment-editor-element';
|
|
14
14
|
import EventProxy from '../utils/event-handler';
|
|
15
15
|
const CommentArticle = _ref => {
|
|
@@ -40,14 +40,12 @@ const CommentArticle = _ref => {
|
|
|
40
40
|
const {
|
|
41
41
|
selection
|
|
42
42
|
} = editor;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (imageNodeEntry) return;
|
|
50
|
-
}
|
|
43
|
+
// Do not scroll into view, when focus on image
|
|
44
|
+
const [imageNodeEntry] = Editor.nodes(editor, {
|
|
45
|
+
match: n => [IMAGE, IMAGE_BLOCK].includes(n.type),
|
|
46
|
+
at: selection
|
|
47
|
+
});
|
|
48
|
+
if (imageNodeEntry) return;
|
|
51
49
|
const focusedNode = Node.get(editor, selection.focus.path);
|
|
52
50
|
const domNode = ReactEditor.toDOMNode(editor, focusedNode);
|
|
53
51
|
if (!domNode) return;
|
|
@@ -85,7 +83,8 @@ const CommentArticle = _ref => {
|
|
|
85
83
|
onCompositionStart: eventProxy.onCompositionStart,
|
|
86
84
|
onCompositionUpdate: eventProxy.onCompositionUpdate,
|
|
87
85
|
onCompositionEnd: eventProxy.onCompositionEnd,
|
|
88
|
-
onKeyDown: onKeyDown
|
|
86
|
+
onKeyDown: onKeyDown,
|
|
87
|
+
onBeforeInput: eventProxy.onBeforeInput
|
|
89
88
|
}));
|
|
90
89
|
};
|
|
91
90
|
export default CommentArticle;
|
|
@@ -14,7 +14,7 @@ import EventBus from '../utils/event-bus';
|
|
|
14
14
|
import { ArticleContainer } from '../layout';
|
|
15
15
|
import { useScrollContext } from '../hooks/use-scroll-context';
|
|
16
16
|
import { SetNodeToDecorations } from '../highlight';
|
|
17
|
-
import { IMAGE } from '../extension/constants';
|
|
17
|
+
import { IMAGE, IMAGE_BLOCK } from '../extension/constants';
|
|
18
18
|
import { isPreventResetTableSelectedRange } from '../extension/plugins/table/helpers';
|
|
19
19
|
const EditableArticle = _ref => {
|
|
20
20
|
let {
|
|
@@ -144,14 +144,12 @@ const EditableArticle = _ref => {
|
|
|
144
144
|
const {
|
|
145
145
|
selection
|
|
146
146
|
} = editor;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (imageNodeEntry) return;
|
|
154
|
-
}
|
|
147
|
+
// Do not scroll into view, when focus on image
|
|
148
|
+
const [imageNodeEntry] = Editor.nodes(editor, {
|
|
149
|
+
match: n => [IMAGE, IMAGE_BLOCK].includes(n.type),
|
|
150
|
+
at: selection
|
|
151
|
+
});
|
|
152
|
+
if (imageNodeEntry) return;
|
|
155
153
|
const focusedNode = Node.get(editor, selection.focus.path);
|
|
156
154
|
const domNode = ReactEditor.toDOMNode(editor, focusedNode);
|
|
157
155
|
if (!domNode) return;
|
|
@@ -178,6 +176,7 @@ const EditableArticle = _ref => {
|
|
|
178
176
|
decorate: decorate,
|
|
179
177
|
onCut: eventProxy.onCut,
|
|
180
178
|
onCopy: eventProxy.onCopy,
|
|
179
|
+
onCompositionStart: eventProxy.onCompositionStart,
|
|
181
180
|
id: "sdoc-editor"
|
|
182
181
|
})), /*#__PURE__*/React.createElement(SideToolbar, null), isShowComment && /*#__PURE__*/React.createElement(CommentWrapper, {
|
|
183
182
|
editor: editor,
|
|
@@ -1,33 +1,42 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import React, { useCallback, useEffect,
|
|
3
|
-
import { Editor } from '@seafile/slate';
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
3
|
import { ReactEditor } from '@seafile/slate-react';
|
|
5
|
-
import {
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Editor } from '@seafile/slate';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import debounce from 'lodash.debounce';
|
|
8
|
-
import toaster from '../../../../components/toast';
|
|
9
|
-
import EventBus from '../../../utils/event-bus';
|
|
10
7
|
import context from '../../../../context';
|
|
11
|
-
import { focusEditor } from '../../core';
|
|
12
|
-
import { insertSdocFileLink } from '../../plugins/sdoc-link/helpers';
|
|
13
8
|
import { LocalStorage, isEnglish } from '../../../../utils';
|
|
14
|
-
import { INTERNAL_EVENT } from '../../../constants';
|
|
15
9
|
import { EXTERNAL_EVENT } from '../../../../constants';
|
|
10
|
+
import EventBus from '../../../utils/event-bus';
|
|
11
|
+
import { INTERNAL_EVENT } from '../../../constants';
|
|
16
12
|
import { SDOC_LINK } from '../../constants';
|
|
17
|
-
import '
|
|
18
|
-
|
|
13
|
+
import toaster from '../../../../components/toast';
|
|
14
|
+
import { insertSdocFileLink, insertTextWhenRemoveFileNameCollector, removeTempInput } from '../../plugins/sdoc-link/helpers';
|
|
15
|
+
import './style.css';
|
|
16
|
+
const FileLinkInsertDialog = _ref => {
|
|
19
17
|
let {
|
|
20
18
|
editor,
|
|
21
|
-
|
|
22
|
-
closeDialog
|
|
23
|
-
t
|
|
19
|
+
element,
|
|
20
|
+
closeDialog
|
|
24
21
|
} = _ref;
|
|
25
|
-
const
|
|
26
|
-
const
|
|
22
|
+
const eventBus = EventBus.getInstance();
|
|
23
|
+
const historyFileWrapperRef = useRef(document.querySelector('.sdoc-history-files-wrapper'));
|
|
27
24
|
const [files, setFiles] = useState([]);
|
|
28
|
-
const [position, setPosition] = useState({
|
|
29
|
-
|
|
25
|
+
const [position, setPosition] = useState({
|
|
26
|
+
top: 0,
|
|
27
|
+
left: 0
|
|
28
|
+
});
|
|
30
29
|
const [newFileName, setNewFileName] = useState('');
|
|
30
|
+
const {
|
|
31
|
+
t
|
|
32
|
+
} = useTranslation();
|
|
33
|
+
const [header, setHeader] = useState(t('Recent_visited'));
|
|
34
|
+
const deleteInputAndInsertText = useCallback(function () {
|
|
35
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
|
+
args[_key] = arguments[_key];
|
|
37
|
+
}
|
|
38
|
+
return insertTextWhenRemoveFileNameCollector(editor, element, ...args);
|
|
39
|
+
}, [editor, element]);
|
|
31
40
|
const getPosition = useCallback(() => {
|
|
32
41
|
const {
|
|
33
42
|
selection
|
|
@@ -35,80 +44,95 @@ const HistoryFiles = _ref => {
|
|
|
35
44
|
const nodeEntry = Editor.node(editor, selection);
|
|
36
45
|
const domNode = ReactEditor.toDOMNode(editor, nodeEntry[0]);
|
|
37
46
|
if (domNode) {
|
|
47
|
+
const topGap = 20;
|
|
48
|
+
const leftGap = 5;
|
|
38
49
|
const {
|
|
39
50
|
top,
|
|
40
|
-
|
|
51
|
+
left
|
|
41
52
|
} = domNode.getBoundingClientRect();
|
|
53
|
+
let popoverTop = top + topGap;
|
|
54
|
+
let popoverLeft = left + leftGap;
|
|
55
|
+
// Insert gap between the popover and the selected node
|
|
56
|
+
// file item height 32px, header height 32px, add button height 32px, margin-top 8px, max-height 306px
|
|
57
|
+
const popoverHeight = Math.min(files.length * 32 + 32 * 3 + 8, 300);
|
|
58
|
+
// Insert gap between the popover and the selected node
|
|
59
|
+
const popoverBottomY = top + popoverHeight + topGap;
|
|
60
|
+
const viewportHeight = window.innerHeight;
|
|
61
|
+
if (popoverBottomY > viewportHeight) {
|
|
62
|
+
// 8px for the gap between the popover and the bottom of the viewport
|
|
63
|
+
const counterTopGap = 8;
|
|
64
|
+
popoverTop = top - popoverHeight - counterTopGap;
|
|
65
|
+
}
|
|
42
66
|
setPosition({
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
top: popoverTop,
|
|
68
|
+
left: popoverLeft
|
|
45
69
|
});
|
|
46
70
|
}
|
|
47
71
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
|
-
}, []);
|
|
72
|
+
}, [files]);
|
|
49
73
|
const onClick = useCallback(e => {
|
|
50
|
-
|
|
74
|
+
var _historyFileWrapperRe, _historyFileWrapperRe2;
|
|
75
|
+
const isClickInside = (_historyFileWrapperRe = historyFileWrapperRef.current) === null || _historyFileWrapperRe === void 0 ? void 0 : (_historyFileWrapperRe2 = _historyFileWrapperRe.contains) === null || _historyFileWrapperRe2 === void 0 ? void 0 : _historyFileWrapperRe2.call(_historyFileWrapperRe, e.target);
|
|
76
|
+
if (isClickInside) return;
|
|
77
|
+
deleteInputAndInsertText();
|
|
51
78
|
closeDialog();
|
|
52
|
-
|
|
53
|
-
}, []);
|
|
79
|
+
}, [closeDialog, deleteInputAndInsertText]);
|
|
54
80
|
const onScroll = useCallback(e => {
|
|
55
81
|
getPosition();
|
|
56
|
-
|
|
57
|
-
}, []);
|
|
82
|
+
}, [getPosition]);
|
|
58
83
|
const getHistoryFiles = useCallback(e => {
|
|
59
84
|
const files = LocalStorage.getItem('sdoc-recent-files') || [];
|
|
60
85
|
setFiles(files);
|
|
61
86
|
}, []);
|
|
62
|
-
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
getHistoryFiles();
|
|
89
|
+
}, [getHistoryFiles]);
|
|
90
|
+
const onKeydown = useCallback(e => {
|
|
63
91
|
const {
|
|
64
|
-
|
|
65
|
-
} =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
92
|
+
key
|
|
93
|
+
} = e;
|
|
94
|
+
switch (key) {
|
|
95
|
+
case 'Escape':
|
|
96
|
+
deleteInputAndInsertText();
|
|
97
|
+
closeDialog();
|
|
98
|
+
break;
|
|
99
|
+
case 'ArrowRight':
|
|
100
|
+
case 'ArrowLeft':
|
|
101
|
+
deleteInputAndInsertText();
|
|
102
|
+
closeDialog();
|
|
103
|
+
break;
|
|
104
|
+
case 'ArrowUp':
|
|
105
|
+
case 'ArrowDown':
|
|
106
|
+
deleteInputAndInsertText();
|
|
107
|
+
closeDialog();
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}, [closeDialog, deleteInputAndInsertText]);
|
|
113
|
+
const onInsertLink = useCallback(params => {
|
|
114
|
+
insertSdocFileLink(editor, params.data.obj_name, params.data.doc_uuid);
|
|
115
|
+
removeTempInput();
|
|
116
|
+
}, [editor]);
|
|
69
117
|
useEffect(() => {
|
|
70
118
|
getPosition();
|
|
71
|
-
getHistoryFiles();
|
|
72
|
-
setTimeout(() => {
|
|
73
|
-
historyFilesInputRef.current.focus();
|
|
74
|
-
}, 0);
|
|
75
119
|
const sdocScrollContainer = document.getElementById('sdoc-scroll-container');
|
|
120
|
+
document.addEventListener('click', onClick);
|
|
121
|
+
document.addEventListener('keydown', onKeydown);
|
|
76
122
|
sdocScrollContainer.addEventListener('scroll', onScroll);
|
|
77
|
-
const eventBus = EventBus.getInstance();
|
|
78
123
|
const unsubscribeInsertLink = eventBus.subscribe(EXTERNAL_EVENT.INSERT_LINK, onInsertLink);
|
|
79
|
-
|
|
124
|
+
const unsubscribeCloseDialog = eventBus.subscribe(INTERNAL_EVENT.CLOSE_FILE_INSET_DIALOG, closeDialog);
|
|
80
125
|
return () => {
|
|
81
126
|
sdocScrollContainer.removeEventListener('scroll', onScroll);
|
|
82
|
-
unsubscribeInsertLink();
|
|
83
127
|
document.removeEventListener('click', onClick);
|
|
128
|
+
document.removeEventListener('keydown', onKeydown);
|
|
129
|
+
unsubscribeInsertLink();
|
|
130
|
+
unsubscribeCloseDialog();
|
|
84
131
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const onKeydown = useCallback(e => {
|
|
88
|
-
const {
|
|
89
|
-
key,
|
|
90
|
-
target
|
|
91
|
-
} = e;
|
|
92
|
-
if (key === 'Backspace' && !target.selectionStart && !target.selectionEnd && !target.value) {
|
|
93
|
-
focusEditor(editor);
|
|
94
|
-
closeDialog();
|
|
95
|
-
}
|
|
96
|
-
}, [closeDialog, editor]);
|
|
97
|
-
const onCompositionStart = e => {
|
|
98
|
-
e.stopPropagation();
|
|
99
|
-
historyFilesInputRef.current.typing = true;
|
|
100
|
-
};
|
|
101
|
-
const onCompositionEnd = e => {
|
|
102
|
-
e.stopPropagation();
|
|
103
|
-
historyFilesInputRef.current.typing = false;
|
|
104
|
-
onSearch(e);
|
|
105
|
-
};
|
|
106
|
-
const onSearch = useCallback(async e => {
|
|
107
|
-
// Ignore when entering Chinese
|
|
108
|
-
if (historyFilesInputRef.current.typing) return;
|
|
109
|
-
|
|
132
|
+
}, [closeDialog, editor, eventBus, files, getPosition, onClick, onInsertLink, onKeydown, onScroll]);
|
|
133
|
+
const onSearch = useCallback(async searchText => {
|
|
110
134
|
// Show history files when search is empty
|
|
111
|
-
if (
|
|
135
|
+
if (searchText.trim().length === 0) {
|
|
112
136
|
setHeader(t('Recent_visited'));
|
|
113
137
|
setNewFileName('');
|
|
114
138
|
getHistoryFiles();
|
|
@@ -116,20 +140,20 @@ const HistoryFiles = _ref => {
|
|
|
116
140
|
}
|
|
117
141
|
|
|
118
142
|
// Cannot be found if the search is less than three characters.
|
|
119
|
-
if (isEnglish(
|
|
143
|
+
if (isEnglish(searchText.trim()) && searchText.length < 3) {
|
|
120
144
|
setFiles([]);
|
|
121
|
-
setHeader(t('
|
|
122
|
-
setNewFileName(
|
|
145
|
+
setHeader(t('Enter_more_character_start_search'));
|
|
146
|
+
setNewFileName(searchText);
|
|
123
147
|
return;
|
|
124
148
|
}
|
|
125
149
|
try {
|
|
126
150
|
var _res$data;
|
|
127
|
-
const res = await context.searchSdocFiles(
|
|
151
|
+
const res = await context.searchSdocFiles(searchText, 1, 10);
|
|
128
152
|
if (res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.results) {
|
|
129
153
|
let newFiles = res.data.results;
|
|
130
154
|
if (newFiles.length === 0) {
|
|
131
155
|
setHeader(t('The_document_does_not_exist'));
|
|
132
|
-
setNewFileName(
|
|
156
|
+
setNewFileName(searchText);
|
|
133
157
|
} else {
|
|
134
158
|
setHeader('');
|
|
135
159
|
setNewFileName('');
|
|
@@ -142,25 +166,27 @@ const HistoryFiles = _ref => {
|
|
|
142
166
|
}
|
|
143
167
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
144
168
|
}, []);
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (!(element === null || element === void 0 ? void 0 : element.children)) return;
|
|
171
|
+
const searchText = element.children[0].text;
|
|
172
|
+
onSearch(searchText);
|
|
173
|
+
}, [element, onSearch]);
|
|
145
174
|
const onSelect = useCallback(fileInfo => {
|
|
146
175
|
const {
|
|
147
176
|
doc_uuid,
|
|
148
177
|
name
|
|
149
178
|
} = fileInfo;
|
|
150
|
-
|
|
151
|
-
insertSdocFileLinkCallback
|
|
152
|
-
} = insertLinkCallback;
|
|
153
|
-
insertSdocFileLinkCallback(editor, name, doc_uuid);
|
|
179
|
+
removeTempInput(editor, element);
|
|
154
180
|
closeDialog();
|
|
155
|
-
|
|
156
|
-
}, []);
|
|
181
|
+
insertSdocFileLink(editor, name, doc_uuid);
|
|
182
|
+
}, [closeDialog, editor, element]);
|
|
157
183
|
const onShowMore = useCallback(() => {
|
|
158
|
-
const eventBus = EventBus.getInstance();
|
|
159
184
|
eventBus.dispatch(INTERNAL_EVENT.INSERT_ELEMENT, {
|
|
160
185
|
type: SDOC_LINK,
|
|
161
186
|
insertSdocFileLinkCallback: insertSdocFileLink
|
|
162
187
|
});
|
|
163
|
-
|
|
188
|
+
removeTempInput(editor, element);
|
|
189
|
+
}, [editor, element, eventBus]);
|
|
164
190
|
const onCreateFile = useCallback(() => {
|
|
165
191
|
const eventBus = EventBus.getInstance();
|
|
166
192
|
eventBus.dispatch(EXTERNAL_EVENT.CREATE_SDOC_FILE, {
|
|
@@ -168,20 +194,10 @@ const HistoryFiles = _ref => {
|
|
|
168
194
|
});
|
|
169
195
|
}, [newFileName]);
|
|
170
196
|
return /*#__PURE__*/React.createElement("div", {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
id: "sdoc-history-files-search-input",
|
|
176
|
-
className: "sdoc-history-files-search-input",
|
|
177
|
-
ref: historyFilesInputRef,
|
|
178
|
-
autoComplete: "off",
|
|
179
|
-
onChange: debounce(onSearch, 200),
|
|
180
|
-
onCompositionStart: onCompositionStart,
|
|
181
|
-
onCompositionEnd: onCompositionEnd,
|
|
182
|
-
onKeyDown: onKeydown
|
|
183
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
184
|
-
className: "sdoc-history-files-content"
|
|
197
|
+
className: "sdoc-history-files-content popover",
|
|
198
|
+
style: _objectSpread(_objectSpread({}, position), {}, {
|
|
199
|
+
position: 'absolute'
|
|
200
|
+
})
|
|
185
201
|
}, header.length !== 0 && /*#__PURE__*/React.createElement("div", {
|
|
186
202
|
className: "sdoc-history-files-header"
|
|
187
203
|
}, header), /*#__PURE__*/React.createElement("div", {
|
|
@@ -206,6 +222,10 @@ const HistoryFiles = _ref => {
|
|
|
206
222
|
onClick: onCreateFile
|
|
207
223
|
}, /*#__PURE__*/React.createElement("i", {
|
|
208
224
|
className: "sdocfont sdoc-append"
|
|
209
|
-
}), /*#__PURE__*/React.createElement("span",
|
|
225
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
226
|
+
className: "new-file-name"
|
|
227
|
+
}, newFileName ? t('Create_file_name_sdoc', {
|
|
228
|
+
file_name_sdoc: "".concat(newFileName, ".sdoc")
|
|
229
|
+
}) : t('Create_a_new_sdoc_file'))));
|
|
210
230
|
};
|
|
211
|
-
export default
|
|
231
|
+
export default FileLinkInsertDialog;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.sdoc-history-files-content {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
position: absolute;
|
|
5
|
+
width: 400px;
|
|
6
|
+
max-height: 300px;
|
|
7
|
+
/* The same as hierarchy of comment drawer */
|
|
8
|
+
z-index: 103;
|
|
9
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, .15), 0 4px 8px 3px rgba(0, 0, 0, .15);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.sdoc-history-files-content .sdoc-history-files-header {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-shrink: 0;
|
|
15
|
+
align-items: center;
|
|
16
|
+
margin-top: 8px;
|
|
17
|
+
padding: 0px 16px;
|
|
18
|
+
height: 32px;
|
|
19
|
+
width: 100%;
|
|
20
|
+
color: #999999;
|
|
21
|
+
font-size: 14px;
|
|
22
|
+
user-select: none;
|
|
23
|
+
cursor: default;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sdoc-history-files-content .sdoc-history-files {
|
|
27
|
+
flex-grow: 1;
|
|
28
|
+
overflow-y: auto;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sdoc-history-files-content .no-header {
|
|
33
|
+
margin-top: 8px;
|
|
34
|
+
width: 100%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.sdoc-history-files-content .sdoc-history-files .sdoc-history-files-item {
|
|
38
|
+
padding: 0px 16px;
|
|
39
|
+
height: 32px;
|
|
40
|
+
line-height: 32px;
|
|
41
|
+
text-overflow: ellipsis;
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sdoc-history-files-content .sdoc-history-files .sdoc-history-files-item :first-child {
|
|
47
|
+
font-size: 12px;
|
|
48
|
+
margin-right: 5px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.sdoc-history-files-content .sdoc-history-files .sdoc-history-files-item:hover {
|
|
52
|
+
background-color: #f5f5f5;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.sdoc-history-files-content .sdoc-history-files-add {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-shrink: 0;
|
|
58
|
+
align-items: center;
|
|
59
|
+
padding: 0px 16px;
|
|
60
|
+
height: 32px;
|
|
61
|
+
width: 100%;
|
|
62
|
+
border-top: 1px solid #e9ecef;
|
|
63
|
+
font-size: 14px;
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.sdoc-history-files-content .sdoc-history-files-add :first-child {
|
|
68
|
+
color: #444444;
|
|
69
|
+
margin-right: 10px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.sdoc-history-files-content .sdoc-history-files-add .new-file-name {
|
|
73
|
+
text-wrap: nowrap;
|
|
74
|
+
text-overflow: ellipsis;
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
}
|
|
@@ -2,12 +2,12 @@ import React, { useCallback, useEffect, useState, useRef } from 'react';
|
|
|
2
2
|
import { CustomTableSizeDialog, SplitCellSettingDialog } from '../../plugins/table/dialogs';
|
|
3
3
|
import AddLinkDialog from '../../plugins/link/dialog/add-link-dialog';
|
|
4
4
|
import SelectFileDialog from '../select-file-dialog/index.js';
|
|
5
|
-
import HistoryFiles from '../history-files';
|
|
6
5
|
import EventBus from '../../../utils/event-bus';
|
|
7
6
|
import { INTERNAL_EVENT } from '../../../constants';
|
|
8
7
|
import { ELEMENT_TYPE, INSERT_POSITION, LOCAL_IMAGE } from '../../constants';
|
|
9
8
|
import { insertImage } from '../../plugins/image/helpers';
|
|
10
9
|
import context from '../../../../context.js';
|
|
10
|
+
import FileLinkInsertDialog from '../file-insert-dialog/index.js';
|
|
11
11
|
const InsertElementDialog = _ref => {
|
|
12
12
|
let {
|
|
13
13
|
editor
|
|
@@ -17,7 +17,6 @@ const InsertElementDialog = _ref => {
|
|
|
17
17
|
const [insertPosition, setInsertPosition] = useState(INSERT_POSITION.CURRENT);
|
|
18
18
|
const [slateNode, setSlateNode] = useState(null);
|
|
19
19
|
const [insertLinkCallback, setInsertLinkCallback] = useState(null);
|
|
20
|
-
const [isShowHistoryFiles, setIsShowHistoryFiles] = useState(false);
|
|
21
20
|
const [validEditor, setValidEditor] = useState(editor);
|
|
22
21
|
const uploadLocalImageInputRef = useRef();
|
|
23
22
|
const onFileChanged = useCallback(event => {
|
|
@@ -46,7 +45,6 @@ const InsertElementDialog = _ref => {
|
|
|
46
45
|
slateNode,
|
|
47
46
|
insertFileLinkCallback,
|
|
48
47
|
insertSdocFileLinkCallback,
|
|
49
|
-
isShowHistoryFiles,
|
|
50
48
|
editor: paramEditor
|
|
51
49
|
} = _ref2;
|
|
52
50
|
setInsertPosition(insertPosition);
|
|
@@ -57,7 +55,6 @@ const InsertElementDialog = _ref => {
|
|
|
57
55
|
insertSdocFileLinkCallback,
|
|
58
56
|
insertFileLinkCallback
|
|
59
57
|
});
|
|
60
|
-
setIsShowHistoryFiles(isShowHistoryFiles);
|
|
61
58
|
// Apply for comment editor, as it has a different editor instance
|
|
62
59
|
setValidEditor(paramEditor || editor);
|
|
63
60
|
if (type === LOCAL_IMAGE) {
|
|
@@ -72,7 +69,6 @@ const InsertElementDialog = _ref => {
|
|
|
72
69
|
setElement('');
|
|
73
70
|
setDialogType('');
|
|
74
71
|
setInsertLinkCallback(null);
|
|
75
|
-
setIsShowHistoryFiles(false);
|
|
76
72
|
setValidEditor(null);
|
|
77
73
|
}, []);
|
|
78
74
|
const props = {
|
|
@@ -103,9 +99,6 @@ const InsertElementDialog = _ref => {
|
|
|
103
99
|
insertLinkCallback,
|
|
104
100
|
closeDialog
|
|
105
101
|
};
|
|
106
|
-
if (isShowHistoryFiles) {
|
|
107
|
-
return /*#__PURE__*/React.createElement(HistoryFiles, sdocLinkProps);
|
|
108
|
-
}
|
|
109
102
|
return /*#__PURE__*/React.createElement(SelectFileDialog, sdocLinkProps);
|
|
110
103
|
}
|
|
111
104
|
case ELEMENT_TYPE.FILE_LINK:
|
|
@@ -132,6 +125,14 @@ const InsertElementDialog = _ref => {
|
|
|
132
125
|
onChange: onFileChanged
|
|
133
126
|
});
|
|
134
127
|
}
|
|
128
|
+
case ELEMENT_TYPE.FILE_LINK_INSET_INPUT_TEMP:
|
|
129
|
+
{
|
|
130
|
+
return /*#__PURE__*/React.createElement(FileLinkInsertDialog, {
|
|
131
|
+
element: slateNode,
|
|
132
|
+
editor: editor,
|
|
133
|
+
closeDialog: closeDialog
|
|
134
|
+
});
|
|
135
|
+
}
|
|
135
136
|
default:
|
|
136
137
|
{
|
|
137
138
|
return null;
|
|
@@ -5,16 +5,14 @@
|
|
|
5
5
|
margin-right: 1px;
|
|
6
6
|
padding: 1px 3px;
|
|
7
7
|
min-width: 12px;
|
|
8
|
-
border
|
|
9
|
-
border-color: rgba(0, 0, 0, 0.1);
|
|
10
|
-
border-radius: 3px;
|
|
11
|
-
border-width: 1px 1px 2px;
|
|
8
|
+
border: none;
|
|
12
9
|
font: inherit;
|
|
13
10
|
text-align: center;
|
|
14
|
-
color:
|
|
15
|
-
background-color:
|
|
11
|
+
color: #999;
|
|
12
|
+
background-color: transparent;
|
|
16
13
|
}
|
|
17
14
|
|
|
18
|
-
.sdoc-shortcut-prompt-container:last-child {
|
|
15
|
+
.sdoc-shortcut-prompt-container kbd:last-child {
|
|
19
16
|
margin-right: 0px;
|
|
17
|
+
padding-right: 0px;
|
|
20
18
|
}
|
|
@@ -26,6 +26,7 @@ export const IMAGE_BLOCK = 'image_block';
|
|
|
26
26
|
export const CALL_OUT = 'callout';
|
|
27
27
|
export const MENTION = 'mention';
|
|
28
28
|
export const MENTION_TEMP = 'mention_temp';
|
|
29
|
+
export const FILE_LINK_INSET_INPUT_TEMP = 'file_link_insert_input_temp';
|
|
29
30
|
|
|
30
31
|
// font
|
|
31
32
|
export const FONT_SIZE = 'font-size';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// extension plugin
|
|
2
2
|
import * as ELEMENT_TYPE from './element-type';
|
|
3
3
|
// eslint-disable-next-line no-duplicate-imports
|
|
4
|
-
import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, IMAGE_BLOCK, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT, MENTION, MENTION_TEMP } from './element-type';
|
|
4
|
+
import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, IMAGE_BLOCK, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT, MENTION, MENTION_TEMP, FILE_LINK_INSET_INPUT_TEMP } from './element-type';
|
|
5
5
|
export { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, DEFAULT_FONT_COLOR, RECENT_USED_HIGHLIGHT_COLORS_KEY, RECENT_USED_FONT_COLORS_KEY, RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY, DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR } from './color';
|
|
6
6
|
export { FONT_SIZE, DEFAULT_FONT, FONT, GOOGLE_FONT_CLASS, RECENT_USED_FONTS_KEY, SDOC_FONT_SIZE } from './font';
|
|
7
7
|
export { DIFF_TYPE, ADDED_STYLE, DELETED_STYLE } from './diff-view';
|
|
@@ -57,4 +57,4 @@ export const MOUSE_ENTER_EVENT_DISABLED_MAP = {
|
|
|
57
57
|
[CALL_OUT]: [CALL_OUT]
|
|
58
58
|
};
|
|
59
59
|
export const ROOT_ELEMENT_TYPES = [PARAGRAPH, TITLE, SUBTITLE, CHECK_LIST_ITEM, ORDERED_LIST, UNORDERED_LIST, BLOCKQUOTE, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, CALL_OUT, TABLE];
|
|
60
|
-
export { ELEMENT_TYPE, BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, IMAGE_BLOCK, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT, MENTION, MENTION_TEMP };
|
|
60
|
+
export { ELEMENT_TYPE, BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, IMAGE_BLOCK, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT, MENTION, MENTION_TEMP, FILE_LINK_INSET_INPUT_TEMP };
|
|
@@ -101,6 +101,15 @@
|
|
|
101
101
|
font-size: 14px;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
.langs-list-empty {
|
|
105
|
+
padding: 10px;
|
|
106
|
+
width: 100%;
|
|
107
|
+
font-size: 13px;
|
|
108
|
+
text-align: center;
|
|
109
|
+
line-height: 30px;
|
|
110
|
+
vertical-align: middle;
|
|
111
|
+
}
|
|
112
|
+
|
|
104
113
|
.sdoc-langs-list-container .langs-list-ul {
|
|
105
114
|
list-style: none;
|
|
106
115
|
overflow-y: auto;
|