@seafile/comment-editor 0.0.1-alpha.7 → 0.0.1-alpha.71

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.
Files changed (34) hide show
  1. package/dist/_i18n/index.js +37 -0
  2. package/dist/basic-sdk/context.js +8 -21
  3. package/dist/basic-sdk/editor/comment-editor.js +219 -234
  4. package/dist/basic-sdk/extension/commons/color-menu/color-item.js +4 -2
  5. package/dist/basic-sdk/extension/commons/color-menu/index.js +4 -2
  6. package/dist/basic-sdk/extension/commons/select/field-setting.js +3 -2
  7. package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.js +4 -2
  8. package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +5 -3
  9. package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.js +5 -3
  10. package/dist/basic-sdk/extension/plugins/header/menu/index.js +3 -2
  11. package/dist/basic-sdk/extension/plugins/image/helpers.js +1 -1
  12. package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +4 -2
  13. package/dist/basic-sdk/extension/plugins/image/render-elem.js +5 -3
  14. package/dist/basic-sdk/extension/plugins/image/use-copy-image.js +1 -1
  15. package/dist/basic-sdk/extension/plugins/image/use-upload-image.js +1 -1
  16. package/dist/basic-sdk/extension/plugins/sdoc-link/hover-menu/index.js +4 -2
  17. package/dist/basic-sdk/extension/plugins/table/menu/color-selector-popover/color-item.js +4 -2
  18. package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +3 -2
  19. package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/insert-table-element.js +3 -2
  20. package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +1 -2
  21. package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +1 -1
  22. package/dist/basic-sdk/extension/plugins/text-style/menu/comemnt-editor-menu.js +1 -2
  23. package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +4 -2
  24. package/dist/basic-sdk/extension/plugins/video/render-elem.js +1 -2
  25. package/dist/basic-sdk/extension/toolbar/comment-editor-toolbar/index.js +13 -9
  26. package/dist/basic-sdk/hooks/use-comment.js +23 -12
  27. package/dist/basic-sdk/model/index.js +1 -8
  28. package/dist/basic-sdk/socket/helpers.js +312 -0
  29. package/dist/components/error-boundary/error-page.js +4 -4
  30. package/dist/pages/seafile-comment-editor.js +49 -26
  31. package/package.json +6 -6
  32. package/dist/basic-sdk/model/notification.js +0 -18
  33. package/dist/components/tip-message/index.js +0 -194
  34. 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(); // lazy init context class
60
- // const server = this.getSetting('serviceUrl');
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");
@@ -31,24 +30,22 @@ var _slateToMd = _interopRequireDefault(require("../slate-convert/slate-to-md"))
31
30
  var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
32
31
  var _eventHandler = _interopRequireDefault(require("../utils/event-handler"));
33
32
  require("./comment-editor.css");
34
- const getSubmitTip = (type, content) => {
35
- if (content) return 'Save';
36
- return type === 'comment' ? 'Comment' : 'Reply';
37
- };
33
+ // const getSubmitTip = (type, content) => {
34
+ // if (content) return 'Save';
35
+ // return type === 'comment' ? 'Comment' : 'Reply';
36
+ // };
37
+
38
38
  const DEFAULT_PLACEHOLDER = 'Enter_comment_shift_enter_for_new_line_Enter_to_send';
