Skip to content

feat: live preview: added outside iframe code#477

Merged
contentstackMridul merged 3 commits intolive-preview-outside-iframefrom
VE_6811
Aug 6, 2025
Merged

feat: live preview: added outside iframe code#477
contentstackMridul merged 3 commits intolive-preview-outside-iframefrom
VE_6811

Conversation

@contentstackMridul
Copy link
Copy Markdown
Contributor

@contentstackMridul contentstackMridul commented Aug 4, 2025

Summary
These commits introduce comprehensive support for live preview functionality when content is opened in new tabs (instead of iframes) and significantly improve Server-Side Rendering (SSR) handling with enhanced event management.

Key Changes

  1. New Tab Detection & Support
    Added inNewTab() utility function to detect when content is opened in a new browser tab
    Modified event manager to target window.opener instead of window.parent for new tab scenarios
    Updated edit button behavior to handle both iframe and new tab contexts
  2. Enhanced SSR Handling
    Implemented differentiated handling for Client-Side Rendering (CSR) vs Server-Side Rendering (SSR)
    Added automatic page reload for SSR websites when entry content changes
    Introduced event type metadata to distinguish between different update scenarios
  3. Advanced Event Management
    Added new event types: HASH_CHANGE and URL_CHANGE for granular control
    Implemented proper URL parameter updates using history.pushState() for hash changes
    Added robust error handling with logging for post message events
    Enhanced type definitions for live preview event data
  4. Bug Fixes & Cleanup
    Fixed URL change handling logic with proper null checking
    Removed debug console statements from production code
    Improved error boundaries around window operations

Test Results
Screenshot 2025-08-06 at 12 58 35

@contentstackMridul contentstackMridul requested a review from a team as a code owner August 4, 2025 10:39
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 4, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 72.49% 8651 / 11934
🔵 Statements 72.49% 8651 / 11934
🔵 Functions 71.83% 306 / 426
🔵 Branches 85.02% 1090 / 1282
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/common/inIframe.ts 85.71% 75% 100% 85.71% 13-14
src/livePreview/editButton/editButton.ts 97.08% 89.78% 95% 97.08% 107-109, 221-222, 266-267, 400-401, 563-566, 613-614
src/livePreview/eventManager/livePreviewEventManager.constant.ts 100% 100% 100% 100%
src/livePreview/eventManager/livePreviewEventManager.ts 100% 100% 100% 100%
src/livePreview/eventManager/postMessageEvent.hooks.ts 89.38% 90% 75% 89.38% 115-116, 129, 138, 151-159
src/livePreview/eventManager/types/livePreviewPostMessageEvent.type.ts 100% 100% 100% 100%
Generated in workflow #504 for commit dffe855 by the Vitest Coverage Report Action

Copy link
Copy Markdown

@KANE-99 KANE-99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@contentstackMridul contentstackMridul merged commit a3a14f6 into live-preview-outside-iframe Aug 6, 2025
10 checks passed
@contentstackMridul contentstackMridul deleted the VE_6811 branch August 6, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants