[Preview NG] Rename preview data field names and unify article-all apiOptions#3590
Open
jeremywiebe wants to merge 4 commits intojer/preview-ng-8-migrate-storybook-and-editorsfrom
Open
Conversation
…es: drop initialHintsVisible, rename json to article, simplify article-all to single shared apiOptions
Contributor
🗄️ Schema Change: No Changes ✅ |
Contributor
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (557dad9) and published it to npm. You Example: pnpm add @khanacademy/perseus@PR3590If you are working in Khan Academy's frontend, you can run the below command. ./dev/tools/bump_perseus_version.ts -t PR3590If you are working in Khan Academy's webapp, you can run the below command. ./dev/tools/bump_perseus_version.js -t PR3590 |
Contributor
🛠️ Item Splitting: No Changes ✅ |
There was a problem hiding this comment.
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.
…ld names in preview messages realted to articles (no longer `json`, now `article` or `section` as needed)
Contributor
|
Size Change: -43 B (-0.01%) Total Size: 504 kB 📦 View Changed
ℹ️ View Unchanged
|
…o we don't have code that does `data.data.` 🤦
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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+ rawpostMessage(string)communication with structured, validated message passing viausePreviewControllerandusePreviewPresenterhooks. 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:
--
Now that the editors and storybook preview page are migrated to the new preview system (#3581), this PR tightens up the preview data shapes. Three changes, all internal to
@khanacademy/perseus-editor:ArticlePreviewData.jsonbecomesarticle. Thejsonname was a leftover from when sections were stored as raw JSON strings; the type already held aPerseusRendererand callers all referred to it by content role, so the new name reflects what's actually there. The type is also tightened fromPerseusArticle(which isPerseusRenderer | PerseusRenderer[]) to justPerseusRenderer—ArticlePreviewDatais now strictly the single-section shape used in edit mode.A new
ArticleAllPreviewDatareplaces the oldArticlePreviewData[]shape used for the all-sections preview. The new type is{article: ReadonlyArray<PerseusRenderer>, apiOptions: APIOptions}— a single sharedapiOptionsrather than the previous per-section duplication.linterContextwas dropped here because article-all is the read-only "preview" view (not the editing surface), so per-section linter context isn't needed.QuestionPreviewData.initialHintsVisibleis removed. It was always hardcoded to 0 at every call site, and the renderer now hardcodeshintsVisible={0}directly.These shapes aren't observed outside the editor package today (the message types aren't part of the public API surface —
index.tsexports the hooks but not the types), so this is a no-op for any external consumer. Thepreview-data-sanitizercollapsed too — there's only oneapiOptionsto sanitize regardless of content type now, so the per-section loop in the article-all branch went away.Issue: LEMS-3741
Test plan:
pnpm tscpnpm lintpnpm test