Skip to content

[Preview NG] Migrate Perseus to the new preview system#3581

Open
jeremywiebe wants to merge 8 commits intojer/preview-ng-7.5-typed-onchangefrom
jer/preview-ng-8-migrate-storybook-and-editors
Open

[Preview NG] Migrate Perseus to the new preview system#3581
jeremywiebe wants to merge 8 commits intojer/preview-ng-7.5-typed-onchangefrom
jer/preview-ng-8-migrate-storybook-and-editors

Conversation

@jeremywiebe
Copy link
Copy Markdown
Collaborator

@jeremywiebe jeremywiebe commented May 5, 2026

Summary:

This PR is part of a series building a typed, hook-based preview system for the Perseus editor. The new system replaces the untyped window.iframeDataStore + raw postMessage(string) communication with structured, validated message passing via usePreviewController and usePreviewPresenter hooks. The new system is being built alongside the old one — no existing behavior changes until the final PR in the series flips the switch.

Previous PRs in this series:


This is the Preview NG changeover PR! After this lands, Perseus will be exclusively using the new Preview communication system (no more legacy iframeDataStore + string-postMessage preview protocol). This means that all Storybook preview code now uses the new usePreviewPresenter hook, and all four editors (EditorPage, ArticleEditor, HintEditor, ItemEditor) switch from IframeContentRenderer to PreviewWithIframe (introduced in #3578).

The legacy IframeContentRenderer remains because some client's still use it directly. When this change is released, I will switch clients over as part of the Perseus release. The legacy component will be deleted in a later cleanup pass once that's done.

Screen.Recording.2026-05-06.at.1.20.24.PM.mov

NOTE: the issue of the keypad being clipped by the preview iframe is a longstanding issue and is unrelated to the changes in this PR.

Issue: LEMS-3741

Test plan:

  • pnpm tsc clean
  • pnpm lint clean for touched files
  • pnpm test
  • Reviewer: open Storybook, navigate to the editor stories, and confirm each editor's preview renders content (question, hint, article single section, article-all). The behaviour should be identical to main.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🗄️ Schema Change: No Changes ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Size Change: +399 B (+0.08%)

Total Size: 504 kB

📦 View Changed
Filename Size Change
packages/perseus-editor/dist/es/index.js 104 kB +399 B (+0.38%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.6 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.31 kB
packages/math-input/dist/es/index.js 98.5 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 12 kB
packages/perseus-core/dist/es/index.js 25.5 kB
packages/perseus-linter/dist/es/index.js 9.41 kB
packages/perseus-score/dist/es/index.js 9.78 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/index.js 198 kB
packages/perseus/dist/es/strings.js 8.5 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🛠️ Item Splitting: No Changes ✅

@jeremywiebe jeremywiebe changed the title [Preview NG] Migrate Storybook and editors to new preview system [Preview NG] Migrate Perseus to the new preview system May 6, 2026
@jeremywiebe jeremywiebe changed the base branch from jer/preview-ng-7-add-preview-with-iframe to jer/preview-ng-7.5-typed-onchange May 6, 2026 18:50
@jeremywiebe jeremywiebe force-pushed the jer/preview-ng-8-migrate-storybook-and-editors branch from a0b8f9f to 2d5913f Compare May 6, 2026 18:50
@github-actions github-actions Bot added item-splitting-change schema-change Attached to PRs when we detect Perseus Schema changes in it labels May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (9c745c5) and published it to npm. You
can install it using the tag PR3581.

Example:

pnpm add @khanacademy/perseus@PR3581

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3581

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3581

@github-actions github-actions Bot removed schema-change Attached to PRs when we detect Perseus Schema changes in it item-splitting-change labels May 6, 2026
@jeremywiebe jeremywiebe force-pushed the jer/preview-ng-8-migrate-storybook-and-editors branch from abdc9f8 to a366962 Compare May 6, 2026 19:25
};

// Store refs for preview iframes (keyed by section index or "all")
private frameRefs: Record<string, PreviewWithIframeRef | null> = {};
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This moves us away from string refs (see _updatePreviewFrames in it original form)

…grate-storybook-preview] Migrate storybook preview page from iframeDataStore to usePreviewPresenter hook
@jeremywiebe jeremywiebe force-pushed the jer/preview-ng-8-migrate-storybook-and-editors branch from ba3e0e6 to 56420cb Compare May 6, 2026 20:20
@jeremywiebe jeremywiebe marked this pull request as ready for review May 6, 2026 20:26
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant