@seafile/comment-editor 0.0.1-alpha.17 → 0.0.1-alpha.19
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
|
-
|
|
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
|
|
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);
|
|
@@ -140,8 +143,10 @@ const CommentEditor = _ref => {
|
|
|
140
143
|
hiddenComment && hiddenComment(false);
|
|
141
144
|
if (onContentChange) {
|
|
142
145
|
if (editor.children.find(n => _slate.Node.string(n).trim())) {
|
|
146
|
+
console.log(11);
|
|
143
147
|
onContentChange((0, _slateToMd.default)(editor.children));
|
|
144
148
|
} else {
|
|
149
|
+
console.log(22);
|
|
145
150
|
onContentChange(null);
|
|
146
151
|
}
|
|
147
152
|
}
|
|
@@ -151,6 +156,7 @@ const CommentEditor = _ref => {
|
|
|
151
156
|
// set editor children
|
|
152
157
|
(0, _react.useEffect)(() => {
|
|
153
158
|
let children = (0, _mdToSlate.default)(content);
|
|
159
|
+
console.log('children', children);
|
|
154
160
|
editor.children = children;
|
|
155
161
|
_slate.Transforms.select(editor, _slate.Editor.end(editor, []));
|
|
156
162
|
}, [editor, content]);
|