Skip to content

[Preview NG] Replace deprecated ChangeHandler with typed onChange signatures#3588

Open
jeremywiebe wants to merge 3 commits intojer/preview-ng-7-add-preview-with-iframefrom
jer/preview-ng-7.5-typed-onchange
Open

[Preview NG] Replace deprecated ChangeHandler with typed onChange signatures#3588
jeremywiebe wants to merge 3 commits intojer/preview-ng-7-add-preview-with-iframefrom
jer/preview-ng-7.5-typed-onchange

Conversation

@jeremywiebe
Copy link
Copy Markdown
Collaborator

@jeremywiebe jeremywiebe commented May 6, 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:

--

Editor and ArticleEditor were using ChangeHandler (and Changeable.ChangeableProps), a deprecated signature whose callback and silent parameters were dead code throughout the codebase. This replaces both with concrete typed signatures so they are accurate and don't include data that the editor doesn't actually dispatch.

Note: This change ripples in a few places worth flagging in review. Inside ArticleEditor, removing Changeable.ChangeableProps lets us drop the local RendererProps shim type that existed only to widen the parameter; the affected helpers (_updateIssues, _sections, _handleEditorChange, _apiOptionsForSection, getSaveWarnings) now use PerseusRenderer / PerseusArticle directly. In editor.tsx, two props.onChange call sites previously used the trailing callback parameter to position the cursor after a synchronous text replacement; that side-effect is dropped here because no caller actually wired it through, and the cursor positioning code wasn't reachable in practice.

Issue: LEMS-3741

Test plan:

  • pnpm tsc
  • pnpm test
  • pnpm lint

…with typed onChange signatures on Editor and ArticleEditor
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🗄️ Schema Change: No Changes ✅

@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 (69a91a1) and published it to npm. You
can install it using the tag PR3588.

Example:

pnpm add @khanacademy/perseus@PR3588

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

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

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

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Size Change: -76 B (-0.02%)

Total Size: 503 kB

📦 View Changed
Filename Size Change
packages/perseus-editor/dist/es/index.js 104 kB -76 B (-0.07%)
ℹ️ 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 6, 2026

🛠️ Item Splitting: No Changes ✅

@jeremywiebe jeremywiebe marked this pull request as ready for review May 6, 2026 19:19
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.

@jeremywiebe jeremywiebe requested review from a team, catandthemachines and nishasy May 6, 2026 20:27
The new signatures are `onChange: (changes: Partial<PerseusRenderer>) => void` for `Editor` and `onChange: (changes: {json: PerseusArticle}) => void` for `ArticleEditor`.
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