@sitecore-jss/sitecore-jss-nextjs 22.2.0-canary.22 → 22.2.0-canary.24

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.
@@ -24,7 +24,9 @@ const sitecore_jss_react_2 = require("@sitecore-jss/sitecore-jss-react");
24
24
  const sitecore_jss_react_3 = require("@sitecore-jss/sitecore-jss-react");
25
25
  const layout_1 = require("@sitecore-jss/sitecore-jss/layout");
26
26
  exports.NextImage = (0, sitecore_jss_react_1.withFieldMetadata)((0, sitecore_jss_react_2.withEmptyFieldEditingComponent)((_a) => {
27
+ var _b;
27
28
  var { editable = true, imageParams, field, mediaUrlPrefix, fill, priority } = _a, otherProps = __rest(_a, ["editable", "imageParams", "field", "mediaUrlPrefix", "fill", "priority"]);
29
+ const sitecoreContext = react_1.default.useContext(sitecore_jss_react_1.SitecoreContextReactContext);
28
30
  // next handles src and we use a custom loader,
29
31
  // throw error if these are present
30
32
  if (otherProps.src) {
@@ -46,8 +48,11 @@ exports.NextImage = (0, sitecore_jss_react_1.withFieldMetadata)((0, sitecore_jss
46
48
  if (!img) {
47
49
  return null;
48
50
  }
51
+ // disable image optimization for Edit and Preview, but preserve original value if true
52
+ const unoptimized = otherProps.unoptimized ||
53
+ ((_b = sitecoreContext.context) === null || _b === void 0 ? void 0 : _b.pageState) !== layout_1.LayoutServicePageState.Normal;
49
54
  const attrs = Object.assign(Object.assign(Object.assign({}, img), otherProps), { fill,
50
- priority, src: media_1.mediaApi.updateImageUrl(img.src, imageParams, mediaUrlPrefix) });
55
+ priority, src: media_1.mediaApi.updateImageUrl(img.src, imageParams, mediaUrlPrefix), unoptimized });
51
56
  const imageProps = Object.assign(Object.assign({}, attrs), {
52
57
  // force replace /media with /jssmedia in src since we _know_ we will be adding a 'mw' query string parameter
53
58
  // this is required for Sitecore media API resizing to work properly
@@ -12,13 +12,15 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { mediaApi } from '@sitecore-jss/sitecore-jss/media';
13
13
  import PropTypes from 'prop-types';
14
14
  import React from 'react';
15
- import { getEEMarkup, withFieldMetadata, } from '@sitecore-jss/sitecore-jss-react';
15
+ import { getEEMarkup, withFieldMetadata, SitecoreContextReactContext, } from '@sitecore-jss/sitecore-jss-react';
16
16
  import Image from 'next/image';
17
17
  import { withEmptyFieldEditingComponent } from '@sitecore-jss/sitecore-jss-react';
18
18
  import { DefaultEmptyFieldEditingComponentImage } from '@sitecore-jss/sitecore-jss-react';
19
- import { isFieldValueEmpty } from '@sitecore-jss/sitecore-jss/layout';
19
+ import { isFieldValueEmpty, LayoutServicePageState } from '@sitecore-jss/sitecore-jss/layout';
20
20
  export const NextImage = withFieldMetadata(withEmptyFieldEditingComponent((_a) => {
21
+ var _b;
21
22
  var { editable = true, imageParams, field, mediaUrlPrefix, fill, priority } = _a, otherProps = __rest(_a, ["editable", "imageParams", "field", "mediaUrlPrefix", "fill", "priority"]);
23
+ const sitecoreContext = React.useContext(SitecoreContextReactContext);
22
24
  // next handles src and we use a custom loader,
23
25
  // throw error if these are present
24
26
  if (otherProps.src) {
@@ -40,8 +42,11 @@ export const NextImage = withFieldMetadata(withEmptyFieldEditingComponent((_a) =
40
42
  if (!img) {
41
43
  return null;
42
44
  }
45
+ // disable image optimization for Edit and Preview, but preserve original value if true
46
+ const unoptimized = otherProps.unoptimized ||
47
+ ((_b = sitecoreContext.context) === null || _b === void 0 ? void 0 : _b.pageState) !== LayoutServicePageState.Normal;
43
48
  const attrs = Object.assign(Object.assign(Object.assign({}, img), otherProps), { fill,
44
- priority, src: mediaApi.updateImageUrl(img.src, imageParams, mediaUrlPrefix) });
49
+ priority, src: mediaApi.updateImageUrl(img.src, imageParams, mediaUrlPrefix), unoptimized });
45
50
  const imageProps = Object.assign(Object.assign({}, attrs), {
46
51
  // force replace /media with /jssmedia in src since we _know_ we will be adding a 'mw' query string parameter
47
52
  // this is required for Sitecore media API resizing to work properly
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-nextjs",
3
- "version": "22.2.0-canary.22",
3
+ "version": "22.2.0-canary.24",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -72,9 +72,9 @@
72
72
  "react-dom": "^18.2.0"
73
73
  },
74
74
  "dependencies": {
75
- "@sitecore-jss/sitecore-jss": "^22.2.0-canary.22",
76
- "@sitecore-jss/sitecore-jss-dev-tools": "^22.2.0-canary.22",
77
- "@sitecore-jss/sitecore-jss-react": "^22.2.0-canary.22",
75
+ "@sitecore-jss/sitecore-jss": "^22.2.0-canary.24",
76
+ "@sitecore-jss/sitecore-jss-dev-tools": "^22.2.0-canary.24",
77
+ "@sitecore-jss/sitecore-jss-react": "^22.2.0-canary.24",
78
78
  "@vercel/kv": "^0.2.1",
79
79
  "prop-types": "^15.8.1",
80
80
  "regex-parser": "^2.2.11",
@@ -82,7 +82,7 @@
82
82
  },
83
83
  "description": "",
84
84
  "types": "types/index.d.ts",
85
- "gitHead": "beab63322dff1a38c33b3580620377215a8b3ab2",
85
+ "gitHead": "2c4ab55cbdb879def573fd9e88b6d5d2dc530c36",
86
86
  "files": [
87
87
  "dist",
88
88
  "types",