@seafile/sdoc-editor 3.0.242 → 3.0.244

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.
@@ -95,19 +95,21 @@ var InsertElementDialog = function InsertElementDialog(_ref) {
95
95
  }
96
96
  // eslint-disable-next-line react-hooks/exhaustive-deps
97
97
  }, [validEditor, uploadLocalImageInputRef, insertPosition, slateNode]);
98
- var handleDisplayAlert = (0, _react.useCallback)(function () {
98
+ var handleDisplayAlert = (0, _react.useCallback)(function (sizeLimit) {
99
99
  setTimeout(function () {
100
- _toast["default"].warning("".concat(t('The_current_version_does_not_support_>5MB_video_file')), {
100
+ _toast["default"].warning(t('The_video_file_exceeds_the_size_limit', {
101
+ size: (0, _index3.formatSeadocVideoSizeLimit)(sizeLimit)
102
+ }), {
101
103
  duration: 3
102
104
  });
103
105
  }, 0);
104
- // eslint-disable-next-line react-hooks/exhaustive-deps
105
- }, []);
106
+ }, [t]);
106
107
  var onVideoFileChanged = (0, _react.useCallback)(function (event) {
107
108
  var files = event.target.files;
108
- // Show warning for 3s and no further insertion if video file is more than 5MB
109
- if (files[0].size > _index3.VIDEO_MAX_SIZE_5MB) {
110
- handleDisplayAlert();
109
+ var videoSizeLimit = (0, _index3.getSeadocVideoSizeLimit)(_context["default"].getSetting('seadocVideoSizeLimit'));
110
+ // Show warning for 3s and no further insertion if the video file exceeds the configured limit.
111
+ if (files[0].size > videoSizeLimit) {
112
+ handleDisplayAlert(videoSizeLimit);
111
113
  event.target.value = null;
112
114
  return;
113
115
  }
@@ -3,8 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VIDEO_MAX_SIZE_5MB = exports.ONE_MB = exports.ONE_KB = exports.ONE_GB = void 0;
7
- var VIDEO_MAX_SIZE_5MB = exports.VIDEO_MAX_SIZE_5MB = 5 * 1024 * 1024;
6
+ exports.getSeadocVideoSizeLimit = exports.formatSeadocVideoSizeLimit = exports.SEADOC_VIDEO_SIZE_LIMIT = exports.ONE_MB = exports.ONE_KB = exports.ONE_GB = void 0;
7
+ var SEADOC_VIDEO_SIZE_LIMIT = exports.SEADOC_VIDEO_SIZE_LIMIT = 5 * 1024 * 1024;
8
+ var getSeadocVideoSizeLimit = exports.getSeadocVideoSizeLimit = function getSeadocVideoSizeLimit(sizeLimit) {
9
+ var parsedSizeLimit = Number(sizeLimit);
10
+ return Number.isFinite(parsedSizeLimit) && parsedSizeLimit > 0 ? parsedSizeLimit : SEADOC_VIDEO_SIZE_LIMIT;
11
+ };
12
+ var formatSeadocVideoSizeLimit = exports.formatSeadocVideoSizeLimit = function formatSeadocVideoSizeLimit(sizeLimit) {
13
+ var units = ['B', 'KB', 'MB', 'GB', 'TB'];
14
+ var formattedSize = getSeadocVideoSizeLimit(sizeLimit);
15
+ var unitIndex = 0;
16
+ while (formattedSize >= 1024 && unitIndex < units.length - 1) {
17
+ formattedSize /= 1024;
18
+ unitIndex += 1;
19
+ }
20
+ var displaySize = Number.isInteger(formattedSize) ? formattedSize : formattedSize.toFixed(1);
21
+ return "".concat(displaySize, " ").concat(units[unitIndex]);
22
+ };
8
23
  var ONE_GB = exports.ONE_GB = 1000 * 1000 * 1000;
9
24
  var ONE_MB = exports.ONE_MB = 1000 * 1000;
10
25
  var ONE_KB = exports.ONE_KB = 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "3.0.242",
3
+ "version": "3.0.244",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -71,5 +71,5 @@
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "0c2e7b8b0dd45275959494bd903a04f7efb12871"
74
+ "gitHead": "c6b6fc48e11563d22a9f5fc32e453c0dedf2fde9"
75
75
  }