@seafile/comment-editor 0.0.1-alpha.24 → 0.0.1-alpha.26

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.
@@ -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,8 +48,8 @@ class Context {
55
48
  this.api = null;
56
49
  this.config = null;
57
50
  }
58
- init(api) {
59
- this.initSettings(); // lazy init context class
51
+ init(settings, api) {
52
+ this.initSettings(settings); // lazy init context class
60
53
  this.api = api;
61
54
  // const server = this.getSetting('serviceUrl');
62
55
  // const token = this.getSetting('accessToken');
@@ -43,6 +43,7 @@ const CommentEditor = _ref => {
43
43
  onContentChange,
44
44
  hiddenComment,
45
45
  hiddenUserInfo,
46
+ hiddenToolMenu,
46
47
  closePanel,
47
48
  addParticipants
48
49
  } = _ref;
@@ -91,14 +92,15 @@ const CommentEditor = _ref => {
91
92
  event && event.stopPropagation();
92
93
  const mdString = (0, _slateToMd.default)(editor.children);
93
94
  if (mdString && mdString.trim()) insertContent(mdString);
94
- addParticipants(userInfo.username);
95
+ addParticipants && addParticipants(userInfo.username);
95
96
  editor.children = [(0, _core.generateEmptyElement)(_constants2.PARAGRAPH, {
96
97
  placeholder
97
98
  })];
98
99
  _slate.Transforms.select(editor, _slate.Editor.start(editor, []));
99
100
  onContentChange && onContentChange(null);
100
101
  closePanel && closePanel();
101
- }, [editor, insertContent, addParticipants, userInfo.username, placeholder, onContentChange, closePanel]);
102
+ // eslint-disable-next-line react-hooks/exhaustive-deps
103
+ }, [editor, insertContent, addParticipants, placeholder, onContentChange, closePanel]);
102
104
  const onSubmitByEnterKey = (0, _react.useCallback)(event => {
103
105
  if (!_slateReact.ReactEditor.isFocused(editor)) return;
104
106
  onSubmit(event);
@@ -130,7 +132,7 @@ const CommentEditor = _ref => {
130
132
  const isPreventCancel = isClickOnListContainer || isClickOnCommentEditorContainer || isClickResizeContainer || isSdocContentWrapper;
131
133
  if (isPreventCancel) return;
132
134
  }
133
- hiddenComment(false);
135
+ hiddenComment && hiddenComment(false);
134
136
  if (onContentChange) {
135
137
  if (editor.children.find(n => _slate.Node.string(n).trim())) {
136
138
  onContentChange((0, _slateToMd.default)(editor.children));
@@ -266,6 +268,7 @@ const CommentEditor = _ref => {
266
268
  onBeforeInput: eventProxy.onBeforeInput
267
269
  })))), /*#__PURE__*/_react.default.createElement(_commentEditorToolbar.default, {
268
270
  editor: editor,
271
+ hiddenToolMenu: hiddenToolMenu,
269
272
  onSubmit: onSubmit,
270
273
  submitBtnText: t(submitTip),
271
274
  onCancel: onCancel
@@ -22,13 +22,14 @@ const CommentEditorToolbar = _ref => {
22
22
  readonly = false,
23
23
  onSubmit,
24
24
  submitBtnText,
25
- onCancel
25
+ onCancel,
26
+ hiddenToolMenu
26
27
  } = _ref;
27
28
  (0, _useSelectionUpdate.default)();
28
29
  const eventBus = _eventBus.default.getInstance();
29
30
  return /*#__PURE__*/_react.default.createElement("div", {
30
31
  className: "comment-editor-toolbar"
31
- }, /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, {
32
+ }, !hiddenToolMenu && /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, {
32
33
  className: "menu-group comment-editor-menu-group"
33
34
  }, /*#__PURE__*/_react.default.createElement(_comemntEditorMenu.default, {
34
35
  editor: editor,
@@ -26,12 +26,14 @@ const SeafileCommentEditor = _ref => {
26
26
  onContentChange,
27
27
  hiddenUserInfo,
28
28
  hiddenComment,
29
+ hiddenToolMenu,
29
30
  closePanel,
30
31
  addParticipants,
31
- // api
32
+ // settings
33
+ settings,
32
34
  api
33
35
  } = _ref;
34
- _basicSdk.context.init(api);
36
+ _basicSdk.context.init(settings, api);
35
37
  return /*#__PURE__*/_react.default.createElement(_errorBoundary.default, null, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentProvider, {
36
38
  type: type,
37
39
  userInfo: userInfo,
@@ -45,6 +47,7 @@ const SeafileCommentEditor = _ref => {
45
47
  onContentChange: onContentChange,
46
48
  hiddenUserInfo: hiddenUserInfo,
47
49
  hiddenComment: hiddenComment,
50
+ hiddenToolMenu: hiddenToolMenu,
48
51
  closePanel: closePanel,
49
52
  addParticipants: addParticipants
50
53
  })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/comment-editor",
3
- "version": "0.0.1-alpha.24",
3
+ "version": "0.0.1-alpha.26",
4
4
  "private": false,
5
5
  "description": "This is a comment editor",
6
6
  "main": "dist/index.js",