@seafile/sdoc-editor 3.0.253 → 3.0.254

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.
@@ -124,6 +124,20 @@ var EditorComment = function EditorComment(_ref) {
124
124
 
125
125
  // Comments are updated to modify the current comment
126
126
  (0, _react.useEffect)(function () {
127
+ if (isShowComments && Object.keys(commentDetail).length) {
128
+ var comments = Object.values(element_comments_map).flat();
129
+ var newCommentDetail = (0, _objectSpread2["default"])({}, commentDetail);
130
+ Object.keys(newCommentDetail).forEach(function (key) {
131
+ var comment = comments.find(function (item) {
132
+ var _newCommentDetail$key;
133
+ return item.id === ((_newCommentDetail$key = newCommentDetail[key]) === null || _newCommentDetail$key === void 0 ? void 0 : _newCommentDetail$key.id);
134
+ });
135
+ if (comment) {
136
+ newCommentDetail[key] = comment;
137
+ }
138
+ });
139
+ setCommentDetail(newCommentDetail);
140
+ }
127
141
  if (isContextComment && activeElementIds) {
128
142
  var unresolvedComments = element_comments_map[activeElementIds[0].element.id].filter(function (item) {
129
143
  return !item.resolved;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.STANDARD_COLORS = exports.RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY = exports.RECENT_USED_HIGHLIGHT_COLORS_KEY = exports.RECENT_USED_FONT_COLORS_KEY = exports.DEFAULT_RECENT_USED_LIST = exports.DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR = exports.DEFAULT_LAST_USED_HIGHLIGHT_COLOR = exports.DEFAULT_LAST_USED_FONT_COLOR = exports.DEFAULT_FONT_COLOR = exports.DEFAULT_COLORS = void 0;
6
+ exports.STANDARD_COLORS = exports.RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY = exports.RECENT_USED_HIGHLIGHT_COLORS_KEY = exports.RECENT_USED_FONT_COLORS_KEY = exports.LAST_USED_TEXT_COLORS_KEY = exports.DEFAULT_RECENT_USED_LIST = exports.DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR = exports.DEFAULT_LAST_USED_HIGHLIGHT_COLOR = exports.DEFAULT_LAST_USED_FONT_COLOR = exports.DEFAULT_FONT_COLOR = exports.DEFAULT_COLORS = void 0;
7
7
  var DEFAULT_COLORS = exports.DEFAULT_COLORS = [{
8
8
  value: '#FFFFFF',
9
9
  name: 'White'
@@ -275,6 +275,7 @@ var DEFAULT_FONT_COLOR = exports.DEFAULT_FONT_COLOR = '#333333';
275
275
  var DEFAULT_LAST_USED_FONT_COLOR = exports.DEFAULT_LAST_USED_FONT_COLOR = '#FFFF00';
276
276
  var DEFAULT_LAST_USED_HIGHLIGHT_COLOR = exports.DEFAULT_LAST_USED_HIGHLIGHT_COLOR = '#FF0000';
277
277
  var DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR = exports.DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR = '#FF0000';
278
+ var LAST_USED_TEXT_COLORS_KEY = exports.LAST_USED_TEXT_COLORS_KEY = 'sdoc-last-used-text-colors';
278
279
 
279
280
  // recent used colors key
280
281
  var RECENT_USED_HIGHLIGHT_COLORS_KEY = exports.RECENT_USED_HIGHLIGHT_COLORS_KEY = 'sdoc-recent-used-highlight-colors';
@@ -246,6 +246,12 @@ Object.defineProperty(exports, "KEYBOARD", {
246
246
  return _keyboard.KEYBOARD;
247
247
  }
248
248
  });
249
+ Object.defineProperty(exports, "LAST_USED_TEXT_COLORS_KEY", {
250
+ enumerable: true,
251
+ get: function get() {
252
+ return _color.LAST_USED_TEXT_COLORS_KEY;
253
+ }
254
+ });
249
255
  Object.defineProperty(exports, "LINK", {
250
256
  enumerable: true,
251
257
  get: function get() {
@@ -29,15 +29,9 @@ var getCollapsedHeaderState = function getCollapsedHeaderState() {
29
29
  return _localStorageUtils["default"].getItem(getHeaderStorageKey(), {});
30
30
  };
31
31
  var persistCollapsedHeaderState = function persistCollapsedHeaderState(collapsedHeaderState) {
32
- try {
33
- _localStorageUtils["default"].setItem(getHeaderStorageKey(), collapsedHeaderState);
34
- } catch (error) {
32
+ if (_localStorageUtils["default"].setItem(getHeaderStorageKey(), collapsedHeaderState) === false) {
35
33
  clearAllHeaderCollapsedState();
36
- try {
37
- _localStorageUtils["default"].setItem(getHeaderStorageKey(), collapsedHeaderState);
38
- } catch (_unused) {
39
- // Ignore storage failures after cleanup.
40
- }
34
+ _localStorageUtils["default"].setItem(getHeaderStorageKey(), collapsedHeaderState);
41
35
  }
42
36
  };
43
37
  var getHeaderId = function getHeaderId(editor, element, defaultPath) {
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "getImageWikiPageUrl", {
11
11
  return _linkHelpers.getImageWikiPageUrl;
12
12
  }
13
13
  });
14
- exports.updateImage = exports.selectImageWhenSelectPartial = exports.resetCursor = exports.removeImageWikiPageLinks = exports.removeImageBlockNode = exports.queryCopyMoveProgressView = exports.isInsertImageMenuDisabled = exports.isImageUrlIsFromUpload = exports.isImageUrlIsFromCopy = exports.isCommentEditor = exports.insertImageFiles = exports.insertImage = exports.hasSdocImages = exports.handleBase64Image = exports.getSingleImageFromFragment = void 0;
14
+ exports.updateImage = exports.selectImageWhenSelectPartial = exports.resetCursor = exports.removeImageWikiPageLinks = exports.removeImageBlockNode = exports.queryCopyMoveProgressView = exports.isInsertImageMenuDisabled = exports.isImageUrlIsFromUpload = exports.isImageUrlIsFromCopy = exports.isForbiddenImageUrl = exports.isCommentEditor = exports.insertImageFiles = exports.insertImage = exports.hasSdocImages = exports.handleBase64Image = exports.getSingleImageFromFragment = void 0;
15
15
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
16
16
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
17
17
  var _regenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regenerator"));
@@ -380,6 +380,111 @@ var isImageUrlIsFromUpload = exports.isImageUrlIsFromUpload = function isImageUr
380
380
  if (url && url.startsWith('blob:http')) return true;
381
381
  return false;
382
382
  };
383
+ var isForbiddenIPv4Octets = function isForbiddenIPv4Octets(first, second) {
384
+ if (first === 127 || first === 10 || first === 0) return true;
385
+ if (first === 169 && second === 254) return true;
386
+ if (first === 172 && second >= 16 && second <= 31) return true;
387
+ if (first === 192 && second === 168) return true;
388
+ return false;
389
+ };
390
+ var matchIPv4 = function matchIPv4(value) {
391
+ var match = value.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
392
+ if (!match) return null;
393
+ var octets = match.slice(1).map(function (part) {
394
+ return parseInt(part, 10);
395
+ });
396
+ if (octets.some(function (octet) {
397
+ return octet > 255;
398
+ })) return null;
399
+ return octets;
400
+ };
401
+
402
+ // Expands a bracketed/bare IPv6 literal (handling "::" compression and a
403
+ // trailing embedded IPv4 address, e.g. "::ffff:127.0.0.1") into 8 16-bit groups.
404
+ var parseIPv6Hostname = function parseIPv6Hostname(hostname) {
405
+ var literal = hostname.startsWith('[') && hostname.endsWith(']') ? hostname.slice(1, -1) : hostname;
406
+ if (!literal.includes(':')) return null;
407
+ var sides = literal.split('::');
408
+ if (sides.length > 2) return null;
409
+ var toGroups = function toGroups(side) {
410
+ if (side === '') return [];
411
+ var parts = side.split(':');
412
+ var last = parts[parts.length - 1];
413
+ if (last.includes('.')) {
414
+ var ipv4 = matchIPv4(last);
415
+ if (!ipv4) return null;
416
+ var _ipv = (0, _slicedToArray2["default"])(ipv4, 4),
417
+ a = _ipv[0],
418
+ b = _ipv[1],
419
+ c = _ipv[2],
420
+ d = _ipv[3];
421
+ parts.splice(parts.length - 1, 1, ((a << 8 | b) & 0xffff).toString(16), ((c << 8 | d) & 0xffff).toString(16));
422
+ }
423
+ if (parts.some(function (part) {
424
+ return !/^[0-9a-f]{1,4}$/i.test(part);
425
+ })) return null;
426
+ return parts.map(function (part) {
427
+ return parseInt(part, 16);
428
+ });
429
+ };
430
+ var head = toGroups(sides[0]);
431
+ var tail = sides.length === 2 ? toGroups(sides[1]) : [];
432
+ if (head === null || tail === null) return null;
433
+ var groups;
434
+ if (sides.length === 1) {
435
+ groups = head;
436
+ } else {
437
+ var missing = 8 - head.length - tail.length;
438
+ if (missing < 0) return null;
439
+ groups = [].concat((0, _toConsumableArray2["default"])(head), (0, _toConsumableArray2["default"])(Array(missing).fill(0)), (0, _toConsumableArray2["default"])(tail));
440
+ }
441
+ return groups.length === 8 ? groups : null;
442
+ };
443
+ var isForbiddenIPv6 = function isForbiddenIPv6(groups) {
444
+ var _groups = (0, _slicedToArray2["default"])(groups, 8),
445
+ g0 = _groups[0],
446
+ g1 = _groups[1],
447
+ g2 = _groups[2],
448
+ g3 = _groups[3],
449
+ g4 = _groups[4],
450
+ g5 = _groups[5],
451
+ g6 = _groups[6],
452
+ g7 = _groups[7];
453
+ // ::1 loopback
454
+ if (g0 === 0 && g1 === 0 && g2 === 0 && g3 === 0 && g4 === 0 && g5 === 0 && g6 === 0 && g7 === 1) return true;
455
+ // fe80::/10 link-local
456
+ if (g0 >= 0xfe80 && g0 <= 0xfebf) return true;
457
+ // fc00::/7 unique-local
458
+ if (g0 >= 0xfc00 && g0 <= 0xfdff) return true;
459
+ // ::ffff:a.b.c.d IPv4-mapped — re-check the embedded IPv4 address
460
+ if (g0 === 0 && g1 === 0 && g2 === 0 && g3 === 0 && g4 === 0 && g5 === 0xffff) {
461
+ return isForbiddenIPv4Octets(g6 >> 8 & 0xff, g6 & 0xff);
462
+ }
463
+ return false;
464
+ };
465
+
466
+ // Blocks requests to loopback, link-local (incl. cloud metadata) and private network ranges,
467
+ // which a crafted copy/pasted image URL could otherwise force the browser to fetch. URLs on the
468
+ // deployment's own configured server are explicitly allowed even if that server itself resolves
469
+ // to a private address (e.g. a self-hosted/on-prem instance).
470
+ var isForbiddenImageUrl = exports.isForbiddenImageUrl = function isForbiddenImageUrl(urlString) {
471
+ try {
472
+ var _URL = new URL(urlString),
473
+ protocol = _URL.protocol,
474
+ hostname = _URL.hostname;
475
+ if (protocol !== 'http:' && protocol !== 'https:') return true;
476
+ if ((0, _linkHelpers.isCurrentServerUrl)(urlString)) return false;
477
+ if (hostname === 'localhost') return true;
478
+ if (hostname.startsWith('[') || hostname.includes(':')) {
479
+ var groups = parseIPv6Hostname(hostname);
480
+ return groups ? isForbiddenIPv6(groups) : true;
481
+ }
482
+ var ipv4 = matchIPv4(hostname);
483
+ return ipv4 ? isForbiddenIPv4Octets(ipv4[0], ipv4[1]) : false;
484
+ } catch (e) {
485
+ return true;
486
+ }
487
+ };
383
488
  var isCommentEditor = exports.isCommentEditor = function isCommentEditor(editor) {
384
489
  return editor.editorType === _constants.COMMENT_EDITOR;
385
490
  };
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports["default"] = void 0;
7
+ exports.downloadAndUploadImage = exports["default"] = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
9
9
  var _regenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regenerator"));
10
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
@@ -12,7 +12,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
12
12
  var _react = require("react");
13
13
  var _slate = require("@seafile/slate");
14
14
  var _slateReact = require("@seafile/slate-react");
15
- var _context3 = _interopRequireDefault(require("../../../context"));
15
+ var _context4 = _interopRequireDefault(require("../../../context"));
16
16
  var _localStorageUtils = _interopRequireDefault(require("../../../utils/local-storage-utils"));
17
17
  var _constants = require("../../constants");
18
18
  var _helpers = require("./helpers");
@@ -49,9 +49,53 @@ var updateImageNode = /*#__PURE__*/function () {
49
49
  return _ref.apply(this, arguments);
50
50
  };
51
51
  }();
52
- var useCopyImage = function useCopyImage(_ref2) {
53
- var editor = _ref2.editor,
54
- element = _ref2.element;
52
+
53
+ // Downloads a copied/pasted image URL and re-uploads it to our own storage.
54
+ // Exported for direct unit testing of the forbidden-URL guard.
55
+ var downloadAndUploadImage = exports.downloadAndUploadImage = /*#__PURE__*/function () {
56
+ var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee2(url) {
57
+ var response, blob, file, imageUrl;
58
+ return (0, _regenerator2["default"])().w(function (_context2) {
59
+ while (1) switch (_context2.n) {
60
+ case 0:
61
+ if (!(0, _helpers.isForbiddenImageUrl)(url)) {
62
+ _context2.n = 1;
63
+ break;
64
+ }
65
+ throw new Error("Blocked potentially unsafe image URL: ".concat(url));
66
+ case 1:
67
+ _context2.n = 2;
68
+ return fetch(url);
69
+ case 2:
70
+ response = _context2.v;
71
+ if (response.ok) {
72
+ _context2.n = 3;
73
+ break;
74
+ }
75
+ throw new Error("HTTP error status: ".concat(response.status));
76
+ case 3:
77
+ _context2.n = 4;
78
+ return response.blob();
79
+ case 4:
80
+ blob = _context2.v;
81
+ file = new File([blob], 'downloaded_image.png', {
82
+ type: blob.type
83
+ });
84
+ _context2.n = 5;
85
+ return _context4["default"].uploadLocalImage([file]);
86
+ case 5:
87
+ imageUrl = _context2.v;
88
+ return _context2.a(2, imageUrl && imageUrl[0] ? imageUrl[0] : null);
89
+ }
90
+ }, _callee2);
91
+ }));
92
+ return function downloadAndUploadImage(_x4) {
93
+ return _ref2.apply(this, arguments);
94
+ };
95
+ }();
96
+ var useCopyImage = function useCopyImage(_ref3) {
97
+ var editor = _ref3.editor,
98
+ element = _ref3.element;
55
99
  var data = element.data;
56
100
  var _data$is_copy_error = data.is_copy_error,
57
101
  is_copy_error = _data$is_copy_error === void 0 ? false : _data$is_copy_error;
@@ -74,64 +118,44 @@ var useCopyImage = function useCopyImage(_ref2) {
74
118
  // sync content from another user's copy
75
119
  if (!cacheContent || JSON.stringify(cacheContent).indexOf(url) === -1) return;
76
120
  }
77
- var downloadAndUploadImages = /*#__PURE__*/function () {
78
- var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee2(url) {
79
- var response, blob, file, imageUrl, _t;
80
- return (0, _regenerator2["default"])().w(function (_context2) {
81
- while (1) switch (_context2.p = _context2.n) {
121
+ var run = /*#__PURE__*/function () {
122
+ var _ref4 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee3(url) {
123
+ var imageUrl, _t;
124
+ return (0, _regenerator2["default"])().w(function (_context3) {
125
+ while (1) switch (_context3.p = _context3.n) {
82
126
  case 0:
83
- _context2.p = 0;
84
- _context2.n = 1;
85
- return fetch(url);
127
+ _context3.p = 0;
128
+ _context3.n = 1;
129
+ return downloadAndUploadImage(url);
86
130
  case 1:
87
- response = _context2.v;
88
- if (!response.ok) {
89
- _context2.n = 4;
90
- break;
131
+ imageUrl = _context3.v;
132
+ if (imageUrl) {
133
+ updateImageNode(editor, element, imageUrl);
91
134
  }
92
- _context2.n = 2;
93
- return response.blob();
94
- case 2:
95
- blob = _context2.v;
96
- file = new File([blob], 'downloaded_image.png', {
97
- type: blob.type
98
- });
99
- _context2.n = 3;
100
- return _context3["default"].uploadLocalImage([file]);
101
- case 3:
102
- imageUrl = _context2.v;
103
- if (imageUrl && imageUrl[0]) {
104
- updateImageNode(editor, element, imageUrl[0]);
105
- }
106
- _context2.n = 5;
135
+ _context3.n = 3;
107
136
  break;
108
- case 4:
109
- throw new Error("HTTP error status: ".concat(response.status));
110
- case 5:
111
- _context2.n = 7;
112
- break;
113
- case 6:
114
- _context2.p = 6;
115
- _t = _context2.v;
137
+ case 2:
138
+ _context3.p = 2;
139
+ _t = _context3.v;
116
140
  console.error(_t);
117
141
  updateImageNode(editor, element, url, true);
118
142
  setIsCopyError(true);
119
- case 7:
120
- _context2.p = 7;
143
+ case 3:
144
+ _context3.p = 3;
121
145
  setTimeout(function () {
122
146
  setIsLoading(false);
123
147
  }, 500);
124
- return _context2.f(7);
125
- case 8:
126
- return _context2.a(2);
148
+ return _context3.f(3);
149
+ case 4:
150
+ return _context3.a(2);
127
151
  }
128
- }, _callee2, null, [[0, 6, 7, 8]]);
152
+ }, _callee3, null, [[0, 2, 3, 4]]);
129
153
  }));
130
- return function downloadAndUploadImages(_x4) {
131
- return _ref3.apply(this, arguments);
154
+ return function run(_x5) {
155
+ return _ref4.apply(this, arguments);
132
156
  };
133
157
  }();
134
- downloadAndUploadImages(url);
158
+ run(url);
135
159
  // eslint-disable-next-line react-hooks/exhaustive-deps
136
160
  }, []);
137
161
  (0, _react.useEffect)(function () {
@@ -6,23 +6,55 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.useColorContext = exports.ColorProvider = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
10
+ var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
9
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
10
12
  var _react = _interopRequireWildcard(require("react"));
13
+ var _context = _interopRequireDefault(require("../context"));
11
14
  var _constants = require("../extension/constants");
15
+ var _localStorageUtils = _interopRequireDefault(require("../utils/local-storage-utils"));
12
16
  var ColorContext = /*#__PURE__*/_react["default"].createContext(null);
17
+ var getLastUsedTextColors = function getLastUsedTextColors(storageKey) {
18
+ if (typeof window === 'undefined' || !storageKey) return {};
19
+ try {
20
+ return _localStorageUtils["default"].getItem(storageKey, {});
21
+ } catch (_unused) {
22
+ return {};
23
+ }
24
+ };
13
25
  var ColorProvider = exports.ColorProvider = function ColorProvider(props) {
14
- var _useState = (0, _react.useState)(_constants.DEFAULT_LAST_USED_FONT_COLOR),
26
+ var username = _context["default"].getSetting('username');
27
+ var storageKey = username ? "".concat(_constants.LAST_USED_TEXT_COLORS_KEY, ":").concat(username) : '';
28
+ var _useState = (0, _react.useState)(function () {
29
+ var _getLastUsedTextColor;
30
+ return (_getLastUsedTextColor = getLastUsedTextColors(storageKey).fontColor) !== null && _getLastUsedTextColor !== void 0 ? _getLastUsedTextColor : _constants.DEFAULT_LAST_USED_FONT_COLOR;
31
+ }),
15
32
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
16
33
  lastUsedFontColor = _useState2[0],
17
- updateLastUsedFontColor = _useState2[1];
18
- var _useState3 = (0, _react.useState)(_constants.DEFAULT_LAST_USED_HIGHLIGHT_COLOR),
34
+ setLastUsedFontColor = _useState2[1];
35
+ var _useState3 = (0, _react.useState)(function () {
36
+ var _getLastUsedTextColor2;
37
+ return (_getLastUsedTextColor2 = getLastUsedTextColors(storageKey).highlightColor) !== null && _getLastUsedTextColor2 !== void 0 ? _getLastUsedTextColor2 : _constants.DEFAULT_LAST_USED_HIGHLIGHT_COLOR;
38
+ }),
19
39
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
20
40
  lastUsedHighlightColor = _useState4[0],
21
- updateLastUsedHighlightColor = _useState4[1];
41
+ setLastUsedHighlightColor = _useState4[1];
22
42
  var _useState5 = (0, _react.useState)(_constants.DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR),
23
43
  _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
24
44
  lastUsedTableCellBackgroundColor = _useState6[0],
25
45
  updateLastUsedTableCellBackgroundColor = _useState6[1];
46
+ var saveLastUsedTextColor = function saveLastUsedTextColor(colorKey, color) {
47
+ if (!storageKey) return;
48
+ _localStorageUtils["default"].setItem(storageKey, (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, getLastUsedTextColors(storageKey)), {}, (0, _defineProperty2["default"])({}, colorKey, color)));
49
+ };
50
+ var updateLastUsedFontColor = function updateLastUsedFontColor(color) {
51
+ setLastUsedFontColor(color);
52
+ saveLastUsedTextColor('fontColor', color);
53
+ };
54
+ var updateLastUsedHighlightColor = function updateLastUsedHighlightColor(color) {
55
+ setLastUsedHighlightColor(color);
56
+ saveLastUsedTextColor('highlightColor', color);
57
+ };
26
58
  return /*#__PURE__*/_react["default"].createElement(ColorContext.Provider, {
27
59
  value: {
28
60
  lastUsedFontColor: lastUsedFontColor,
@@ -14,16 +14,20 @@ var LocalStorage = /*#__PURE__*/function () {
14
14
  return (0, _createClass2["default"])(LocalStorage, null, [{
15
15
  key: "setItem",
16
16
  value: function setItem(key, value) {
17
- var savedValue;
18
- var valueType = typeof value;
19
- if (valueType === 'string') {
20
- savedValue = value;
21
- } else if (valueType === 'number') {
22
- savedValue = value + '';
23
- } else {
24
- savedValue = JSON.stringify(value);
17
+ try {
18
+ var savedValue;
19
+ var valueType = typeof value;
20
+ if (valueType === 'string') {
21
+ savedValue = value;
22
+ } else if (valueType === 'number') {
23
+ savedValue = value + '';
24
+ } else {
25
+ savedValue = JSON.stringify(value);
26
+ }
27
+ return window.localStorage.setItem(key, savedValue);
28
+ } catch (_unused) {
29
+ return false;
25
30
  }
26
- return window.localStorage.setItem(key, savedValue);
27
31
  }
28
32
  }, {
29
33
  key: "getItem",
@@ -31,7 +35,7 @@ var LocalStorage = /*#__PURE__*/function () {
31
35
  var value = window.localStorage.getItem(key);
32
36
  try {
33
37
  return JSON.parse(value) || defaultValue;
34
- } catch (_unused) {
38
+ } catch (_unused2) {
35
39
  return value || defaultValue;
36
40
  }
37
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "3.0.253",
3
+ "version": "3.0.254",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "c611c7584955e57fc785a18198584f10bbdb0425"
73
+ "gitHead": "e5d88a3c1423f08871e0b5c28c56d47043047238"
74
74
  }