39
39
  const CommentEditor = _ref => {
40
40
  let {
41
41
  content,
42
- commentContent,
43
42
  placeholder = DEFAULT_PLACEHOLDER,
44
43
  insertContent,
45
- updateContent,
46
44
  onContentChange,
47
- setIsEditing,
48
45
  hiddenComment,
49
46
  hiddenUserInfo,
50
- closeComment,
51
- addParticipants
47
+ toolMenus = ['text_style', _constants2.BLOCKQUOTE, _constants2.UNORDERED_LIST, _constants2.ORDERED_LIST, _constants2.LINK, _constants2.IMAGE],
48
+ closePanel
52
49
  } = _ref;
53
50
  const commentWrapperRef = (0, _react.useRef)();
54
51
  const {
@@ -57,233 +54,221 @@ const CommentEditor = _ref => {
57
54
  const {
58
55
  className,
59
56
  userInfo,
60
- type
57
+ type,
58
+ addParticipants
61
59
  } = (0, _useComment.useComment)();
62
- 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]);
60
+ // const submitTip = useMemo(() => getSubmitTip(type, content), [content, type]);
61
+
62
+ // const document = useMemo(() => {
63
+ // const cursor = {};
64
+ // let elements = null;
65
+ // elements = [generateEmptyElement(PARAGRAPH, { placeholder })];
66
+ // return { elements, cursor };
67
+ // }, [placeholder]);
68
+
69
+ // const [slateValue, setSlateValue] = useState(document.elements);
70
+ // const commentEditorContainerRef = useRef(null);
71
+
72
+ // const editor = useMemo(() => {
73
+ // const defaultEditor = createCommentEditor();
74
+ // const newEditor = withNodeId(defaultEditor);
75
+ // const { cursors } = document;
76
+ // newEditor.cursors = cursors || {};
77
+ // newEditor.width = COMMENT_EDITOR_EDIT_AREA_WIDTH; // default width
78
+ // newEditor.editorType = COMMENT_EDITOR;
79
+
80
+ // return newEditor;
81
+ // }, [document]);
82
+
83
+ // const { cursors } = useCursors(editor);
84
+ // const decorate = usePipDecorate(editor);
85
+ // // init eventHandler
86
+ // // eslint-disable-next-line react-hooks/exhaustive-deps
87
+ // const eventProxy = useMemo(() => new EventProxy(editor), []);
88
+
89
+ // const onSubmit = useCallback((event) => {
90
+ // event && event.stopPropagation();
91
+
92
+ // const mdString = slateToMdString(editor.children);
93
+ // if (mdString && mdString.trim()) insertContent(mdString);
94
+
95
+ // addParticipants && addParticipants(userInfo.username);
96
+
97
+ // editor.children = [generateEmptyElement(PARAGRAPH, { placeholder })];
98
+ // Transforms.select(editor, Editor.start(editor, []));
99
+
100
+ // onContentChange && onContentChange(null);
101
+ // closePanel && closePanel();
102
+ // // eslint-disable-next-line react-hooks/exhaustive-deps
103
+ // }, [editor, insertContent, addParticipants, placeholder, onContentChange, closePanel]);
104
+
105
+ // const onSubmitByEnterKey = useCallback((event) => {
106
+ // if (!ReactEditor.isFocused(editor)) return;
107
+ // onSubmit(event);
108
+ // }, [editor, onSubmit]);
109
+
110
+ // // addEventListener
111
+ // useEffect(() => {
112
+ // const eventBus = EventBus.getInstance();
113
+ // const unsubscribePostComment = eventBus.subscribe(INTERNAL_EVENT.COMMENT_EDITOR_POST_COMMENT, onSubmitByEnterKey);
114
+
115
+ // return () => {
116
+ // unsubscribePostComment();
117
+ // };
118
+ // }, [onSubmitByEnterKey]);
119
+
120
+ // const onCancel = useCallback((event) => {
121
+ // event.stopPropagation();
122
+ // const { type: eventType, keyCode, target } = event;
123
+ // if (eventType === 'keydown' && keyCode !== KeyCodes.Esc) return;
124
+ // if (eventType === 'click') {
125
+ // const isSdocContentWrapper = target.classList.contains('sdoc-content-wrapper');
126
+ // const listContainer = window.document.querySelector('#global-comment-list-container');
127
+ // const resizeContainer = window.document.querySelector('.sdoc-comment-resize-handler');
128
+ // const isClickOnListContainer = listContainer && listContainer.contains(target);
129
+ // const isClickOnCommentEditorContainer = commentWrapperRef.current.contains(target);
130
+ // const isClickResizeContainer = resizeContainer && resizeContainer.contains(target);
131
+ // const isPreventCancel = isClickOnListContainer || isClickOnCommentEditorContainer || isClickResizeContainer || isSdocContentWrapper;
132
+ // if (isPreventCancel) return;
133
+ // }
134
+ // hiddenComment && hiddenComment(false);
135
+
136
+ // if (onContentChange) {
137
+ // if (editor.children.find(n => Node.string(n).trim())) {
138
+ // onContentChange(slateToMdString(editor.children));
139
+ // } else {
140
+ // onContentChange(null);
141
+ // }
142
+ // }
143
+ // // eslint-disable-next-line react-hooks/exhaustive-deps
144
+ // }, []);
145
+
146
+ // // set editor children
147
+ // useEffect(() => {
148
+ // let children = mdStringToSlate(content);
149
+ // editor.children = children;
150
+ // // Transforms.select(editor, Editor.end(editor, []));
151
+ // }, [editor, content]);
152
+
153
+ // // useMount: focus editor
154
+ // useEffect(() => {
155
+ // const [firstNode] = editor.children;
156
+ // if (firstNode) {
157
+ // const [firstNodeFirstChild] = firstNode.children;
158
+
159
+ // if (firstNodeFirstChild) {
160
+ // const endOfFirstNode = Editor.end(editor, [0, 0]);
161
+ // const range = {
162
+ // anchor: endOfFirstNode,
163
+ // focus: endOfFirstNode,
164
+ // };
165
+ // // focusEditor(editor, range);
166
+ // }
167
+ // // Force refresh to fix comment list
168
+ // // setSlateValue([...editor.children]);
169
+ // }
170
+ // // eslint-disable-next-line react-hooks/exhaustive-deps
171
+ // }, []);
172
+
173
+ // const handleFocusEditor = (e) => {
174
+ // if (e.target === commentEditorContainerRef.current) {
175
+ // const focusPoint = Editor.end(editor, []);
176
+ // focusEditor(editor, focusPoint);
177
+ // }
178
+ // };
179
+
180
+ // const handleScrollIntoView = useCallback((editor, domRange) => {
181
+ // try {
182
+ // const { selection } = editor;
183
+ // // Do not scroll into view, when focus on image
184
+ // const [imageNodeEntry] = Editor.nodes(editor, {
185
+ // match: n => [IMAGE, IMAGE_BLOCK].includes(n.type),
186
+ // at: selection
187
+ // });
188
+ // if (imageNodeEntry) return;
189
+ // const focusedNode = Node.get(editor, selection.focus.path);
190
+ // const domNode = ReactEditor.toDOMNode(editor, focusedNode);
191
+ // if (!domNode) return;
192
+ // scrollIntoView(domNode, { 'scrollMode': 'if-needed' });
193
+ // } catch (error) {
194
+ // //
195
+ // }
196
+ // }, []);
197
+
198
+ // const onMouseDown = useCallback((event) => {
199
+ // if (event.button === 0) {
200
+ // // Compatible with the editor which unload table plugin
201
+ // editor.reSetTableSelectedRange && editor.reSetTableSelectedRange();
202
+ // const eventBus = EventBus.getInstance();
203
+ // eventBus.dispatch(INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
204
+ // }
205
+ // // eslint-disable-next-line react-hooks/exhaustive-deps
206
+ // }, []);
207
+
208
+ // const onKeyDown = useCallback((event) => {
209
+ // if (isHotkey('enter', event)) {
210
+ // event.preventDefault();
211
+ // const eventBus = EventBus.getInstance();
212
+ // eventBus.dispatch(INTERNAL_EVENT.COMMENT_EDITOR_POST_COMMENT, event);
213
+ // return;
214
+ // }
215
+
216
+ // if (isHotkey('shift+enter', event)) {
217
+ // event.preventDefault();
218
+ // Editor.insertBreak(editor);
219
+ // return;
220
+ // }
115
221
 
116
- // addEventListener
117
- (0, _react.useEffect)(() => {
118
- const eventBus = _eventBus.default.getInstance();
119
- const unsubscribePostComment = eventBus.subscribe(_constants.INTERNAL_EVENT.COMMENT_EDITOR_POST_COMMENT, onSubmitByEnterKey);
120
- return () => {
121
- unsubscribePostComment();
122
- };
123
- }, [onSubmitByEnterKey]);
124
- const onCancel = (0, _react.useCallback)(event => {
125
- event.stopPropagation();
126
- const {
127
- type: eventType,
128
- keyCode,
129
- target
130
- } = event;
131
- if (eventType === 'keydown' && keyCode !== _constants.KeyCodes.Esc) return;
132
- if (eventType === 'click') {
133
- const isSdocContentWrapper = target.classList.contains('sdoc-content-wrapper');
134
- const listContainer = window.document.querySelector('#global-comment-list-container');
135
- const resizeContainer = window.document.querySelector('.sdoc-comment-resize-handler');
136
- const isClickOnListContainer = listContainer && listContainer.contains(target);
137
- const isClickOnCommentEditorContainer = commentWrapperRef.current.contains(target);
138
- const isClickResizeContainer = resizeContainer && resizeContainer.contains(target);
139
- const isPreventCancel = isClickOnListContainer || isClickOnCommentEditorContainer || isClickResizeContainer || isSdocContentWrapper;
140
- if (isPreventCancel) return;
141
- }
142
- setIsEditing && setIsEditing(false);
143
- hiddenComment && hiddenComment(false);
144
- if (onContentChange) {
145
- if (editor.children.find(n => _slate.Node.string(n).trim())) {
146
- onContentChange((0, _slateToMd.default)(editor.children));
147
- } else {
148
- onContentChange(null);
149
- }
150
- }
151
- // eslint-disable-next-line react-hooks/exhaustive-deps
152
- }, [setIsEditing]);
222
+ // eventProxy.onKeyDown(event);
153
223
 
154
- // set editor children
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]);
224
+ // }, [eventProxy, editor]);
163
225
 
