Skip to content

Commit 14b1f37

Browse files
Merge pull request #496 from contentstack/preview-share-hot-fix
V4.0.1
2 parents d1a0246 + 2e6d835 commit 14b1f37

File tree

9 files changed

+37
-13
lines changed

9 files changed

+37
-13
lines changed

.talismanrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ fileignoreconfig:
44
- filecontent
55
- filename: README.md
66
checksum: 568289bbe7c088967493db246dbf29e465382648ac574c1b1236be57d5662a38
7-
- filename: CHANGELOG.md
8-
checksum: 8e2495db48ed58704b0883b052c5d44b9f1a96cff7556235f924d16a47442688
97
- filename: src/visualBuilder/components/__test__/fieldToolbar.test.tsx
108
checksum: 3badd6a142456b6a361569e6fc546349a38ac6b366bef7fd5255d1e93220444e
119
- filename: src/visualBuilder/components/Collab/ThreadPopup/__test__/CommentTextArea.test.tsx
1210
checksum: d0ef271ee5381d9feab06bda6e7e89bd0a882fee87495627bd811c1f0a5459c7
1311
- filename: package-lock.json
1412
checksum: fd06363871d0ee16ebfb5d9d0cc479e0922a615bb76584b80bb6933ee6c3e237
1513
- filename: CHANGELOG.md
16-
checksum: 8522880c11ce1518b18b8760a0f5a9cdcdd2d330575f50ba6ab403b7f8f7e74f
14+
checksum: 873106e25dafe0355c55724936cfe0ecc9d0192a2a82c98eddaf5648f23d5ee7
1715
version: "1.0"

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# Changelog
22

3-
## [v4.0.0](https://github.com/contentstack/live-preview-sdk/compare/v4.1.0...v4.0.0)
3+
## [v4.0.1](https://github.com/contentstack/live-preview-sdk/compare/v4.0.0...v4.0.1)
44

5-
> 20 August 2025
5+
> 22 August 2025
6+
7+
### Fixes
8+
9+
- fix(preview): add util function to allow operations in preview share (Zuhair Ahmed - [fb70cdf](https://github.com/contentstack/live-preview-sdk/commit/fb70cdf8f238a0f54bbf85cacd84a09688d54b9e))
10+
11+
## [v4.0.0](https://github.com/contentstack/live-preview-sdk/compare/v3.4.0...v4.0.0)
12+
13+
> 22 August 2025
614
715
### New Features
816

@@ -12,6 +20,7 @@
1220

1321
### General Changes
1422

23+
- 21st august 2025 release (Sahil Chalke - [#495](https://github.com/contentstack/live-preview-sdk/pull/495))
1524
- Live preview outside iframe (Mridul Sharma - [#492](https://github.com/contentstack/live-preview-sdk/pull/492))
1625

1726
### New Features
@@ -29,7 +38,9 @@
2938
### Chores And Housekeeping
3039

3140
- chore: replace ifs with switch (Faraaz Biyabani - [5e216ea](https://github.com/contentstack/live-preview-sdk/commit/5e216ea01311dceee09405e1265190267745afc0))
41+
- chore: updated the changelog.md (SahilCs15 - [fab45bf](https://github.com/contentstack/live-preview-sdk/commit/fab45bf178e31340ae72577a2f3038449970f3e1))
3242
- chore: updated version (Mridul Sharma - [ede97b9](https://github.com/contentstack/live-preview-sdk/commit/ede97b983727e69c5d44d8d9879d18592a47548a))
43+
- chore: updated the .talismanrc (SahilCs15 - [4686298](https://github.com/contentstack/live-preview-sdk/commit/4686298249bb51900fc2b703653be939a8ebc0a4))
3344
- chore: update tooltip message (Faraaz Biyabani - [c23798e](https://github.com/contentstack/live-preview-sdk/commit/c23798e0467c0a6318047ee2e4fdfeef4f74a5fd))
3445
- chore: remove sequential from unit tests (Faraaz Biyabani - [07f3c96](https://github.com/contentstack/live-preview-sdk/commit/07f3c964950db86a2537988d53ad1b78af3f1860))
3546

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Alternatively, if you want to include the package directly in your website HTML
1616

1717
```html
1818
<script type='module' integrity='sha384-b6G+ggU20rGxqCqsgaS6zludFgj5N11xsuXhMEIARMuQY2PtyDS04TU0H5goP+32' crossorigin="anonymous">
19-
import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@4.0.0';
19+
import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@4.0.1';
2020
2121
ContentstackLivePreview.init({
2222
stackDetails: {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/live-preview-utils",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Contentstack provides the Live Preview SDK to establish a communication channel between the various Contentstack SDKs and your website, transmitting live changes to the preview pane.",
55
"type": "module",
66
"types": "dist/legacy/index.d.ts",

src/utils/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,13 @@ export function isOpenInBuilder(): boolean {
4444
}
4545
return false;
4646
}
47+
48+
49+
export function isOpenInPreviewShare(): boolean {
50+
if (hasWindow()) {
51+
const urlParams = new URLSearchParams(window.location.search);
52+
const previewShare = urlParams.get("preview_share");
53+
return !!previewShare;
54+
}
55+
return false;
56+
}

src/visualBuilder/__test__/hover/fields/date.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ vi.mock("../../../../utils/index.ts", () => {
3030
return {
3131
__esModule: true,
3232
isOpenInBuilder: vi.fn().mockReturnValue(true),
33+
isOpenInPreviewShare: vi.fn().mockReturnValue(false),
3334
isOpeningInTimeline: vi.fn().mockReturnValue(false),
3435
hasWindow: vi.fn().mockReturnValue(true),
3536
addLivePreviewQueryTags: vi.fn(),

src/visualBuilder/components/VisualBuilder.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ import {
55
VisualBuilderGlobalStyles,
66
} from "../visualBuilder.style";
77
import React from "preact/compat";
8-
import { isOpenInBuilder } from "../../utils";
8+
import { isOpenInBuilder , isOpenInPreviewShare} from "../../utils";
99

1010
interface VisualBuilderProps {
1111
visualBuilderContainer: HTMLDivElement | null;
1212
resizeObserver: ResizeObserver;
1313
}
1414

1515
function VisualBuilderComponent(props: VisualBuilderProps): JSX.Element | null {
16-
if (!isOpenInBuilder()) {
16+
const isInBuilder = isOpenInBuilder();
17+
const isInPreviewShare = isOpenInPreviewShare();
18+
19+
if (!isInBuilder && !isInPreviewShare) {
1720
return null;
1821
}
1922

src/visualBuilder/components/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { render } from "preact";
22
import VisualBuilderComponent from "./VisualBuilder";
33
import { visualBuilderStyles } from "../visualBuilder.style";
44
import React from "preact/compat";
5-
import { isOpenInBuilder } from "../../utils";
5+
import { isOpenInBuilder , isOpenInPreviewShare} from "../../utils";
66

77
interface InitUIParams {
88
resizeObserver: ResizeObserver;
@@ -14,8 +14,9 @@ function initUI(props: InitUIParams): void {
1414
);
1515

1616
const isInBuilder = isOpenInBuilder();
17+
const isInPreviewShare = isOpenInPreviewShare();
1718

18-
if (!visualBuilderDOM && isInBuilder) {
19+
if (!visualBuilderDOM && (isInBuilder || isInPreviewShare)) {
1920
const visualBuilderContainer = document.createElement("div");
2021
visualBuilderContainer.classList.add(
2122
visualBuilderStyles()["visual-builder__container"],

0 commit comments

Comments
 (0)