@seafile/comment-editor 0.0.1-alpha.16 → 0.0.1-alpha.18

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.
@@ -91,12 +91,15 @@ const CommentEditor = _ref => {
91
91
  // init eventHandler
92
92
  // eslint-disable-next-line react-hooks/exhaustive-deps
93
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]);
94
99
  const onSubmit = (0, _react.useCallback)(event => {
95
100
  event && event.stopPropagation();
96
101
  const mdString = (0, _slateToMd.default)(editor.children);
97
- if (mdString.trim()) {
98
- content ? insertContent(mdString) : updateContent(mdString);
99
- }
102
+ updateValue(mdString);
100
103
  addParticipants(userInfo.username);
101
104
  editor.children = [(0, _core.generateEmptyElement)(_constants2.PARAGRAPH, {
102
105
  placeholder
@@ -104,7 +107,7 @@ const CommentEditor = _ref => {
104
107
  _slate.Transforms.select(editor, _slate.Editor.start(editor, []));
105
108
  onContentChange && onContentChange(null);
106
109
  closeComment && closeComment();
107
- }, [editor, addParticipants, userInfo.username, placeholder, onContentChange, closeComment, content, insertContent, updateContent]);
110
+ }, [editor, updateValue, addParticipants, userInfo.username, placeholder, onContentChange, closeComment]);
108
111
  const onSubmitByEnterKey = (0, _react.useCallback)(event => {
109
112
  if (!_slateReact.ReactEditor.isFocused(editor)) return;
110
113
  onSubmit(event);
@@ -119,7 +122,6 @@ const CommentEditor = _ref => {
119
122
  };
120
123
  }, [onSubmitByEnterKey]);
121
124
  const onCancel = (0, _react.useCallback)(event => {
122
- console.log('onCancel');
123
125
  event.stopPropagation();
124
126
  const {
125
127
  type: eventType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/comment-editor",
3
- "version": "0.0.1-alpha.16",
3
+ "version": "0.0.1-alpha.18",
4
4
  "private": false,
5
5
  "description": "This is a comment editor",
6
6
  "main": "dist/index.js",