@seafile/comment-editor 0.0.1-alpha.59 → 0.0.1-alpha.60
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.
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactI18next = require("react-i18next");
|
|
10
11
|
var _slate = require("@seafile/slate");
|
|
11
12
|
var _slateReact = require("@seafile/slate-react");
|
|
12
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -29,8 +30,6 @@ var _slateToMd = _interopRequireDefault(require("../slate-convert/slate-to-md"))
|
|
|
29
30
|
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
30
31
|
var _eventHandler = _interopRequireDefault(require("../utils/event-handler"));
|
|
31
32
|
require("./comment-editor.css");
|
|
32
|
-
// import { useTranslation } from 'react-i18next';
|
|
33
|
-
|
|
34
33
|
const getSubmitTip = (type, content) => {
|
|
35
34
|
if (content) return 'Save';
|
|
36
35
|
return type === 'comment' ? 'Comment' : 'Reply';
|
|
@@ -48,7 +47,9 @@ const CommentEditor = _ref => {
|
|
|
48
47
|
closePanel
|
|
49
48
|
} = _ref;
|
|
50
49
|
const commentWrapperRef = (0, _react.useRef)();
|
|
51
|
-
|
|
50
|
+
const {
|
|
51
|
+
t
|
|
52
|
+
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
52
53
|
const {
|
|
53
54
|
className,
|
|
54
55
|
userInfo,
|
|
@@ -146,7 +147,7 @@ const CommentEditor = _ref => {
|
|
|
146
147
|
(0, _react.useEffect)(() => {
|
|
147
148
|
let children = (0, _mdToSlate.default)(content);
|
|
148
149
|
editor.children = children;
|
|
149
|
-
|
|
150
|
+
_slate.Transforms.select(editor, _slate.Editor.end(editor, []));
|
|
150
151
|
}, [editor, content]);
|
|
151
152
|
|
|
152
153
|
// useMount: focus editor
|
|
@@ -160,10 +161,10 @@ const CommentEditor = _ref => {
|
|
|
160
161
|
anchor: endOfFirstNode,
|
|
161
162
|
focus: endOfFirstNode
|
|
162
163
|
};
|
|
163
|
-
|
|
164
|
+
(0, _core.focusEditor)(editor, range);
|
|
164
165
|
}
|
|
165
166
|
// Force refresh to fix comment list
|
|
166
|
-
|
|
167
|
+
setSlateValue([...editor.children]);
|
|
167
168
|
}
|
|
168
169
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
169
170
|
}, []);
|
|
@@ -232,8 +233,46 @@ const CommentEditor = _ref => {
|
|
|
232
233
|
width: "100%"
|
|
233
234
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
234
235
|
className: "comment-editor-user-name"
|
|
235
|
-
}, userInfo.name)),
|
|
236
|
-
|
|
237
|
-
}
|
|
236
|
+
}, userInfo.name)), /*#__PURE__*/_react.default.createElement("div", {
|
|
237
|
+
className: "comment-editor-container"
|
|
238
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
239
|
+
className: "comment-editor-content"
|
|
240
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
241
|
+
ref: commentEditorContainerRef,
|
|
242
|
+
className: "article comment-editor",
|
|
243
|
+
onClick: handleFocusEditor
|
|
244
|
+
}, /*#__PURE__*/_react.default.createElement(_useScrollContext.ScrollContext.Provider, {
|
|
245
|
+
value: {
|
|
246
|
+
scrollRef: commentEditorContainerRef
|
|
247
|
+
}
|
|
248
|
+
}, /*#__PURE__*/_react.default.createElement(_slateReact.Slate, {
|
|
249
|
+
editor: editor,
|
|
250
|
+
value: slateValue,
|
|
251
|
+
onChange: setSlateValue
|
|
252
|
+
}, /*#__PURE__*/_react.default.createElement(_slateReact.Editable, {
|
|
253
|
+
id: "sdoc-editor",
|
|
254
|
+
scrollSelectionIntoView: handleScrollIntoView,
|
|
255
|
+
cursors: cursors,
|
|
256
|
+
renderElement: props => (0, _renderCommentEditorElement.default)({
|
|
257
|
+
...props,
|
|
258
|
+
commentType: type
|
|
259
|
+
}),
|
|
260
|
+
renderLeaf: _extension.renderLeaf,
|
|
261
|
+
onMouseDown: onMouseDown,
|
|
262
|
+
decorate: decorate,
|
|
263
|
+
onCut: eventProxy.onCut,
|
|
264
|
+
onCopy: eventProxy.onCopy,
|
|
265
|
+
onCompositionStart: eventProxy.onCompositionStart,
|
|
266
|
+
onCompositionUpdate: eventProxy.onCompositionUpdate,
|
|
267
|
+
onCompositionEnd: eventProxy.onCompositionEnd,
|
|
268
|
+
onKeyDown: onKeyDown,
|
|
269
|
+
onBeforeInput: eventProxy.onBeforeInput
|
|
270
|
+
})))), /*#__PURE__*/_react.default.createElement(_commentEditorToolbar.default, {
|
|
271
|
+
editor: editor,
|
|
272
|
+
toolMenus: toolMenus,
|
|
273
|
+
onSubmit: onSubmit,
|
|
274
|
+
submitBtnText: t(submitTip),
|
|
275
|
+
onCancel: onCancel
|
|
276
|
+
}))));
|
|
238
277
|
};
|
|
239
278
|
var _default = exports.default = CommentEditor;
|