Preview mode for the editor web component - #1610
Merged
Merged
Conversation
DNR500
temporarily deployed
to
previews/1610/merge
August 25, 2026 13:27 — with
GitHub Actions
Inactive
DNR500
force-pushed
the
add-preview-mode
branch
from
August 25, 2026 14:06
876e110 to
ec7bed1
Compare
DNR500
temporarily deployed
to
previews/1610/merge
August 25, 2026 14:06 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “preview mode” for the <editor-wc> web component so hosts can enable Scratch upload/download while keeping saving disabled, with read_only explicitly overriding preview behavior.
Changes:
- Introduces
editor.previewstate +setPreviewRedux action, wired from the web component attribute throughWebComponentLoader. - Adds
usePreviewMode/selectPreviewModehelper to enforce “preview only when not read-only”. - Updates Scratch project bar behavior (save + rename) and adds unit tests + README documentation for the new attribute.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/web-component.jsx | Adds preview to observed/boolean attributes so hosts can set <editor-wc preview="true">. |
| src/redux/EditorSlice.js | Adds preview to initial state and introduces setPreview reducer/action. |
| src/redux/EditorSlice.test.js | Adds unit test coverage for setPreview. |
| src/hooks/usePreviewMode.js | Adds selector + hook to compute effective preview mode (preview && !readOnly). |
| src/hooks/usePreviewMode.test.js | Adds unit tests for preview-mode selector behavior, including read-only override. |
| src/containers/WebComponentLoader.jsx | Plumbs preview prop into Redux via dispatch(setPreview(preview)). |
| src/containers/WebComponentLoader.test.jsx | Adds test verifying setPreview(true) is dispatched when preview prop is provided. |
| src/components/ProjectBar/ScratchProjectBar.jsx | Disables Scratch save + rename when preview mode is active; keeps upload gated by read-only. |
| src/components/ProjectBar/ScratchProjectBar.test.jsx | Adds preview-mode tests (upload/download shown, save hidden, no autosave; read-only override). |
| README.md | Documents the new preview attribute and the read_only precedence rule. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
DNR500
temporarily deployed
to
previews/1610/merge
August 25, 2026 14:29 — with
GitHub Actions
Inactive
DNR500
marked this pull request as ready for review
August 25, 2026 15:21
jamiebenstead
approved these changes
Aug 26, 2026
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.
Issue: 1655
Summary
Adds a
previewattribute on<editor-wc>so hosts (like Code Classroom’s Experience CS project preview) can let people try a project without saving it.Works for Python, HTML, and Scratch (Blocks).
Upload and download stay available where the editor already shows them. Saving, renaming, autosave, remix, and local backup stay off.
This is separate from
read_only, which is a locked-down view (no upload). If both are set,read_onlywins.Behaviour
When
preview="true"(andread_onlyis not set):Hosts that already use
read_onlyare unchanged.What changed
previewflagread_onlyis off)previewand wires it into app state (same idea asread_only)How hosts use it
Classroom’s preview page should use
preview, notread_only, once this build is available. See PR -https://github.com/RaspberryPiFoundation/editor-standalone/pull/1064