@seafile/comment-editor 0.0.1-alpha.21 → 0.0.1-alpha.23

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.
@@ -40,14 +40,10 @@ const CommentEditor = _ref => {
40
40
  content,
41
41
  placeholder = DEFAULT_PLACEHOLDER,
42
42
  insertContent,
43
- // add
44
- updateContent,
45
- // edit
46
43
  onContentChange,
47
- setIsEditing,
48
44
  hiddenComment,
49
45
  hiddenUserInfo,
50
- closeComment,
46
+ closePanel,
51
47
  addParticipants
52
48
  } = _ref;
53
49
  const commentWrapperRef = (0, _react.useRef)();
@@ -91,25 +87,18 @@ const CommentEditor = _ref => {
91
87
  // init eventHandler
92
88
  // eslint-disable-next-line react-hooks/exhaustive-deps
93
89
  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
90
  const onSubmit = (0, _react.useCallback)(event => {
100
91
  event && event.stopPropagation();
101
92
  const mdString = (0, _slateToMd.default)(editor.children);
102
93
  if (mdString && mdString.trim()) insertContent(mdString);
103
- // updateValue(mdString);
104
-
105
94
  addParticipants(userInfo.username);
106
95
  editor.children = [(0, _core.generateEmptyElement)(_constants2.PARAGRAPH, {
107
96
  placeholder
108
97
  })];
109
98
  _slate.Transforms.select(editor, _slate.Editor.start(editor, []));
110
99
  onContentChange && onContentChange(null);
111
- closeComment && closeComment();
112
- }, [editor, insertContent, addParticipants, userInfo.username, placeholder, onContentChange, closeComment]);
100
+ closePanel && closePanel();
101
+ }, [editor, insertContent, addParticipants, userInfo.username, placeholder, onContentChange, closePanel]);
113
102
  const onSubmitByEnterKey = (0, _react.useCallback)(event => {
114
103
  if (!_slateReact.ReactEditor.isFocused(editor)) return;
115
104
  onSubmit(event);
@@ -141,24 +130,20 @@ const CommentEditor = _ref => {
141
130
  const isPreventCancel = isClickOnListContainer || isClickOnCommentEditorContainer || isClickResizeContainer || isSdocContentWrapper;
142
131
  if (isPreventCancel) return;
143
132
  }
144
- setIsEditing && setIsEditing(false);
145
- hiddenComment && hiddenComment(false);
133
+ hiddenComment(false);
146
134
  if (onContentChange) {
147
135
  if (editor.children.find(n => _slate.Node.string(n).trim())) {
148
- console.log(11);
149
136
  onContentChange((0, _slateToMd.default)(editor.children));
150
137
  } else {
151
- console.log(22);
152
138
  onContentChange(null);
153
139
  }
154
140
  }
155
141
  // eslint-disable-next-line react-hooks/exhaustive-deps
156
- }, [setIsEditing]);
142
+ }, []);
157
143
 
158
144
  // set editor children
159
145
  (0, _react.useEffect)(() => {
160
146
  let children = (0, _mdToSlate.default)(content);
161
- console.log('children', children);
162
147
  editor.children = children;
163
148
  _slate.Transforms.select(editor, _slate.Editor.end(editor, []));
164
149
  }, [editor, content]);
@@ -22,13 +22,11 @@ const SeafileCommentEditor = _ref => {
22
22
  pluginEvent,
23
23
  // Comment editor
24
24
  content,
25
- updateContent,
26
25
  insertContent,
27
26
  onContentChange,
28
27
  hiddenUserInfo,
29
28
  hiddenComment,
30
- closeComment,
31
- setIsEditing,
29
+ closePanel,
32
30
  addParticipants,
33
31
  // api
34
32
  api
@@ -43,13 +41,11 @@ const SeafileCommentEditor = _ref => {
43
41
  pluginEvent: pluginEvent
44
42
  }, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentEditor, {
45
43
  content: content,
46
- updateContent: updateContent,
47
44
  insertContent: insertContent,
48
45
  onContentChange: onContentChange,
49
46
  hiddenUserInfo: hiddenUserInfo,
50
47
  hiddenComment: hiddenComment,
51
- closeComment: closeComment,
52
- setIsEditing: setIsEditing,
48
+ closePanel: closePanel,
53
49
  addParticipants: addParticipants
54
50
  })));
55
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/comment-editor",
3
- "version": "0.0.1-alpha.21",
3
+ "version": "0.0.1-alpha.23",
4
4
  "private": false,
5
5
  "description": "This is a comment editor",
6
6
  "main": "dist/index.js",