@seafile/comment-editor 0.0.1-alpha.53 → 0.0.1-alpha.54
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,9 @@ 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
|
-
// <div className="comment-editor-user-img">
|
|
228
|
-
// <img src={userInfo.avatar_url} alt="" height="100%" width="100%" />
|
|
229
|
-
// </div>
|
|
230
|
-
// <div className="comment-editor-user-name">{userInfo.name}</div>
|
|
231
|
-
// </div>
|
|
232
|
-
// )}
|
|
233
|
-
// <div className='comment-editor-container'>
|
|
234
|
-
// <div className="comment-editor-content">
|
|
235
|
-
// <div ref={commentEditorContainerRef} className='article comment-editor' onClick={handleFocusEditor} >
|
|
236
|
-
// <ScrollContext.Provider value={{ scrollRef: commentEditorContainerRef }}>
|
|
237
|
-
// <Slate editor={editor} value={slateValue} onChange={setSlateValue}>
|
|
238
|
-
// <Editable
|
|
239
|
-
// id='sdoc-editor'
|
|
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
|
+
});
|
|
269
225
|
};
|
|
270
226
|
var _default = exports.default = CommentEditor;
|