@seafile/comment-editor 0.0.1-alpha.41 → 0.0.1-alpha.43

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.
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getI18n = void 0;
8
+ var _reactI18next = require("react-i18next");
9
+ var _i18next = _interopRequireDefault(require("i18next"));
10
+ var _i18nextBrowserLanguagedetector = _interopRequireDefault(require("i18next-browser-languagedetector"));
11
+ var _i18nextHttpBackend = _interopRequireDefault(require("i18next-http-backend"));
12
+ const getI18n = _ref => {
13
+ let {
14
+ lang
15
+ } = _ref;
16
+ _i18next.default.use(_i18nextHttpBackend.default).use(_i18nextBrowserLanguagedetector.default).use(_reactI18next.initReactI18next).init({
17
+ lng: lang,
18
+ fallbackLng: 'en',
19
+ ns: ['sdoc-editor'],
20
+ defaultNS: 'sdoc-editor',
21
+ debug: false,
22
+ // console log if debug: true
23
+
24
+ whitelist: ['en', 'zh_CN', 'fr', 'de', 'cs', 'es', 'es-AR', 'es-MX', 'ru'],
25
+ backend: {
26
+ loadPath: '/public/locales/{{ lng }}/{{ ns }}.json'
27
+ },
28
+ interpolation: {
29
+ escapeValue: false // not needed for react!!
30
+ },
31
+ react: {
32
+ wait: true
33
+ }
34
+ });
35
+ return _i18next.default;
36
+ };
37
+ exports.getI18n = getI18n;
@@ -4,17 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- Object.defineProperty(exports, "Notification", {
8
- enumerable: true,
9
- get: function () {
10
- return _notification.default;
11
- }
12
- });
13
7
  Object.defineProperty(exports, "User", {
14
8
  enumerable: true,
15
9
  get: function () {
16
10
  return _user.default;
17
11
  }
18
12
  });
19
- var _user = _interopRequireDefault(require("./user"));
20
- var _notification = _interopRequireDefault(require("./notification"));
13
+ var _user = _interopRequireDefault(require("./user"));
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _reactI18next = require("react-i18next");
9
10
  var _basicSdk = require("../basic-sdk");
10
- // import ErrorBoundary from '../components/error-boundary';
11
-
11
+ var _i18n = require("../_i18n");
12
+ var _errorBoundary = _interopRequireDefault(require("../components/error-boundary"));
12
13
  const SeafileCommentEditor = _ref => {
13
14
  let {
14
15
  // Provider
@@ -34,30 +35,30 @@ const SeafileCommentEditor = _ref => {
34
35
  settings,
35
36
  api
36
37
  } = _ref;
38
+ const {
39
+ lang
40
+ } = settings || {};
37
41
  _basicSdk.context.init(settings, api);
38
- return (
39
- /*#__PURE__*/
40
- // <ErrorBoundary>
41
- _react.default.createElement(_basicSdk.CommentProvider, {
42
- type: type,
43
- className: className,
44
- pluginName: pluginName,
45
- pluginEventBus: pluginEventBus,
46
- pluginEvent: pluginEvent,
47
- collaborators: collaborators,
48
- participants: participants,
49
- addParticipants: addParticipants
50
- }, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentEditor, {
51
- content: content,
52
- insertContent: insertContent,
53
- onContentChange: onContentChange,
54
- hiddenUserInfo: hiddenUserInfo,
55
- hiddenComment: hiddenComment,
56
- toolMenus: toolMenus,
57
- closePanel: closePanel,
58
- addParticipants: addParticipants
59
- }))
60
- // </ErrorBoundary>
61
- );
42
+ return /*#__PURE__*/_react.default.createElement(_errorBoundary.default, null, /*#__PURE__*/_react.default.createElement(_reactI18next.I18nextProvider, {
43
+ i18n: (0, _i18n.getI18n)(lang || 'en')
44
+ }, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentProvider, {
45
+ type: type,
46
+ className: className,
47
+ pluginName: pluginName,
48
+ pluginEventBus: pluginEventBus,
49
+ pluginEvent: pluginEvent,
50
+ collaborators: collaborators,
51
+ participants: participants,
52
+ addParticipants: addParticipants
53
+ }, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentEditor, {
54
+ content: content,
55
+ insertContent: insertContent,
56
+ onContentChange: onContentChange,
57
+ hiddenUserInfo: hiddenUserInfo,
58
+ hiddenComment: hiddenComment,
59
+ toolMenus: toolMenus,
60
+ closePanel: closePanel,
61
+ addParticipants: addParticipants
62
+ }))));
62
63
  };
63
64
  var _default = exports.default = SeafileCommentEditor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/comment-editor",
3
- "version": "0.0.1-alpha.41",
3
+ "version": "0.0.1-alpha.43",
4
4
  "private": false,
5
5
  "description": "This is a comment editor",
6
6
  "main": "dist/index.js",
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _utils = require("../comment/utils");
8
- class Notification {
9
- constructor(options) {
10
- var _options$detail, _options$detail2, _options$detail3;
11
- this.id = options.id || '';
12
- this.comment_id = (options === null || options === void 0 ? void 0 : (_options$detail = options.detail) === null || _options$detail === void 0 ? void 0 : _options$detail.comment_id) || '';
13
- this.reply_id = (options === null || options === void 0 ? void 0 : (_options$detail2 = options.detail) === null || _options$detail2 === void 0 ? void 0 : _options$detail2.reply_id) || '';
14
- this.type = (options === null || options === void 0 ? void 0 : (_options$detail3 = options.detail) === null || _options$detail3 === void 0 ? void 0 : _options$detail3.msg_type) || '';
15
- this.key = this.type !== 'reply' ? (0, _utils.generatorNotificationKey)(this.comment_id) : (0, _utils.generatorNotificationKey)(this.comment_id, this.reply_id);
16
- }
17
- }
18
- var _default = exports.default = Notification;