@seafile/comment-editor 0.0.1-alpha.53 → 0.0.1-alpha.55
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.
|
@@ -143,32 +143,30 @@ const CommentEditor = _ref => {
|
|
|
143
143
|
}, []);
|
|
144
144
|
|
|
145
145
|
// set editor children
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// // useMount: focus editor
|
|
153
|
-
// useEffect(() => {
|
|
154
|
-
// const [firstNode] = editor.children;
|
|
155
|
-
// if (firstNode) {
|
|
156
|
-
// const [firstNodeFirstChild] = firstNode.children;
|
|
157
|
-
|
|
158
|
-
// if (firstNodeFirstChild) {
|
|
159
|
-
// const endOfFirstNode = Editor.end(editor, [0, 0]);
|
|
160
|
-
// const range = {
|
|
161
|
-
// anchor: endOfFirstNode,
|
|
162
|
-
// focus: endOfFirstNode,
|
|
163
|
-
// };
|
|
164
|
-
// focusEditor(editor, range);
|
|
165
|
-
// }
|
|
166
|
-
// // Force refresh to fix comment list
|
|
167
|
-
// setSlateValue([...editor.children]);
|
|
168
|
-
// }
|
|
169
|
-
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
170
|
-
// }, []);
|
|
146
|
+
(0, _react.useEffect)(() => {
|
|
147
|
+
let children = (0, _mdToSlate.default)(content);
|
|
148
|
+
editor.children = children;
|
|
149
|
+
// Transforms.select(editor, Editor.end(editor, []));
|
|
150
|
+
}, [editor, content]);
|
|
171
151
|
|
|
152
|
+
// useMount: focus editor
|
|
153
|
+
(0, _react.useEffect)(() => {
|
|
154
|
+
const [firstNode] = editor.children;
|
|
155
|
+
if (firstNode) {
|
|
156
|
+
const [firstNodeFirstChild] = firstNode.children;
|
|
157
|
+
if (firstNodeFirstChild) {
|
|
158
|
+
const endOfFirstNode = _slate.Editor.end(editor, [0, 0]);
|
|
159
|
+
const range = {
|
|
160
|
+
anchor: endOfFirstNode,
|
|
161
|
+
focus: endOfFirstNode
|
|
162
|
+
};
|
|
163
|
+
// focusEditor(editor, range);
|
|
164
|
+
}
|
|
165
|
+
// Force refresh to fix comment list
|
|
166
|
+
// setSlateValue([...editor.children]);
|
|
167
|
+
}
|
|
168
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
169
|
+
}, []);
|
|
172
170
|
const handleFocusEditor = e => {
|
|
173
171
|
if (e.target === commentEditorContainerRef.current) {
|
|
174
172
|
const focusPoint = _slate.Editor.end(editor, []);
|
|
@@ -220,51 +218,22 @@ const CommentEditor = _ref => {
|
|
|
220
218
|
eventProxy.onKeyDown(event);
|
|
221
219
|
}, [eventProxy, editor]);
|
|
222
220
|
console.log('toolMenus', toolMenus);
|
|
223
|
-
return /*#__PURE__*/_react.default.createElement("div",
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
// scrollSelectionIntoView={handleScrollIntoView}
|
|
241
|
-
// cursors={cursors}
|
|
242
|
-
// renderElement={(props) => RenderCommentEditorCustomRenderElement({ ...props, commentType: type })}
|
|
243
|
-
// renderLeaf={renderLeaf}
|
|
244
|
-
// onMouseDown={onMouseDown}
|
|
245
|
-
// decorate={decorate}
|
|
246
|
-
// onCut={eventProxy.onCut}
|
|
247
|
-
// onCopy={eventProxy.onCopy}
|
|
248
|
-
// onCompositionStart={eventProxy.onCompositionStart}
|
|
249
|
-
// onCompositionUpdate={eventProxy.onCompositionUpdate}
|
|
250
|
-
// onCompositionEnd={eventProxy.onCompositionEnd}
|
|
251
|
-
// onKeyDown={onKeyDown}
|
|
252
|
-
// onBeforeInput={eventProxy.onBeforeInput}
|
|
253
|
-
// />
|
|
254
|
-
// </Slate>
|
|
255
|
-
// </ScrollContext.Provider>
|
|
256
|
-
// </div>
|
|
257
|
-
// <CommentEditorToolbar
|
|
258
|
-
// editor={editor}
|
|
259
|
-
// toolMenus={toolMenus}
|
|
260
|
-
// onSubmit={onSubmit}
|
|
261
|
-
// submitBtnText={t(submitTip)}
|
|
262
|
-
// onCancel={onCancel}
|
|
263
|
-
// />
|
|
264
|
-
// </div>
|
|
265
|
-
// </div>
|
|
266
|
-
// {toolMenus.includes(IMAGE) && <InsertElementDialog editor={editor} />} */}
|
|
267
|
-
// </div>
|
|
268
|
-
;
|
|
221
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
222
|
+
className: (0, _classnames.default)('comment-editor-wrapper', className),
|
|
223
|
+
ref: commentWrapperRef
|
|
224
|
+
}, type === 'comment' && !hiddenUserInfo && /*#__PURE__*/_react.default.createElement("div", {
|
|
225
|
+
className: "comment-editor-user-info"
|
|
226
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
227
|
+
className: "comment-editor-user-img"
|
|
228
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
229
|
+
src: userInfo.avatar_url,
|
|
230
|
+
alt: "",
|
|
231
|
+
height: "100%",
|
|
232
|
+
width: "100%"
|
|
233
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
234
|
+
className: "comment-editor-user-name"
|
|
235
|
+
}, userInfo.name)), toolMenus.includes(_constants2.IMAGE) && /*#__PURE__*/_react.default.createElement(_insertElementDialog.default, {
|
|
236
|
+
editor: editor
|
|
237
|
+
}));
|
|
269
238
|
};
|
|
270
239
|
var _default = exports.default = CommentEditor;
|