Skip to content

Add onJsonModeChange callback to EditorPage - #4188

Open
benchristel wants to merge 2 commits into
mainfrom
benc/onJsonModeChange
Open

Add onJsonModeChange callback to EditorPage#4188
benchristel wants to merge 2 commits into
mainfrom
benc/onJsonModeChange

Conversation

@benchristel

Copy link
Copy Markdown
Member

Summary:

The plan is to remove jsonMode from onChange, so onChange can just accept
a PerseusItem.

Issue: LEMS-4570

Test plan:

CI checks should pass.

…`onJsonModeChange` prop to inform clients of when JSON mode is toggled. The `jsonMode` parameter to `onChange` is deprecated.
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

npm Snapshot

Want to try this PR's changes before it merges? Comment /snapshot below and we'll publish an npm snapshot you can install right away.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Size Change: +20 B (0%)

Total Size: 513 kB

📦 View Changed
Filename Size Change
packages/perseus-editor/dist/es/index.js 105 kB +20 B (+0.02%)
ℹ️ 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.7 kB
packages/math-input/dist/es/strings.js 1.63 kB
packages/perseus-core/dist/es/index.item-splitting.js 13.3 kB
packages/perseus-core/dist/es/index.js 28.7 kB
packages/perseus-linter/dist/es/index.js 10.3 kB
packages/perseus-score/dist/es/index.js 9.91 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/index.js 196 kB
packages/perseus/dist/es/strings.js 12.9 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.12 kB

compressed-size-action

const newJsonMode = !this.props.jsonMode;
this.props.onChange({
jsonMode: !this.props.jsonMode,
jsonMode: newJsonMode,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just rip the bandaid and remove this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't want the next person to release Perseus to be blocked by having to update all onChange callbacks.

"@khanacademy/perseus-editor": minor
---

`EditorPage` now accepts an `onJsonModeChange` prop to inform clients of when JSON mode is toggled. The `jsonMode` parameter to `onChange` is deprecated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder why we have two ways to switch to JSON mode: a switch outside of Perseus and a checkbox inside of Perseus?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Because originally the toggle was inside EditorPage and its availability was controlled by an APIOption (I can't remember what it was)... and then someone wanted it outside so we have both.

When we break the EditorPage down into smaller components, Perseus will no longer manage switching between views, we'll just export the editor and a JSON viewer/editor and consumers can do what they want.

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.

3 participants