@seafile/comment-editor 0.0.1-alpha.20 → 0.0.1-alpha.22
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.
|
@@ -37,15 +37,10 @@ const getSubmitTip = (type, content) => {
|
|
|
37
37
|
const DEFAULT_PLACEHOLDER = 'Enter_comment_shift_enter_for_new_line_Enter_to_send';
|
|
38
38
|
const CommentEditor = _ref => {
|
|
39
39
|
let {
|
|
40
|
-
commentContent,
|
|
41
40
|
content,
|
|
42
41
|
placeholder = DEFAULT_PLACEHOLDER,
|
|
43
42
|
insertContent,
|
|
44
|
-
// add
|
|
45
|
-
updateContent,
|
|
46
|
-
// edit
|
|
47
43
|
onContentChange,
|
|
48
|
-
setIsEditing,
|
|
49
44
|
hiddenComment,
|
|
50
45
|
hiddenUserInfo,
|
|
51
46
|
closeComment,
|
|
@@ -92,15 +87,10 @@ const CommentEditor = _ref => {
|
|
|
92
87
|
// init eventHandler
|
|
93
88
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
89
|
const eventProxy = (0, _react.useMemo)(() => new _eventHandler.default(editor), []);
|
|
95
|
-
const updateValue = (0, _react.useCallback)(value => {
|
|
96
|
-
if (!value || value.trim() === '') return;
|
|
97
|
-
if (!content) return insertContent(value);
|
|
98
|
-
updateContent && updateContent(value);
|
|
99
|
-
}, [content, insertContent, updateContent]);
|
|
100
90
|
const onSubmit = (0, _react.useCallback)(event => {
|
|
101
91
|
event && event.stopPropagation();
|
|
102
92
|
const mdString = (0, _slateToMd.default)(editor.children);
|
|
103
|
-
|
|
93
|
+
if (mdString && mdString.trim()) insertContent(mdString);
|
|
104
94
|
addParticipants(userInfo.username);
|
|
105
95
|
editor.children = [(0, _core.generateEmptyElement)(_constants2.PARAGRAPH, {
|
|
106
96
|
placeholder
|
|
@@ -108,7 +98,7 @@ const CommentEditor = _ref => {
|
|
|
108
98
|
_slate.Transforms.select(editor, _slate.Editor.start(editor, []));
|
|
109
99
|
onContentChange && onContentChange(null);
|
|
110
100
|
closeComment && closeComment();
|
|
111
|
-
}, [editor,
|
|
101
|
+
}, [editor, insertContent, addParticipants, userInfo.username, placeholder, onContentChange, closeComment]);
|
|
112
102
|
const onSubmitByEnterKey = (0, _react.useCallback)(event => {
|
|
113
103
|
if (!_slateReact.ReactEditor.isFocused(editor)) return;
|
|
114
104
|
onSubmit(event);
|
|
@@ -140,27 +130,20 @@ const CommentEditor = _ref => {
|
|
|
140
130
|
const isPreventCancel = isClickOnListContainer || isClickOnCommentEditorContainer || isClickResizeContainer || isSdocContentWrapper;
|
|
141
131
|
if (isPreventCancel) return;
|
|
142
132
|
}
|
|
143
|
-
setIsEditing && setIsEditing(false);
|
|
144
133
|
hiddenComment && hiddenComment(false);
|
|
145
134
|
if (onContentChange) {
|
|
146
135
|
if (editor.children.find(n => _slate.Node.string(n).trim())) {
|
|
147
|
-
console.log(11);
|
|
148
136
|
onContentChange((0, _slateToMd.default)(editor.children));
|
|
149
137
|
} else {
|
|
150
|
-
console.log(22);
|
|
151
138
|
onContentChange(null);
|
|
152
139
|
}
|
|
153
140
|
}
|
|
154
141
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
155
|
-
}, [
|
|
142
|
+
}, []);
|
|
156
143
|
|
|
157
144
|
// set editor children
|
|
158
145
|
(0, _react.useEffect)(() => {
|
|
159
146
|
let children = (0, _mdToSlate.default)(content);
|
|
160
|
-
if (commentContent) {
|
|
161
|
-
children = (0, _mdToSlate.default)(commentContent);
|
|
162
|
-
}
|
|
163
|
-
console.log('children', children);
|
|
164
147
|
editor.children = children;
|
|
165
148
|
_slate.Transforms.select(editor, _slate.Editor.end(editor, []));
|
|
166
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
29
|
closeComment,
|
|
31
|
-
setIsEditing,
|
|
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
48
|
closeComment: closeComment,
|
|
52
|
-
setIsEditing: setIsEditing,
|
|
53
49
|
addParticipants: addParticipants
|
|
54
50
|
})));
|
|
55
51
|
};
|