@seafile/comment-editor 0.0.1-alpha.7 → 0.0.1-alpha.70
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 +37 -0
- package/dist/basic-sdk/context.js +8 -21
- package/dist/basic-sdk/editor/comment-editor.js +213 -229
- package/dist/basic-sdk/extension/commons/color-menu/color-item.js +4 -2
- package/dist/basic-sdk/extension/commons/color-menu/index.js +4 -2
- package/dist/basic-sdk/extension/commons/select/field-setting.js +3 -2
- package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +5 -3
- package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.js +5 -3
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/image/helpers.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +5 -3
- package/dist/basic-sdk/extension/plugins/image/use-copy-image.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/use-upload-image.js +1 -1
- package/dist/basic-sdk/extension/plugins/sdoc-link/hover-menu/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/table/menu/color-selector-popover/color-item.js +4 -2
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/insert-table-element.js +3 -2
- package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +1 -2
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/text-style/menu/comemnt-editor-menu.js +1 -2
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/video/render-elem.js +1 -2
- package/dist/basic-sdk/extension/toolbar/comment-editor-toolbar/index.js +13 -9
- package/dist/basic-sdk/hooks/use-comment.js +23 -12
- package/dist/basic-sdk/model/index.js +1 -8
- package/dist/basic-sdk/socket/helpers.js +312 -0
- package/dist/components/error-boundary/error-page.js +4 -4
- package/dist/pages/seafile-comment-editor.js +49 -26
- package/package.json +6 -6
- package/dist/basic-sdk/model/notification.js +0 -18
- package/dist/components/tip-message/index.js +0 -194
- package/dist/components/tip-message/style.css +0 -15
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getI18n = void 0;
|
|
8
|
+
var _reactI18next = require("react-i18next");
|
|
9
|
+
var _i18next = _interopRequireDefault(require("i18next"));
|
|
10
|
+
var _i18nextBrowserLanguagedetector = _interopRequireDefault(require("i18next-browser-languagedetector"));
|
|
11
|
+
var _i18nextHttpBackend = _interopRequireDefault(require("i18next-http-backend"));
|
|
12
|
+
const getI18n = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
lang
|
|
15
|
+
} = _ref;
|
|
16
|
+
_i18next.default.use(_i18nextHttpBackend.default).use(_i18nextBrowserLanguagedetector.default).use(_reactI18next.initReactI18next).init({
|
|
17
|
+
lng: lang,
|
|
18
|
+
fallbackLng: 'en',
|
|
19
|
+
ns: ['sdoc-editor'],
|
|
20
|
+
defaultNS: 'sdoc-editor',
|
|
21
|
+
debug: false,
|
|
22
|
+
// console log if debug: true
|
|
23
|
+
|
|
24
|
+
whitelist: ['en', 'zh_CN', 'fr', 'de', 'cs', 'es', 'es-AR', 'es-MX', 'ru'],
|
|
25
|
+
backend: {
|
|
26
|
+
loadPath: '/public/locales/{{ lng }}/{{ ns }}.json'
|
|
27
|
+
},
|
|
28
|
+
interpolation: {
|
|
29
|
+
escapeValue: false // not needed for react!!
|
|
30
|
+
},
|
|
31
|
+
react: {
|
|
32
|
+
wait: true
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return _i18next.default;
|
|
36
|
+
};
|
|
37
|
+
exports.getI18n = getI18n;
|
|
@@ -11,12 +11,12 @@ var _sdocServerApi = _interopRequireDefault(require("./api/sdoc-server-api"));
|
|
|
11
11
|
var _seafileApi = _interopRequireDefault(require("./api/seafile-api"));
|
|
12
12
|
class Context {
|
|
13
13
|
constructor() {
|
|
14
|
-
(0, _defineProperty2.default)(this, "initSettings",
|
|
15
|
-
this.settings = window.seafile ? window.seafile : window.seafileConfig;
|
|
14
|
+
(0, _defineProperty2.default)(this, "initSettings", settings => {
|
|
15
|
+
this.settings = settings ? settings : window.seafile ? window.seafile : window.seafileConfig;
|
|
16
16
|
const {
|
|
17
|
-
name,
|
|
18
|
-
username,
|
|
19
|
-
avatarURL
|
|
17
|
+
name = '',
|
|
18
|
+
username = '',
|
|
19
|
+
avatarURL = ''
|
|
20
20
|
} = this.settings;
|
|
21
21
|
const userInfo = {
|
|
22
22
|
name,
|
|
@@ -24,13 +24,6 @@ class Context {
|
|
|
24
24
|
avatar_url: avatarURL
|
|
25
25
|
};
|
|
26
26
|
this.user = userInfo;
|
|
27
|
-
if (this.settings['isSdocRevision']) {
|
|
28
|
-
const repoID = this.getSetting('repoID');
|
|
29
|
-
const siteRoot = this.getSetting('siteRoot');
|
|
30
|
-
const originFilePath = this.getSetting('originFilePath');
|
|
31
|
-
const originFileURL = `${siteRoot}lib/${repoID}/file${originFilePath}`;
|
|
32
|
-
this.settings['originFileURL'] = originFileURL;
|
|
33
|
-
}
|
|
34
27
|
});
|
|
35
28
|
(0, _defineProperty2.default)(this, "uploadLocalImage", imageFiles => {
|
|
36
29
|
const docUuid = this.getSetting('docUuid');
|
|
@@ -55,15 +48,9 @@ class Context {
|
|
|
55
48
|
this.api = null;
|
|
56
49
|
this.config = null;
|
|
57
50
|
}
|
|
58
|
-
init() {
|
|
59
|
-
this.initSettings();
|
|
60
|
-
|
|
61
|
-
// const token = this.getSetting('accessToken');
|
|
62
|
-
// this.api = new SeafileAPI(server, token);
|
|
63
|
-
// const isOpenSocket = this.getSetting('isOpenSocket');
|
|
64
|
-
// if (isOpenSocket) {
|
|
65
|
-
// this.sdocServerApi = new SDocServerApi(this.settings);
|
|
66
|
-
// }
|
|
51
|
+
init(settings, api) {
|
|
52
|
+
this.initSettings(settings);
|
|
53
|
+
this.api = api;
|
|
67
54
|
}
|
|
68
55
|
getSettings() {
|
|
69
56
|
return this.settings;
|
|
@@ -14,7 +14,6 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
14
14
|
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
15
15
|
var _scrollIntoViewIfNeeded = _interopRequireDefault(require("scroll-into-view-if-needed"));
|
|
16
16
|
var _constants = require("../constants");
|
|
17
|
-
var _context = _interopRequireDefault(require("../context"));
|
|
18
17
|
var _useCursors = require("../cursor/use-cursors");
|
|
19
18
|
var _decorates = require("../decorates");
|
|
20
19
|
var _extension = require("../extension");
|
|
@@ -39,16 +38,13 @@ const DEFAULT_PLACEHOLDER = 'Enter_comment_shift_enter_for_new_line_Enter_to_sen
|
|
|
39
38
|
const CommentEditor = _ref => {
|
|
40
39
|
let {
|
|
41
40
|
content,
|
|
42
|
-
commentContent,
|
|
43
41
|
placeholder = DEFAULT_PLACEHOLDER,
|
|
44
42
|
insertContent,
|
|
45
|
-
updateContent,
|
|
46
43
|
onContentChange,
|
|
47
|
-
setIsEditing,
|
|
48
44
|
hiddenComment,
|
|
49
45
|
hiddenUserInfo,
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
toolMenus = ['text_style', _constants2.BLOCKQUOTE, _constants2.UNORDERED_LIST, _constants2.ORDERED_LIST, _constants2.LINK, _constants2.IMAGE],
|
|
47
|
+
closePanel
|
|
52
48
|
} = _ref;
|
|
53
49
|
const commentWrapperRef = (0, _react.useRef)();
|
|
54
50
|
const {
|
|
@@ -57,233 +53,221 @@ const CommentEditor = _ref => {
|
|
|
57
53
|
const {
|
|
58
54
|
className,
|
|
59
55
|
userInfo,
|
|
60
|
-
type
|
|
56
|
+
type,
|
|
57
|
+
addParticipants
|
|
61
58
|
} = (0, _useComment.useComment)();
|
|
62
59
|
const submitTip = (0, _react.useMemo)(() => getSubmitTip(type, content), [content, type]);
|
|
63
|
-
const document = (0, _react.useMemo)(() => {
|
|
64
|
-
const cursor = {};
|
|
65
|
-
let elements = null;
|
|
66
|
-
elements = [(0, _core.generateEmptyElement)(_constants2.PARAGRAPH, {
|
|
67
|
-
placeholder
|
|
68
|
-
})];
|
|
69
|
-
return {
|
|
70
|
-
elements,
|
|
71
|
-
cursor
|
|
72
|
-
};
|
|
73
|
-
}, [placeholder]);
|
|
74
|
-
const [slateValue, setSlateValue] = (0, _react.useState)(document.elements);
|
|
75
|
-
const commentEditorContainerRef = (0, _react.useRef)(null);
|
|
76
|
-
const editor = (0, _react.useMemo)(() => {
|
|
77
|
-
const defaultEditor = (0, _extension.createCommentEditor)();
|
|
78
|
-
const newEditor = (0, _nodeId.default)(defaultEditor);
|
|
79
|
-
const {
|
|
80
|
-
cursors
|
|
81
|
-
} = document;
|
|
82
|
-
newEditor.cursors = cursors || {};
|
|
83
|
-
newEditor.width = _constants.COMMENT_EDITOR_EDIT_AREA_WIDTH; // default width
|
|
84
|
-
newEditor.editorType = _constants.COMMENT_EDITOR;
|
|
85
|
-
return newEditor;
|
|
86
|
-
}, [document]);
|
|
87
|
-
const {
|
|
88
|
-
cursors
|
|
89
|
-
} = (0, _useCursors.useCursors)(editor);
|
|
90
|
-
const decorate = (0, _decorates.usePipDecorate)(editor);
|
|
91
|
-
// init eventHandler
|
|
92
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
|
-
const eventProxy = (0, _react.useMemo)(() => new _eventHandler.default(editor), []);
|
|
94
|
-
const updateValue = (0, _react.useCallback)(value => {
|
|
95
|
-
if (!value || value.trim() === '') return;
|
|
96
|
-
if (!content) return insertContent(value);
|
|
97
|
-
updateContent && updateContent(value);
|
|
98
|
-
}, [content, insertContent, updateContent]);
|
|
99
|
-
const onSubmit = (0, _react.useCallback)(event => {
|
|
100
|
-
event && event.stopPropagation();
|
|
101
|
-
const mdString = (0, _slateToMd.default)(editor.children);
|
|
102
|
-
updateValue(mdString);
|
|
103
|
-
addParticipants(userInfo.username);
|
|
104
|
-
editor.children = [(0, _core.generateEmptyElement)(_constants2.PARAGRAPH, {
|
|
105
|
-
placeholder
|
|
106
|
-
})];
|
|
107
|
-
_slate.Transforms.select(editor, _slate.Editor.start(editor, []));
|
|
108
|
-
onContentChange && onContentChange(null);
|
|
109
|
-
closeComment && closeComment();
|
|
110
|
-
}, [editor, updateValue, addParticipants, userInfo.username, placeholder, onContentChange, closeComment]);
|
|
111
|
-
const onSubmitByEnterKey = (0, _react.useCallback)(event => {
|
|
112
|
-
if (!_slateReact.ReactEditor.isFocused(editor)) return;
|
|
113
|
-
onSubmit(event);
|
|
114
|
-
}, [editor, onSubmit]);
|
|
115
60
|
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
61
|
+
// const document = useMemo(() => {
|
|
62
|
+
// const cursor = {};
|
|
63
|
+
// let elements = null;
|
|
64
|
+
// elements = [generateEmptyElement(PARAGRAPH, { placeholder })];
|
|
65
|
+
// return { elements, cursor };
|
|
66
|
+
// }, [placeholder]);
|
|
67
|
+
|
|
68
|
+
// const [slateValue, setSlateValue] = useState(document.elements);
|
|
69
|
+
// const commentEditorContainerRef = useRef(null);
|
|
70
|
+
|
|
71
|
+
// const editor = useMemo(() => {
|
|
72
|
+
// const defaultEditor = createCommentEditor();
|
|
73
|
+
// const newEditor = withNodeId(defaultEditor);
|
|
74
|
+
// const { cursors } = document;
|
|
75
|
+
// newEditor.cursors = cursors || {};
|
|
76
|
+
// newEditor.width = COMMENT_EDITOR_EDIT_AREA_WIDTH; // default width
|
|
77
|
+
// newEditor.editorType = COMMENT_EDITOR;
|
|
78
|
+
|
|
79
|
+
// return newEditor;
|
|
80
|
+
// }, [document]);
|
|
81
|
+
|
|
82
|
+
// const { cursors } = useCursors(editor);
|
|
83
|
+
// const decorate = usePipDecorate(editor);
|
|
84
|
+
// // init eventHandler
|
|
85
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
|
+
// const eventProxy = useMemo(() => new EventProxy(editor), []);
|
|
87
|
+
|
|
88
|
+
// const onSubmit = useCallback((event) => {
|
|
89
|
+
// event && event.stopPropagation();
|
|
90
|
+
|
|
91
|
+
// const mdString = slateToMdString(editor.children);
|
|
92
|
+
// if (mdString && mdString.trim()) insertContent(mdString);
|
|
93
|
+
|
|
94
|
+
// addParticipants && addParticipants(userInfo.username);
|
|
95
|
+
|
|
96
|
+
// editor.children = [generateEmptyElement(PARAGRAPH, { placeholder })];
|
|
97
|
+
// Transforms.select(editor, Editor.start(editor, []));
|
|
98
|
+
|
|
99
|
+
// onContentChange && onContentChange(null);
|
|
100
|
+
// closePanel && closePanel();
|
|
101
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
102
|
+
// }, [editor, insertContent, addParticipants, placeholder, onContentChange, closePanel]);
|
|
103
|
+
|
|
104
|
+
// const onSubmitByEnterKey = useCallback((event) => {
|
|
105
|
+
// if (!ReactEditor.isFocused(editor)) return;
|
|
106
|
+
// onSubmit(event);
|
|
107
|
+
// }, [editor, onSubmit]);
|
|
108
|
+
|
|
109
|
+
// // addEventListener
|
|
110
|
+
// useEffect(() => {
|
|
111
|
+
// const eventBus = EventBus.getInstance();
|
|
112
|
+
// const unsubscribePostComment = eventBus.subscribe(INTERNAL_EVENT.COMMENT_EDITOR_POST_COMMENT, onSubmitByEnterKey);
|
|
113
|
+
|
|
114
|
+
// return () => {
|
|
115
|
+
// unsubscribePostComment();
|
|
116
|
+
// };
|
|
117
|
+
// }, [onSubmitByEnterKey]);
|
|
118
|
+
|
|
119
|
+
// const onCancel = useCallback((event) => {
|
|
120
|
+
// event.stopPropagation();
|
|
121
|
+
// const { type: eventType, keyCode, target } = event;
|
|
122
|
+
// if (eventType === 'keydown' && keyCode !== KeyCodes.Esc) return;
|
|
123
|
+
// if (eventType === 'click') {
|
|
124
|
+
// const isSdocContentWrapper = target.classList.contains('sdoc-content-wrapper');
|
|
125
|
+
// const listContainer = window.document.querySelector('#global-comment-list-container');
|
|
126
|
+
// const resizeContainer = window.document.querySelector('.sdoc-comment-resize-handler');
|
|
127
|
+
// const isClickOnListContainer = listContainer && listContainer.contains(target);
|
|
128
|
+
// const isClickOnCommentEditorContainer = commentWrapperRef.current.contains(target);
|
|
129
|
+
// const isClickResizeContainer = resizeContainer && resizeContainer.contains(target);
|
|
130
|
+
// const isPreventCancel = isClickOnListContainer || isClickOnCommentEditorContainer || isClickResizeContainer || isSdocContentWrapper;
|
|
131
|
+
// if (isPreventCancel) return;
|
|
132
|
+
// }
|
|
133
|
+
// hiddenComment && hiddenComment(false);
|
|
134
|
+
|
|
135
|
+
// if (onContentChange) {
|
|
136
|
+
// if (editor.children.find(n => Node.string(n).trim())) {
|
|
137
|
+
// onContentChange(slateToMdString(editor.children));
|
|
138
|
+
// } else {
|
|
139
|
+
// onContentChange(null);
|
|
140
|
+
// }
|
|
141
|
+
// }
|
|
142
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
143
|
+
// }, []);
|
|
144
|
+
|
|
145
|
+
// // set editor children
|
|
146
|
+
// useEffect(() => {
|
|
147
|
+
// let children = mdStringToSlate(content);
|
|
148
|
+
// editor.children = children;
|
|
149
|
+
// // Transforms.select(editor, Editor.end(editor, []));
|
|
150
|
+
// }, [editor, content]);
|
|
151
|
+
|
|
152
|
+
// // useMount: focus editor
|
|
153
|
+
// useEffect(() => {
|
|
154
|
+
// const [firstNode] = editor.children;
|
|
155
|
+
// if (firstNode) {
|
|
156
|
+
// const [firstNodeFirstChild] = firstNode.children;
|
|
157
|
+
|
|
158
|
+
// if (firstNodeFirstChild) {
|
|
159
|
+
// const endOfFirstNode = Editor.end(editor, [0, 0]);
|
|
160
|
+
// const range = {
|
|
161
|
+
// anchor: endOfFirstNode,
|
|
162
|
+
// focus: endOfFirstNode,
|
|
163
|
+
// };
|
|
164
|
+
// // focusEditor(editor, range);
|
|
165
|
+
// }
|
|
166
|
+
// // Force refresh to fix comment list
|
|
167
|
+
// // setSlateValue([...editor.children]);
|
|
168
|
+
// }
|
|
169
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
170
|
+
// }, []);
|
|
171
|
+
|
|
172
|
+
// const handleFocusEditor = (e) => {
|
|
173
|
+
// if (e.target === commentEditorContainerRef.current) {
|
|
174
|
+
// const focusPoint = Editor.end(editor, []);
|
|
175
|
+
// focusEditor(editor, focusPoint);
|
|
176
|
+
// }
|
|
177
|
+
// };
|
|
178
|
+
|
|
179
|
+
// const handleScrollIntoView = useCallback((editor, domRange) => {
|
|
180
|
+
// try {
|
|
181
|
+
// const { selection } = editor;
|
|
182
|
+
// // Do not scroll into view, when focus on image
|
|
183
|
+
// const [imageNodeEntry] = Editor.nodes(editor, {
|
|
184
|
+
// match: n => [IMAGE, IMAGE_BLOCK].includes(n.type),
|
|
185
|
+
// at: selection
|
|
186
|
+
// });
|
|
187
|
+
// if (imageNodeEntry) return;
|
|
188
|
+
// const focusedNode = Node.get(editor, selection.focus.path);
|
|
189
|
+
// const domNode = ReactEditor.toDOMNode(editor, focusedNode);
|
|
190
|
+
// if (!domNode) return;
|
|
191
|
+
// scrollIntoView(domNode, { 'scrollMode': 'if-needed' });
|
|
192
|
+
// } catch (error) {
|
|
193
|
+
// //
|
|
194
|
+
// }
|
|
195
|
+
// }, []);
|
|
196
|
+
|
|
197
|
+
// const onMouseDown = useCallback((event) => {
|
|
198
|
+
// if (event.button === 0) {
|
|
199
|
+
// // Compatible with the editor which unload table plugin
|
|
200
|
+
// editor.reSetTableSelectedRange && editor.reSetTableSelectedRange();
|
|
201
|
+
// const eventBus = EventBus.getInstance();
|
|
202
|
+
// eventBus.dispatch(INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
203
|
+
// }
|
|
204
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
205
|
+
// }, []);
|
|
206
|
+
|
|
207
|
+
// const onKeyDown = useCallback((event) => {
|
|
208
|
+
// if (isHotkey('enter', event)) {
|
|
209
|
+
// event.preventDefault();
|
|
210
|
+
// const eventBus = EventBus.getInstance();
|
|
211
|
+
// eventBus.dispatch(INTERNAL_EVENT.COMMENT_EDITOR_POST_COMMENT, event);
|
|
212
|
+
// return;
|
|
213
|
+
// }
|
|
214
|
+
|
|
215
|
+
// if (isHotkey('shift+enter', event)) {
|
|
216
|
+
// event.preventDefault();
|
|
217
|
+
// Editor.insertBreak(editor);
|
|
218
|
+
// return;
|
|
219
|
+
// }
|
|
220
|
+
|
|
221
|
+
// eventProxy.onKeyDown(event);
|
|
153
222
|
|
|
154
|
-
//
|
|
155
|
-
(0, _react.useEffect)(() => {
|
|
156
|
-
let children = (0, _mdToSlate.default)(content);
|
|
157
|
-
if (commentContent) {
|
|
158
|
-
children = (0, _mdToSlate.default)(commentContent);
|
|
159
|
-
}
|
|
160
|
-
editor.children = children;
|
|
161
|
-
_slate.Transforms.select(editor, _slate.Editor.end(editor, []));
|
|
162
|
-
}, [editor, content, commentContent]);
|
|
223
|
+
// }, [eventProxy, editor]);
|
|
163
224
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
// Compatible with the editor which unload table plugin
|
|
212
|
-
editor.reSetTableSelectedRange && editor.reSetTableSelectedRange();
|
|
213
|
-
const eventBus = _eventBus.default.getInstance();
|
|
214
|
-
eventBus.dispatch(_constants.INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
215
|
-
}
|
|
216
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
217
|
-
}, []);
|
|
218
|
-
const onKeyDown = (0, _react.useCallback)(event => {
|
|
219
|
-
if ((0, _isHotkey.default)('enter', event)) {
|
|
220
|
-
event.preventDefault();
|
|
221
|
-
const eventBus = _eventBus.default.getInstance();
|
|
222
|
-
eventBus.dispatch(_constants.INTERNAL_EVENT.COMMENT_EDITOR_POST_COMMENT, event);
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
if ((0, _isHotkey.default)('shift+enter', event)) {
|
|
226
|
-
event.preventDefault();
|
|
227
|
-
_slate.Editor.insertBreak(editor);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
eventProxy.onKeyDown(event);
|
|
231
|
-
}, [eventProxy, editor]);
|
|
232
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
233
|
-
className: (0, _classnames.default)('comment-editor-wrapper', className),
|
|
234
|
-
ref: commentWrapperRef
|
|
235
|
-
}, type === 'comment' && !hiddenUserInfo && /*#__PURE__*/_react.default.createElement("div", {
|
|
236
|
-
className: "comment-editor-user-info"
|
|
237
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
238
|
-
className: "comment-editor-user-img"
|
|
239
|
-
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
240
|
-
src: userInfo.avatar_url,
|
|
241
|
-
alt: "",
|
|
242
|
-
height: "100%",
|
|
243
|
-
width: "100%"
|
|
244
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
245
|
-
className: "comment-editor-user-name"
|
|
246
|
-
}, userInfo.name)), /*#__PURE__*/_react.default.createElement("div", {
|
|
247
|
-
className: "comment-editor-container"
|
|
248
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
249
|
-
className: "comment-editor-content"
|
|
250
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
251
|
-
ref: commentEditorContainerRef,
|
|
252
|
-
className: "article comment-editor",
|
|
253
|
-
onClick: handleFocusEditor
|
|
254
|
-
}, /*#__PURE__*/_react.default.createElement(_useScrollContext.ScrollContext.Provider, {
|
|
255
|
-
value: {
|
|
256
|
-
scrollRef: commentEditorContainerRef
|
|
257
|
-
}
|
|
258
|
-
}, /*#__PURE__*/_react.default.createElement(_slateReact.Slate, {
|
|
259
|
-
editor: editor,
|
|
260
|
-
value: slateValue,
|
|
261
|
-
onChange: setSlateValue
|
|
262
|
-
}, /*#__PURE__*/_react.default.createElement(_slateReact.Editable, {
|
|
263
|
-
id: "sdoc-editor",
|
|
264
|
-
scrollSelectionIntoView: handleScrollIntoView,
|
|
265
|
-
cursors: cursors,
|
|
266
|
-
renderElement: props => (0, _renderCommentEditorElement.default)({
|
|
267
|
-
...props,
|
|
268
|
-
commentType: type
|
|
269
|
-
}),
|
|
270
|
-
renderLeaf: _extension.renderLeaf,
|
|
271
|
-
onMouseDown: onMouseDown,
|
|
272
|
-
decorate: decorate,
|
|
273
|
-
onCut: eventProxy.onCut,
|
|
274
|
-
onCopy: eventProxy.onCopy,
|
|
275
|
-
onCompositionStart: eventProxy.onCompositionStart,
|
|
276
|
-
onCompositionUpdate: eventProxy.onCompositionUpdate,
|
|
277
|
-
onCompositionEnd: eventProxy.onCompositionEnd,
|
|
278
|
-
onKeyDown: onKeyDown,
|
|
279
|
-
onBeforeInput: eventProxy.onBeforeInput
|
|
280
|
-
})))), /*#__PURE__*/_react.default.createElement(_commentEditorToolbar.default, {
|
|
281
|
-
editor: editor,
|
|
282
|
-
onSubmit: onSubmit,
|
|
283
|
-
submitBtnText: t(submitTip),
|
|
284
|
-
onCancel: onCancel
|
|
285
|
-
}))), /*#__PURE__*/_react.default.createElement(_insertElementDialog.default, {
|
|
286
|
-
editor: editor
|
|
287
|
-
}));
|
|
225
|
+
console.log('toolMenus', toolMenus);
|
|
226
|
+
return /*#__PURE__*/_react.default.createElement("div", null, "123")
|
|
227
|
+
// <div className={classNames('comment-editor-wrapper', className)} ref={commentWrapperRef}>
|
|
228
|
+
// {type === 'comment' && !hiddenUserInfo && (
|
|
229
|
+
// <div className="comment-editor-user-info">
|
|
230
|
+
// <div className="comment-editor-user-img">
|
|
231
|
+
// <img src={userInfo.avatar_url} alt="" height="100%" width="100%" />
|
|
232
|
+
// </div>
|
|
233
|
+
// <div className="comment-editor-user-name">{userInfo.name}</div>
|
|
234
|
+
// </div>
|
|
235
|
+
// )}
|
|
236
|
+
// <div className='comment-editor-container'>
|
|
237
|
+
// <div className="comment-editor-content">
|
|
238
|
+
// <div ref={commentEditorContainerRef} className='article comment-editor' onClick={handleFocusEditor} >
|
|
239
|
+
// <ScrollContext.Provider value={{ scrollRef: commentEditorContainerRef }}>
|
|
240
|
+
// <Slate editor={editor} value={slateValue} onChange={setSlateValue}>
|
|
241
|
+
// <Editable
|
|
242
|
+
// id='sdoc-editor'
|
|
243
|
+
// scrollSelectionIntoView={handleScrollIntoView}
|
|
244
|
+
// cursors={cursors}
|
|
245
|
+
// renderElement={(props) => RenderCommentEditorCustomRenderElement({ ...props, commentType: type })}
|
|
246
|
+
// renderLeaf={renderLeaf}
|
|
247
|
+
// onMouseDown={onMouseDown}
|
|
248
|
+
// decorate={decorate}
|
|
249
|
+
// onCut={eventProxy.onCut}
|
|
250
|
+
// onCopy={eventProxy.onCopy}
|
|
251
|
+
// onCompositionStart={eventProxy.onCompositionStart}
|
|
252
|
+
// onCompositionUpdate={eventProxy.onCompositionUpdate}
|
|
253
|
+
// onCompositionEnd={eventProxy.onCompositionEnd}
|
|
254
|
+
// onKeyDown={onKeyDown}
|
|
255
|
+
// onBeforeInput={eventProxy.onBeforeInput}
|
|
256
|
+
// />
|
|
257
|
+
// </Slate>
|
|
258
|
+
// </ScrollContext.Provider>
|
|
259
|
+
// </div>
|
|
260
|
+
// <CommentEditorToolbar
|
|
261
|
+
// editor={editor}
|
|
262
|
+
// toolMenus={toolMenus}
|
|
263
|
+
// onSubmit={onSubmit}
|
|
264
|
+
// submitBtnText={t(submitTip)}
|
|
265
|
+
// onCancel={onCancel}
|
|
266
|
+
// />
|
|
267
|
+
// </div>
|
|
268
|
+
// </div>
|
|
269
|
+
// {toolMenus.includes(IMAGE) && <InsertElementDialog editor={editor} />}
|
|
270
|
+
// </div>
|
|
271
|
+
;
|
|
288
272
|
};
|
|
289
273
|
var _default = exports.default = CommentEditor;
|
|
@@ -10,10 +10,12 @@ var _reactI18next = require("react-i18next");
|
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
const ColorItem = _ref => {
|
|
12
12
|
let {
|
|
13
|
-
t,
|
|
14
13
|
color,
|
|
15
14
|
lastUsedColor
|
|
16
15
|
} = _ref;
|
|
16
|
+
const {
|
|
17
|
+
t
|
|
18
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
17
19
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
18
20
|
className: (0, _classnames.default)('sdoc-color-item', {
|
|
19
21
|
'selected': lastUsedColor === color.value
|
|
@@ -28,4 +30,4 @@ const ColorItem = _ref => {
|
|
|
28
30
|
}) : t(color.name)
|
|
29
31
|
});
|
|
30
32
|
};
|
|
31
|
-
var _default = exports.default =
|
|
33
|
+
var _default = exports.default = ColorItem;
|
|
@@ -26,7 +26,6 @@ const ColorMenu = _ref => {
|
|
|
26
26
|
id,
|
|
27
27
|
popoverClassName,
|
|
28
28
|
disabled,
|
|
29
|
-
t,
|
|
30
29
|
setColor,
|
|
31
30
|
recentUsedColorsKey,
|
|
32
31
|
text,
|
|
@@ -35,6 +34,9 @@ const ColorMenu = _ref => {
|
|
|
35
34
|
lastUsedColor,
|
|
36
35
|
updateLastUsedColor
|
|
37
36
|
} = _ref;
|
|
37
|
+
const {
|
|
38
|
+
t
|
|
39
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
38
40
|
const popoverRef = (0, _react.useRef)(null);
|
|
39
41
|
const moreColorsPopoverRef = (0, _react.useRef)(null);
|
|
40
42
|
const [recentUsedColors, setRecentUsedColors] = (0, _react.useState)(_localStorageUtils.default.getItem(recentUsedColorsKey, _constants.DEFAULT_RECENT_USED_LIST));
|
|
@@ -205,4 +207,4 @@ const ColorMenu = _ref => {
|
|
|
205
207
|
onChange: onChange
|
|
206
208
|
}))))));
|
|
207
209
|
};
|
|
208
|
-
var _default = exports.default =
|
|
210
|
+
var _default = exports.default = ColorMenu;
|
|
@@ -7,8 +7,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _reactI18next = require("react-i18next");
|
|
11
10
|
var _menu = _interopRequireDefault(require("./menu"));
|
|
11
|
+
// import { withTranslation } from 'react-i18next';
|
|
12
|
+
|
|
12
13
|
class FieldSetting extends _react.default.Component {
|
|
13
14
|
constructor(props) {
|
|
14
15
|
super(props);
|
|
@@ -106,4 +107,4 @@ class FieldSetting extends _react.default.Component {
|
|
|
106
107
|
}, t('Italic'))));
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
var _default = exports.default =
|
|
110
|
+
var _default = exports.default = FieldSetting;
|
|
@@ -20,10 +20,12 @@ const LocalFiles = _ref => {
|
|
|
20
20
|
onSelectedFile,
|
|
21
21
|
toggle,
|
|
22
22
|
fileType,
|
|
23
|
-
t,
|
|
24
23
|
searchContent,
|
|
25
24
|
isOpenSearch
|
|
26
25
|
} = _ref;
|
|
26
|
+
const {
|
|
27
|
+
t
|
|
28
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
27
29
|
const folderRef = (0, _react.useRef)(null);
|
|
28
30
|
const [expandedFolder, setExpandedFolder] = (0, _react.useState)(new Set([]));
|
|
29
31
|
const [currentActiveItem, setCurrentActiveItem] = (0, _react.useState)(null);
|
|
@@ -188,4 +190,4 @@ const LocalFiles = _ref => {
|
|
|
188
190
|
className: "sdoc-file-search-no-result"
|
|
189
191
|
}, t('No_results')));
|
|
190
192
|
};
|
|
191
|
-
var _default = exports.default =
|
|
193
|
+
var _default = exports.default = LocalFiles;
|
|
@@ -55,9 +55,11 @@ const CodeBlockHoverMenu = _ref2 => {
|
|
|
55
55
|
onChangeLanguage,
|
|
56
56
|
onChangeAutoLineWrap,
|
|
57
57
|
onCopyCodeBlock,
|
|
58
|
-
onDeleteCodeBlock
|
|
59
|
-
t
|
|
58
|
+
onDeleteCodeBlock
|
|
60
59
|
} = _ref2;
|
|
60
|
+
const {
|
|
61
|
+
t
|
|
62
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
61
63
|
const {
|
|
62
64
|
white_space = 'nowrap'
|
|
63
65
|
} = style;
|
|
@@ -254,4 +256,4 @@ const CodeBlockHoverMenu = _ref2 => {
|
|
|
254
256
|
ref: langRefs
|
|
255
257
|
})))));
|
|
256
258
|
};
|
|
257
|
-
var _default = exports.default =
|
|
259
|
+
var _default = exports.default = CodeBlockHoverMenu;
|