164
- // useMount: focus editor
165
- (0, _react.useEffect)(() => {
166
- const [firstNode] = editor.children;
167
- if (firstNode) {
168
- const [firstNodeFirstChild] = firstNode.children;
169
- if (firstNodeFirstChild) {
170
- const endOfFirstNode = _slate.Editor.end(editor, [0, 0]);
171
- const range = {
172
- anchor: endOfFirstNode,
173
- focus: endOfFirstNode
174
- };
175
- (0, _core.focusEditor)(editor, range);
176
- }
177
- // Force refresh to fix comment list
178
- setSlateValue([...editor.children]);
179
- }
180
- // eslint-disable-next-line react-hooks/exhaustive-deps
181
- }, []);
182
- const handleFocusEditor = e => {
183
- if (e.target === commentEditorContainerRef.current) {
184
- const focusPoint = _slate.Editor.end(editor, []);
185
- (0, _core.focusEditor)(editor, focusPoint);
186
- }
187
- };
188
- const handleScrollIntoView = (0, _react.useCallback)((editor, domRange) => {
189
- try {
190
- const {
191
- selection
192
- } = editor;
193
- // Do not scroll into view, when focus on image
194
- const [imageNodeEntry] = _slate.Editor.nodes(editor, {
195
- match: n => [_constants2.IMAGE, _constants2.IMAGE_BLOCK].includes(n.type),
196
- at: selection
197
- });
198
- if (imageNodeEntry) return;
199
- const focusedNode = _slate.Node.get(editor, selection.focus.path);
200
- const domNode = _slateReact.ReactEditor.toDOMNode(editor, focusedNode);
201
- if (!domNode) return;
202
- (0, _scrollIntoViewIfNeeded.default)(domNode, {
203
- 'scrollMode': 'if-needed'
204
- });
205
- } catch (error) {
206
- //
207
- }
208
- }, []);
209
- const onMouseDown = (0, _react.useCallback)(event => {
210
- if (event.button === 0) {
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
- }));
226
+ console.log('toolMenus', toolMenus);
227
+ return /*#__PURE__*/_react.default.createElement("div", null, "123")
228
+ // <div className={classNames('comment-editor-wrapper', className)} ref={commentWrapperRef}>
229
+ // {type === 'comment' && !hiddenUserInfo && (
230
+ // <div className="comment-editor-user-info">
231
+ // <div className="comment-editor-user-img">
232
+ // <img src={userInfo.avatar_url} alt="" height="100%" width="100%" />
233
+ // </div>
234
+ // <div className="comment-editor-user-name">{userInfo.name}</div>
235
+ // </div>
236
+ // )}
237
+ // <div className='comment-editor-container'>
238
+ // <div className="comment-editor-content">
239
+ // <div ref={commentEditorContainerRef} className='article comment-editor' onClick={handleFocusEditor} >
240
+ // <ScrollContext.Provider value={{ scrollRef: commentEditorContainerRef }}>
241
+ // <Slate editor={editor} value={slateValue} onChange={setSlateValue}>
242
+ // <Editable
243
+ // id='sdoc-editor'
244
+ // scrollSelectionIntoView={handleScrollIntoView}
245
+ // cursors={cursors}
246
+ // renderElement={(props) => RenderCommentEditorCustomRenderElement({ ...props, commentType: type })}
247
+ // renderLeaf={renderLeaf}
248
+ // onMouseDown={onMouseDown}
249
+ // decorate={decorate}
250
+ // onCut={eventProxy.onCut}
251
+ // onCopy={eventProxy.onCopy}
252
+ // onCompositionStart={eventProxy.onCompositionStart}
253
+ // onCompositionUpdate={eventProxy.onCompositionUpdate}
254
+ // onCompositionEnd={eventProxy.onCompositionEnd}
255
+ // onKeyDown={onKeyDown}
256
+ // onBeforeInput={eventProxy.onBeforeInput}
257
+ // />
258
+ // </Slate>
259
+ // </ScrollContext.Provider>
260
+ // </div>
261
+ // <CommentEditorToolbar
262
+ // editor={editor}
263
+ // toolMenus={toolMenus}
264
+ // onSubmit={onSubmit}
265
+ // submitBtnText={t(submitTip)}
266
+ // onCancel={onCancel}
267
+ // />
268
+ // </div>
269
+ // </div>
270
+ // {toolMenus.includes(IMAGE) && <InsertElementDialog editor={editor} />}
271
+ // </div>
272
+ ;
288
273
  };
289
274
  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 = (0, _reactI18next.withTranslation)('sdoc-editor')(ColorItem);
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 = (0, _reactI18next.withTranslation)('sdoc-editor')(ColorMenu);
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 = (0, _reactI18next.withTranslation)('seafile-editor')(FieldSetting);
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 = (0, _reactI18next.withTranslation)('sdoc-editor')(LocalFiles);
193
+ var _default = exports.default = LocalFiles;