-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: simulate cross-origin iframe in editor demo page
- Loading branch information
1 parent
244c7fb
commit 4c83cd3
Showing
5 changed files
with
53 additions
and
37 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
packages/editor/demo/iframed-editor-and-preview/index.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<html lang="en" style="height: 100%"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Editor & Preview (iframed)</title> | ||
</head> | ||
<body style="margin: 0; height: 100%"> | ||
<div id="root" style="height: 100%"></div> | ||
<script | ||
type="module" | ||
src="/src/___dev-demo/iframed-editor-and-preview.tsx" | ||
></script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
26 changes: 26 additions & 0 deletions
26
packages/editor/src/___dev-demo/iframed-editor-and-preview.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { createRoot } from 'react-dom/client' | ||
|
||
createRoot(document.getElementById('root')!).render( | ||
<iframe | ||
style={{ width: '100%', height: '100%', borderWidth: '0' }} | ||
// Embedding localhost:3001 on host page localhost:3000 simulates cross-origin. Important because a lot of iframe, cookie, CSP security measures are only in effect for cross-origin iframes. | ||
src="http://localhost:3001/demo/react-preview/" | ||
sandbox={` | ||
allow-downloads | ||
allow-forms | ||
allow-modals | ||
allow-popups | ||
allow-popups-to-escape-sandbox | ||
allow-presentation | ||
allow-same-origin | ||
allow-scripts | ||
allow-storage-access-by-user-activation | ||
`} | ||
allow={` | ||
clipboard-read https://editor.serlo.org https://staging.editor.serlo.org https://dev.editor.serlo.org https://editor.serlo-staging.dev; | ||
clipboard-write https://editor.serlo.org https://staging.editor.serlo.org https://dev.editor.serlo.org https://editor.serlo-staging.dev; | ||
fullscreen https://editor.serlo.org https://staging.editor.serlo.org https://dev.editor.serlo.org https://editor.serlo-staging.dev; | ||
autoplay https://editor.serlo.org https://staging.editor.serlo.org https://dev.editor.serlo.org https://editor.serlo-staging.dev | ||
`} | ||
></iframe> | ||
) |