Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5f386ed
Create new preview renderer + build config
mwtrew Mar 27, 2026
013e419
Wait for renderer to be ready
mwtrew Mar 27, 2026
50ad8f6
Merge branch 'main' of github.com:RaspberryPiFoundation/editor-ui int…
mwtrew Mar 30, 2026
6ba5dde
Remove unused inline style
mwtrew Mar 30, 2026
eb74fb2
Remove obsolete HtmlRunner tests
mwtrew Mar 31, 2026
9c063f0
Update Cypress tests, handle links as before
mwtrew Mar 31, 2026
b7ce17e
Remove assertions from Cypress util functions
mwtrew Apr 6, 2026
8ccd3e6
Enforce allowed iframe message origins and use type field to identify…
mwtrew Apr 6, 2026
021daa8
Skip HTML editor tests
mwtrew Apr 7, 2026
6a4f54e
Skip remaining failing test
mwtrew Apr 8, 2026
1fb8099
Deploy HTML renderer to R2
mwtrew Apr 8, 2026
287e062
Add path to HTML renderer URL
mwtrew Apr 8, 2026
1bbd22a
Merge branch 'main' into 1264_cross-origin-html-preview
mwtrew Apr 8, 2026
08fe169
Use correct target origins for posted messages
mwtrew Apr 8, 2026
2e3e1f0
Merge branch '1264_cross-origin-html-preview' of github.com:Raspberry…
mwtrew Apr 8, 2026
75d7d45
Remove obsolete iframe reload logic
mwtrew Apr 9, 2026
f85c73d
Move HTML editor tests to E2E repo
mwtrew Apr 9, 2026
85e635a
Merge branch 'main' into 1264_cross-origin-html-preview
mwtrew Apr 9, 2026
089cdb6
Remove broken embedded mode test
mwtrew Apr 9, 2026
ce0d221
Remove todo
mwtrew Apr 9, 2026
b58d9c2
Fix embedded mode styling
mwtrew Apr 9, 2026
4873451
Resolve merge conflict
mwtrew Apr 9, 2026
3820c35
Fix typo in cache clear command
mwtrew Apr 9, 2026
edad908
Remove todo in webpack config
mwtrew Apr 9, 2026
1eae90b
Remove unused import
mwtrew Apr 9, 2026
49cbee5
Update HTML runner test
mwtrew Apr 10, 2026
9ddf0e5
Resolve merge conflict
mwtrew Apr 10, 2026
948c616
Correct syntax error in cache clear command
mwtrew Apr 10, 2026
b6741eb
Restore HtmlRunner unit tests where possible
mwtrew Apr 10, 2026
46839e8
Move remaining component tests to HtmlRenderer
mwtrew Apr 10, 2026
34864ea
Merge branch 'main' into 1264_cross-origin-html-preview
mwtrew Apr 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ REACT_APP_SENTRY_DSN=''
REACT_APP_SENTRY_ENV='local'
PUBLIC_URL='http://localhost:3011'
ASSETS_URL='http://localhost:3011'
HTML_RENDERER_URL='http://localhost:3003'
REACT_APP_GOOGLE_TAG_MANAGER_ID=''
REACT_APP_API_ENDPOINT='http://localhost:3009'
REACT_APP_PLAUSIBLE_DATA_DOMAIN=''
REACT_APP_PLAUSIBLE_SOURCE=''
REACT_APP_ALLOWED_IFRAME_ORIGINS='http://localhost:3011,http://localhost:3012'
REACT_APP_ALLOWED_IFRAME_ORIGINS='http://localhost:3011,http://localhost:3012'
23 changes: 17 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
required: false
default: "https://staging-editor-static.raspberrypi.org"
type: string
html_renderer_url:
required: false
default: "https://staging-editor-static.raspberrypi.org"
type: string
react_app_api_endpoint:
required: false
default: "https://staging-editor-api.raspberrypi.org"
Expand Down Expand Up @@ -62,7 +66,7 @@ on:
required: false
default: "https://staging-editor.raspberrypi.org,https://staging-editor-static.raspberrypi.org,https://test-editor.raspberrypi.org"
type: string

