oolib 2.67.4 → 2.67.5

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.
@@ -99,7 +99,8 @@ function ImageEditor(_a) {
99
99
  aspectRatio: aspectRatio,
100
100
  underEditImageData: underEditImageData,
101
101
  isFirstMount: isFirstMount,
102
- handleDeleteSingleImage: handleDeleteSingleImage
102
+ handleDeleteSingleImage: handleDeleteSingleImage,
103
+ readOnly: readOnly
103
104
  }), reorientedImageTempUrl = _l.reorientedImageTempUrl, imageLazyLoading = _l.imageLazyLoading;
104
105
  var _m = (0, react_1.useState)(undefined), showDeleteImageModal = _m[0], setShowDeleteImageModal = _m[1];
105
106
  var inputRef = (0, react_1.useRef)(null);
@@ -1,4 +1,4 @@
1
- export function useReorientImage({ imageRotate, setFullWidthOrFullHeightImg, setUnderEditImageData, publicUrl, aspectRatio, isFirstMount, handleDeleteSingleImage }: {
1
+ export function useReorientImage({ imageRotate, setFullWidthOrFullHeightImg, setUnderEditImageData, publicUrl, aspectRatio, isFirstMount, handleDeleteSingleImage, readOnly }: {
2
2
  imageRotate: any;
3
3
  setFullWidthOrFullHeightImg: any;
4
4
  setUnderEditImageData: any;
@@ -6,6 +6,7 @@ export function useReorientImage({ imageRotate, setFullWidthOrFullHeightImg, set
6
6
  aspectRatio: any;
7
7
  isFirstMount: any;
8
8
  handleDeleteSingleImage: any;
9
+ readOnly: any;
9
10
  }): {
10
11
  reorientedImageTempUrl: any;
11
12
  imageLazyLoading: boolean;
@@ -6,8 +6,9 @@ var react_1 = require("react");
6
6
  var decideIfFullWidthOrFullHeightImg_1 = require("../decideIfFullWidthOrFullHeightImg");
7
7
  var changeImageOrientation_1 = require("./changeImageOrientation");
8
8
  var bannerContext_1 = require("../../../../../Banners/bannerContext");
9
+ var UIContent_1 = require("../../../../../../UIContent");
9
10
  var useReorientImage = function (_a) {
10
- var imageRotate = _a.imageRotate, setFullWidthOrFullHeightImg = _a.setFullWidthOrFullHeightImg, setUnderEditImageData = _a.setUnderEditImageData, publicUrl = _a.publicUrl, aspectRatio = _a.aspectRatio, isFirstMount = _a.isFirstMount, handleDeleteSingleImage = _a.handleDeleteSingleImage;
11
+ var imageRotate = _a.imageRotate, setFullWidthOrFullHeightImg = _a.setFullWidthOrFullHeightImg, setUnderEditImageData = _a.setUnderEditImageData, publicUrl = _a.publicUrl, aspectRatio = _a.aspectRatio, isFirstMount = _a.isFirstMount, handleDeleteSingleImage = _a.handleDeleteSingleImage, readOnly = _a.readOnly;
11
12
  var SET_ALERT_BANNER = (0, bannerContext_1.useBannerContext)().SET_ALERT_BANNER;
12
13
  var _b = (0, react_1.useState)(true), imageLazyLoading = _b[0], setImageLazyLoading = _b[1];
13
14
  var _c = (0, react_1.useState)(undefined), reorientedImageTempUrl = _c[0], setReorientedImageTempUrl = _c[1];
@@ -29,8 +30,13 @@ var useReorientImage = function (_a) {
29
30
  * this component. In such cases, an error will fire here, and we need to
30
31
  * handle it, by deleting said url and throwing an alert
31
32
  */
32
- handleDeleteSingleImage({ publicUrl: publicUrl });
33
- SET_ALERT_BANNER(UIContent.ImageInput.corruptUrlErrMsg, 'red', 3000);
33
+ if (!readOnly) { //this also fixes another issue. in readonly in some cases (LinkEmbed) on change prop is not available. handleDelete uses the onChange, so this !readOnly condition solves that problem as well
34
+ handleDeleteSingleImage({ publicUrl: publicUrl });
35
+ SET_ALERT_BANNER(UIContent_1.UIContent.ImageInput.corruptUrlErrMsg, 'red', 3000);
36
+ }
37
+ else {
38
+ setImageLazyLoading(false); // in read only, let the broken image attempt to render and browser will show some default UI for the error
39
+ }
34
40
  };
35
41
  img.onload = function () {
36
42
  setFullWidthOrFullHeightImg((0, decideIfFullWidthOrFullHeightImg_1.decideIfFullWidthOrFullHeightImg)({
@@ -24,29 +24,32 @@ exports.prepInitValueFromConfigIfNoValue = void 0;
24
24
  var makeArrayFromLength_1 = require("../../../utils/makeArrayFromLength");
25
25
  var functions_1 = require("../functions");
26
26
  var prepInitValueFromConfigIfNoValue = function (_a) {
27
- var _b;
27
+ var _b, _c;
28
28
  var _value = _a._value, config = _a.config, defaultColWidth = _a.defaultColWidth;
29
29
  //if colHeaderData is defined then that decides the noOfCols.
30
30
  var noOfCols = ((_b = config.colHeaderData) === null || _b === void 0 ? void 0 : _b.length) || config.noOfCols;
31
- var value = !_value
32
- ? {
33
- data: __spreadArray([], insertRowAndCellIds({
34
- noOfRows: config.noOfRows,
35
- noOfCols: noOfCols
36
- }), true),
37
- colWidthConfig: getInitColWidthConfigs({ noOfCols: noOfCols, defaultColWidth: defaultColWidth }),
38
- }
39
- : !_value.data
31
+ var value = ((_c = _value === null || _value === void 0 ? void 0 : _value.data) === null || _c === void 0 ? void 0 : _c.length) > 0 //value exists in the correct shape
32
+ ? _value
33
+ : Array.isArray(_value) && _value.length > 0 //value exists but in deprecated shape
40
34
  ? {
41
35
  data: _value,
42
- colWidthConfig: getInitColWidthConfigs({ noOfCols: _value[0].cellData.length, defaultColWidth: defaultColWidth }),
43
- } //backwars compat
44
- : _value;
45
- return ({
36
+ colWidthConfig: getInitColWidthConfigs({
37
+ noOfCols: _value[0].cellData.length,
38
+ defaultColWidth: defaultColWidth,
39
+ }),
40
+ } //backwards compat
41
+ : {
42
+ data: __spreadArray([], insertRowAndCellIds({
43
+ noOfRows: config.noOfRows,
44
+ noOfCols: noOfCols,
45
+ }), true),
46
+ colWidthConfig: getInitColWidthConfigs({ noOfCols: noOfCols, defaultColWidth: defaultColWidth }),
47
+ };
48
+ return {
46
49
  value: value,
47
50
  canAddCols: !!!config.colHeaderData,
48
- canToggleColHeaderStyle: !!!config.colHeaderData // meaning its true if no config.colHeaderData is defined. else false
49
- });
51
+ canToggleColHeaderStyle: !!!config.colHeaderData, // meaning its true if no config.colHeaderData is defined. else false
52
+ };
50
53
  };
51
54
  exports.prepInitValueFromConfigIfNoValue = prepInitValueFromConfigIfNoValue;
52
55
  var getInitColWidthConfigs = function (_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.67.4",
3
+ "version": "2.67.5",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",