Skip to content

Commit 3bcf72d

Browse files
authored
Merge pull request #488 from contentstack/stage_v3
2 parents 95fb850 + d470fcb commit 3bcf72d

27 files changed

+1440
-62
lines changed

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fileignoreconfig:
55
- filename: README.md
66
checksum: 568289bbe7c088967493db246dbf29e465382648ac574c1b1236be57d5662a38
77
- filename: CHANGELOG.md
8-
checksum: ed794e2f5c5884f74af12e5f5bfbb117c08ba454104f929df3deb7627407317a
8+
checksum: 8e2495db48ed58704b0883b052c5d44b9f1a96cff7556235f924d16a47442688
99
- filename: src/visualBuilder/components/__test__/fieldToolbar.test.tsx
1010
checksum: 3badd6a142456b6a361569e6fc546349a38ac6b366bef7fd5255d1e93220444e
1111
- filename: src/visualBuilder/components/Collab/ThreadPopup/__test__/CommentTextArea.test.tsx

CHANGELOG.md

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,51 @@
11
# Changelog
22

3+
## [v3.4.0](https://github.com/contentstack/live-preview-sdk/compare/v3.3.0...v3.4.0)
4+
5+
> 6 August 2025
6+
7+
### Fixes
8+
9+
- fix: multiple reloads in timeline (Mridul Sharma - [#484](https://github.com/contentstack/live-preview-sdk/pull/484))
10+
- fix: removed edit icon when the click is on the container (#478) (Sahil Chalke - [#485](https://github.com/contentstack/live-preview-sdk/pull/485))
11+
- Fix: Issue with hover toolbar click-ability (Ayush Dubey - [#467](https://github.com/contentstack/live-preview-sdk/pull/467))
12+
- fix: modified the way we were handling fieldlocation data fetch (Sahil Chalke - [#462](https://github.com/contentstack/live-preview-sdk/pull/462))
13+
14+
### General Changes
15+
16+
- VE-6918 (Aditya Pachauri - [#487](https://github.com/contentstack/live-preview-sdk/pull/487))
17+
- Hover Toolbar Click-ability Missed Commit (Ayush Dubey - [#482](https://github.com/contentstack/live-preview-sdk/pull/482))
18+
- Ve 5474 clean (Sahil Chalke - [#481](https://github.com/contentstack/live-preview-sdk/pull/481))
19+
20+
### Fixes
21+
22+
- fix: fixed the required changes (SahilCs15 - [53c6e77](https://github.com/contentstack/live-preview-sdk/commit/53c6e77c2d49718c748895d3bdecb7676461fe8d))
23+
- fix: resolved the issues (SahilCs15 - [3987e1c](https://github.com/contentstack/live-preview-sdk/commit/3987e1c92daf17658c0b814e52f2ce8950334d5b))
24+
- fix: undo unneccsary changes (SahilCs15 - [d0dae47](https://github.com/contentstack/live-preview-sdk/commit/d0dae47dda1bc41fde6ff6205bcee9b046ac2c09))
25+
- fix: fixed conficts (SahilCs15 - [17423d5](https://github.com/contentstack/live-preview-sdk/commit/17423d5e34094d91c0840a49dbee913be3b4bc37))
26+
- fix: removed not requied changes (SahilCs15 - [6837e62](https://github.com/contentstack/live-preview-sdk/commit/6837e62f73fbb6cc46adf6d4454157181d428043))
27+
- fix: disable scroll when field modifer is active (SahilCs15 - [2cb9824](https://github.com/contentstack/live-preview-sdk/commit/2cb9824dde552548a66d5a1ae79f1b98b089a535))
28+
- fix: addresed the requested cahnges (SahilCs15 - [27ec2f3](https://github.com/contentstack/live-preview-sdk/commit/27ec2f3442f1fdc1b327e77fda1b8cb1b71b1822))
29+
- fix:removed uncessary changes (SahilCs15 - [a0803ad](https://github.com/contentstack/live-preview-sdk/commit/a0803ad8aeab52fd298ef71a1dab754ae116aa27))
30+
31+
### Chores And Housekeeping
32+
33+
- chore: rendered the fieldmodifier apps added an event listner to send the selected app (SahilCs15 - [0c49039](https://github.com/contentstack/live-preview-sdk/commit/0c490390011da7a4c7b8a4b64e4e53cdab0cc9a3))
34+
- chore: added test cases for the field location data (SahilCs15 - [6337a6d](https://github.com/contentstack/live-preview-sdk/commit/6337a6de2c41684d6cc70b62f600a4036264577b))
35+
- chore: fieldlocation fetch completed (SahilCs15 - [bab5a47](https://github.com/contentstack/live-preview-sdk/commit/bab5a47953979af9cc5acc4fc05cbe6623caeb55))
36+
- chore(VE-6918/error-text): unit test file added (Aditya Pachauri - [ed1c0bb](https://github.com/contentstack/live-preview-sdk/commit/ed1c0bb03bc21a92f61c63e8db6120b6b35cb17e))
37+
- chore(VE-6918/error-text): warning message improved (Aditya Pachauri - [8122192](https://github.com/contentstack/live-preview-sdk/commit/8122192f46a29579da04ea7e7c6e0fb102a9043a))
38+
- chore(VE-6918/error-text): component name changed to title case (Aditya Pachauri - [dc3901f](https://github.com/contentstack/live-preview-sdk/commit/dc3901fafe5560b8a58f57303f934e21bbb73d98))
39+
- chore: test fix from merge operation (Mridul Sharma - [e335877](https://github.com/contentstack/live-preview-sdk/commit/e335877c8f7d120f5f0549463f6ad1a1c81c9176))
40+
41+
### Changes to Test Assests
42+
43+
- test: added test cases for addLivePreviewQueryTags and addParamsToUrl (Mridul Sharma - [e781891](https://github.com/contentstack/live-preview-sdk/commit/e781891b9f65baae7860c11e09d0ac88b0c9b229))
44+
45+
### General Changes
46+
47+
- redner the app on dom (SahilCs15 - [bd5095a](https://github.com/contentstack/live-preview-sdk/commit/bd5095a556930aeef55afc9de7f64d26f5e268d6))
48+
349
## [v3.3.0](https://github.com/contentstack/live-preview-sdk/compare/v3.2.5...v3.3.0)
450

551
> 24 July 2025
@@ -10,10 +56,15 @@
1056

1157
### General Changes
1258

59+
- v3.3.0 (Sairaj - [#474](https://github.com/contentstack/live-preview-sdk/pull/474))
1360
- Release 24 July to stage_v3 (Sairaj - [#473](https://github.com/contentstack/live-preview-sdk/pull/473))
1461
- HoverToolbar: Requested Changes (Ayush Dubey - [#464](https://github.com/contentstack/live-preview-sdk/pull/464))
1562
- [Feature] HoverToolbar (Ayush Dubey - [#455](https://github.com/contentstack/live-preview-sdk/pull/455))
1663

64+
### Chores And Housekeeping
65+
66+
- chore:increment package version (Aditya Pachauri - [950170c](https://github.com/contentstack/live-preview-sdk/commit/950170c321a8850d6854b9c09f27e6522a5c5798))
67+
1768
## [v3.2.5](https://github.com/contentstack/live-preview-sdk/compare/v3.2.4...v3.2.5)
1869

1970
> 10 July 2025
@@ -121,6 +172,7 @@
121172

122173
- v3.2.2 (Hitesh Shetty - [#435](https://github.com/contentstack/live-preview-sdk/pull/435))
123174
- Stage v3.2.2 (Hitesh Shetty - [#433](https://github.com/contentstack/live-preview-sdk/pull/433))
175+
- v3.2.1 (Faraaz Biyabani - [#430](https://github.com/contentstack/live-preview-sdk/pull/430))
124176

125177
### Fixes
126178

@@ -150,14 +202,15 @@
150202
### General Changes
151203

152204
- secrets-scan.yml (Aravind Kumar - [f9c5068](https://github.com/contentstack/live-preview-sdk/commit/f9c5068f3996d39aa73dcabac788950903513e32))
205+
- policy-scan.yml (Aravind Kumar - [7ae545b](https://github.com/contentstack/live-preview-sdk/commit/7ae545b3167869dc01874c8a75ffaff118d0d00a))
153206
- talismanrc file updated (Aravind Kumar - [8a70888](https://github.com/contentstack/live-preview-sdk/commit/8a70888d24083ff4f5f9c2878d3b94661dabbd08))
154207
- Updated codeowners (Aravind Kumar - [86bc538](https://github.com/contentstack/live-preview-sdk/commit/86bc538fc3f1bb42f2d86cf39ae8568be94880dd))
155208
- issues-jira.yml (Aravind Kumar - [84a292c](https://github.com/contentstack/live-preview-sdk/commit/84a292cc28491bdab4ea9ab819594de320a99e8e))
156209
- policy-scan.yml (Aravind Kumar - [55a2765](https://github.com/contentstack/live-preview-sdk/commit/55a2765deefc7ba4ebc91e2af07496834ee3dce3))
157210

158211
## [v3.2.1](https://github.com/contentstack/live-preview-sdk/compare/v3.2.0...v3.2.1)
159212

160-
> 24 April 2025
213+
> 23 April 2025
161214
162215
### Fixes
163216

@@ -169,7 +222,6 @@
169222

170223
### General Changes
171224

172-
- v3.2.1 (Faraaz Biyabani - [#430](https://github.com/contentstack/live-preview-sdk/pull/430))
173225
- Stage-v3.2.1 (Faraaz Biyabani - [#428](https://github.com/contentstack/live-preview-sdk/pull/428))
174226

175227
### Fixes
@@ -195,7 +247,6 @@
195247
- Delete jira.yml (Aravind Kumar - [80a496c](https://github.com/contentstack/live-preview-sdk/commit/80a496c805ce52542221f9bafa11116211f24f73))
196248
- issues-jira.yml (Aravind Kumar - [a429983](https://github.com/contentstack/live-preview-sdk/commit/a4299833949c80c274abd8af8ae81062fd78556f))
197249
- policy-scan.yml (Aravind Kumar - [a4b69a0](https://github.com/contentstack/live-preview-sdk/commit/a4b69a07a50b0d8145122bf99b330c3b22d91e8f))
198-
- policy-scan.yml (Aravind Kumar - [7ae545b](https://github.com/contentstack/live-preview-sdk/commit/7ae545b3167869dc01874c8a75ffaff118d0d00a))
199250
- Delete sast-scan.yml (Aravind Kumar - [c0bffef](https://github.com/contentstack/live-preview-sdk/commit/c0bffefd3a100a96117b080bd5cd7d2f6302deea))
200251
- Updated codeowners (Aravind Kumar - [b759727](https://github.com/contentstack/live-preview-sdk/commit/b759727225ca20ee5e4b5addb8783a87eb8bc385))
201252
- codeql-analysis.yml (Aravind Kumar - [d90af9f](https://github.com/contentstack/live-preview-sdk/commit/d90af9f61ed6fca7f4fdfac6ad6993006ed771ea))

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@3.2.5';
19+
import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@3.4.0';
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": "3.3.0",
3+
"version": "3.4.0",
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/livePreview/__test__/live-preview.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ describe("incoming postMessage", () => {
432432

433433
describe("testing window event listeners", () => {
434434
let addEventListenerMock: any;
435-
let sendInitEvent = vi.fn().mockImplementation(mockLivePreviewInitEventListener);
435+
const sendInitEvent = vi.fn().mockImplementation(mockLivePreviewInitEventListener);
436436
let livePreviewInstance: LivePreview;
437437

438438
beforeEach(() => {

src/livePreview/eventManager/postMessageEvent.hooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Config, { setConfigFromParams } from "../../configManager/configManager";
22
import { ILivePreviewWindowType } from "../../types/types";
3-
import { addParamsToUrl } from "../../utils";
3+
import { addParamsToUrl, isOpeningInTimeline } from "../../utils";
44
import livePreviewPostMessage from "./livePreviewEventManager";
55
import { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from "./livePreviewEventManager.constant";
66
import {
@@ -95,7 +95,7 @@ export function sendInitializeLivePreviewPostMessageEvent(): void {
9595
// "init message did not contain contentTypeUid or entryUid."
9696
// );
9797
}
98-
if (Config.get().ssr) {
98+
if (Config.get().ssr || isOpeningInTimeline()) {
9999
addParamsToUrl();
100100
}
101101
Config.set("windowType", windowType);
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { describe, test, expect, vi, beforeEach } from "vitest";
2+
import { addLivePreviewQueryTags } from "../addLivePreviewQueryTags";
3+
import { PublicLogger } from "../../logger/logger";
4+
5+
// Mock the logger
6+
vi.mock("../../logger/logger", () => ({
7+
PublicLogger: {
8+
error: vi.fn(),
9+
},
10+
}));
11+
12+
describe("addLivePreviewQueryTags", () => {
13+
beforeEach(() => {
14+
vi.clearAllMocks();
15+
});
16+
17+
test("should return original URL when no live preview parameters in current location", () => {
18+
// This test works with current document.location (likely has no live preview params)
19+
const targetUrl = "http://example.com/target-page";
20+
21+
const result = addLivePreviewQueryTags(targetUrl);
22+
23+
// Should return unchanged since no live preview params in current location
24+
expect(result).toBe(targetUrl);
25+
});
26+
27+
test("should log error and return original link when target URL is invalid", () => {
28+
const targetUrl = "not-a-valid-url-at-all-invalid";
29+
30+
const result = addLivePreviewQueryTags(targetUrl);
31+
32+
expect(PublicLogger.error).toHaveBeenCalledWith("Error while adding live preview to URL");
33+
expect(result).toBe(targetUrl);
34+
});
35+
36+
test("should handle empty string input", () => {
37+
const targetUrl = "";
38+
39+
const result = addLivePreviewQueryTags(targetUrl);
40+
41+
expect(PublicLogger.error).toHaveBeenCalledWith("Error while adding live preview to URL");
42+
expect(result).toBe(targetUrl);
43+
});
44+
45+
test("should handle malformed URLs gracefully", () => {
46+
const targetUrl = "http://";
47+
48+
const result = addLivePreviewQueryTags(targetUrl);
49+
50+
expect(PublicLogger.error).toHaveBeenCalledWith("Error while adding live preview to URL");
51+
expect(result).toBe(targetUrl);
52+
});
53+
54+
test("should handle valid URLs without errors", () => {
55+
const targetUrl = "https://example.com/valid-page";
56+
57+
const result = addLivePreviewQueryTags(targetUrl);
58+
59+
// Should not throw errors and return some result
60+
expect(typeof result).toBe("string");
61+
expect(result.length).toBeGreaterThan(0);
62+
});
63+
64+
test("should add live preview query tags to URL with all required query parameters", () => {
65+
const originalUrl =
66+
"http://example.com?live_preview=hash&content_type_uid=ctuid&entry_uid=entryuid";
67+
const expectedUrl =
68+
"http://example.com/?live_preview=hash&content_type_uid=ctuid&entry_uid=entryuid";
69+
70+
global.window = Object.create(window);
71+
Object.defineProperty(window, "location", {
72+
value: {
73+
href: originalUrl,
74+
},
75+
writable: true,
76+
});
77+
const result = addLivePreviewQueryTags(originalUrl);
78+
79+
expect(result).toEqual(expectedUrl);
80+
});
81+
});

0 commit comments

Comments
 (0)