secrets:
AWS_ACCESS_KEY_ID:
required: false
Expand All @@ -86,6 +90,7 @@ jobs:
deploy_dir: ${{ steps.setup-environment.outputs.deploy_dir }}
public_url: ${{ steps.setup-environment.outputs.public_url }}
assets_url: ${{ steps.setup-environment.outputs.assets_url }}
html_renderer_url: ${{ steps.setup-environment.outputs.html_renderer_url }}
react_app_base_url: ${{ steps.setup-environment.outputs.react_app_base_url }}
steps:
- id: setup-environment
Expand All @@ -94,9 +99,11 @@ jobs:
deploy_dir=${{inputs.prefix}}/$safe_ref_name
public_url=${{inputs.base_url}}/$deploy_dir
assets_url=${{inputs.assets_url}}/$deploy_dir
html_renderer_url=${{inputs.html_renderer_url}}/$deploy_dir/html-renderer
echo "deploy_dir=$deploy_dir" >> $GITHUB_OUTPUT
echo "public_url=$public_url" >> $GITHUB_OUTPUT
echo "assets_url=$assets_url" >> $GITHUB_OUTPUT
echo "html_renderer_url=$html_renderer_url" >> $GITHUB_OUTPUT
if [ "${{inputs.react_app_base_url}}" = "unspecified" ] ; then
echo "react_app_base_url=$deploy_dir" >> $GITHUB_OUTPUT
else
Expand Down Expand Up @@ -139,6 +146,7 @@ jobs:
env:
PUBLIC_URL: ${{ needs.setup-environment.outputs.public_url }}
ASSETS_URL: ${{ needs.setup-environment.outputs.assets_url }}
HTML_RENDERER_URL: ${{ needs.setup-environment.outputs.html_renderer_url }}
REACT_APP_API_ENDPOINT: ${{ inputs.react_app_api_endpoint }}
REACT_APP_AUTHENTICATION_CLIENT_ID: ${{ inputs.react_app_authentication_client_id }}
REACT_APP_AUTHENTICATION_URL: ${{ inputs.react_app_authentication_url }}
Expand All @@ -151,11 +159,18 @@ jobs:
REACT_APP_SENTRY_ENV: ${{ inputs.react_app_sentry_env }}
REACT_APP_ALLOWED_IFRAME_ORIGINS: ${{ inputs.react_app_allowed_iframe_origins }}

- name: Build HTML renderer bundle
run: yarn build-html-renderer
env:
HTML_RENDERER_URL: ${{ needs.setup-environment.outputs.html_renderer_url }}
REACT_APP_ALLOWED_IFRAME_ORIGINS: ${{ inputs.react_app_allowed_iframe_origins }}

- name: Deploy site to S3 bucket
if: env.AWS_SECRET_ACCESS_KEY != ''
run: |
aws s3 sync ./build/ s3://${{ secrets.AWS_S3_BUCKET }}/${{ needs.setup-environment.outputs.deploy_dir }} --endpoint ${{ secrets.AWS_ENDPOINT }} --progress-frequency 5
aws s3 sync ./build/chunks/ s3://${{ secrets.AWS_S3_BUCKET }}/chunks/ --endpoint ${{ secrets.AWS_ENDPOINT }} --exclude "*" --include "fetch-worker*" --progress-frequency 5
aws s3 sync ./build-html-renderer/ s3://${{ secrets.AWS_S3_BUCKET }}/${{ needs.setup-environment.outputs.deploy_dir }}/html-renderer/ --endpoint ${{ secrets.AWS_ENDPOINT }} --progress-frequency 5
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -170,10 +185,6 @@ jobs:
fi

echo -n "${{ needs.setup-environment.outputs.deploy_dir }}" | aws s3 cp - s3://${{ secrets.AWS_S3_BUCKET }}/latest_version --endpoint ${{ secrets.AWS_ENDPOINT }} --content-type "text/plain"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}

