@seafile/comment-editor 0.0.1-alpha.15 → 0.0.1-alpha.17
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,7 +40,9 @@ const CommentEditor = _ref => {
|
|
|
40
40
|
content,
|
|
41
41
|
placeholder = DEFAULT_PLACEHOLDER,
|
|
42
42
|
insertContent,
|
|
43
|
+
// add
|
|
43
44
|
updateContent,
|
|
45
|
+
// edit
|
|
44
46
|
onContentChange,
|
|
45
47
|
setIsEditing,
|
|
46
48
|
hiddenComment,
|
|
@@ -89,15 +91,12 @@ const CommentEditor = _ref => {
|
|
|
89
91
|
// init eventHandler
|
|
90
92
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
93
|
const eventProxy = (0, _react.useMemo)(() => new _eventHandler.default(editor), []);
|
|
92
|
-
const updateValue = (0, _react.useCallback)(value => {
|
|
93
|
-
if (!value || value.trim() === '') return;
|
|
94
|
-
if (!content) return insertContent(value);
|
|
95
|
-
updateContent && updateContent(value);
|
|
96
|
-
}, [content, insertContent, updateContent]);
|
|
97
94
|
const onSubmit = (0, _react.useCallback)(event => {
|
|
98
95
|
event && event.stopPropagation();
|
|
99
96
|
const mdString = (0, _slateToMd.default)(editor.children);
|
|
100
|
-
|
|
97
|
+
if (mdString.trim()) {
|
|
98
|
+
!content ? insertContent(mdString) : updateContent(mdString);
|
|
99
|
+
}
|
|
101
100
|
addParticipants(userInfo.username);
|
|
102
101
|
editor.children = [(0, _core.generateEmptyElement)(_constants2.PARAGRAPH, {
|
|
103
102
|
placeholder
|
|
@@ -105,7 +104,7 @@ const CommentEditor = _ref => {
|
|
|
105
104
|
_slate.Transforms.select(editor, _slate.Editor.start(editor, []));
|
|
106
105
|
onContentChange && onContentChange(null);
|
|
107
106
|
closeComment && closeComment();
|
|
108
|
-
}, [editor,
|
|
107
|
+
}, [editor, addParticipants, userInfo.username, placeholder, onContentChange, closeComment, content, insertContent, updateContent]);
|
|
109
108
|
const onSubmitByEnterKey = (0, _react.useCallback)(event => {
|
|
110
109
|
if (!_slateReact.ReactEditor.isFocused(editor)) return;
|
|
111
110
|
onSubmit(event);
|