- name: Purge Cloudflare cache
if: env.HAS_CLOUDFLARE_SECRETS == 'true'
Expand All @@ -182,7 +193,7 @@ jobs:
curl -sS --fail-with-body -X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
-H "Content-Type: application/json" \
--data '{"files":["${{ needs.setup-environment.outputs.public_url }}/web-component.html", "${{ needs.setup-environment.outputs.public_url }}/web-component.js", "${{ needs.setup-environment.outputs.public_url }}/scratch.html", "${{ needs.setup-environment.outputs.public_url }}/scratch.js", "${{ inputs.base_url }}/latest_version"]}'
--data '{"files":["${{ needs.setup-environment.outputs.public_url }}/web-component.html", "${{ needs.setup-environment.outputs.public_url }}/web-component.js", "${{ needs.setup-environment.outputs.public_url }}/scratch.html", "${{ needs.setup-environment.outputs.public_url }}/scratch.js", "${{ inputs.base_url }}/latest_version", "${{ needs.setup-environment.outputs.html_renderer_url}}/index.html", "${{ needs.setup-environment.outputs.html_renderer_url}}/html-renderer.js"]}'
)" || {
echo "Cloudflare purge request failed:"
echo "$response"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ node_modules

# production
/build
/build-html-renderer
/public/storybook

# misc
Expand All @@ -33,3 +34,4 @@ yarn-error.log*
.yarn/install-state.gz

.vscode/settings.json
.idea/*
126 changes: 0 additions & 126 deletions cypress/e2e/spec-html.cy.js

This file was deleted.

25 changes: 0 additions & 25 deletions cypress/e2e/spec-wc.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
expectHtmlRunnerPreviewToContainText,
getCodeEditorInput,
getEditorShadow,
getRunButton,
Expand Down Expand Up @@ -148,28 +147,4 @@ describe("when embedded, output_only & output_split_view are true", () => {
getSkulptTabByName("Visual output").should("be.visible");
getSkulptTabByName("Visual output").should("have.length", 1);
});

it("displays the embedded view for an HTML project", () => {
cy.visit(urlFor("anime-expressions-solution"));

// Check HTML preview output panel is visible and has a run button
// Important to wait for this before making the negative assertions that follow
getEditorShadow().contains("index.html preview").should("be.visible");
getRunButton().should("not.be.disabled");
getRunButton().should("be.visible");

// Check that the code has automatically run i.e. the HTML has been rendered
expectHtmlRunnerPreviewToContainText("Draw anime with me");

// Check that the side bar is not displayed
getEditorShadow().should("not.contain.text", "Project files");
// Check that the project bar is not displayed
getEditorShadow().should("not.contain.text", "Anime expressions solution");
// Check that the editor input containing the code is not displayed
getEditorShadow().should("not.contain.text", "<h1>Draw anime with me</h1>");

// Run the code and check it executed without error
runProject();
cy.get("#results").should("contain", '"errorDetails":{}');
});
});
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
},
"scripts": {
"start": "NODE_ENV=development BABEL_ENV=development webpack serve -c ./webpack.config.js",
"start-html-renderer": "NODE_ENV=development BABEL_ENV=development webpack serve -c ./webpack.html-renderer.config.js",
"build": "NODE_ENV=production BABEL_ENV=production webpack build -c ./webpack.config.js",
"build-html-renderer": "NODE_ENV=production BABEL_ENV=production webpack build -c ./webpack.html-renderer.config.js",
"analyze": "ANALYZE_WEBPACK_BUNDLE=true yarn build",
"lint": "eslint 'src/**/*.{js,jsx}' cypress/**/*.js",
"lint:fix": "eslint --fix 'src/**/*.{js,jsx}' cypress/**/*.js",
Expand Down
20 changes: 20 additions & 0 deletions public/index-html-renderer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" href="data:," />
<title>Editor HTML preview</title>
<style>
html,
body,
#root {
block-size: 100%;
margin: 0;
}
</style>
</head>
<body>
<div id="root"></div>
</body>
</html>
15 changes: 15 additions & 0 deletions src/assets/stylesheets/HtmlRunner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ a.htmlrunner-link {
block-size: 100%;
inline-size: 100%;
}

.htmlrenderer-root {
box-sizing: border-box;
display: flex;
flex-direction: column;
min-block-size: 0;
block-size: 100%;
inline-size: 100%;

.htmlrunner-iframe {
flex: 1 1 auto;
min-block-size: 0;
block-size: auto;
}
}
Loading
Loading