-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JS editor to playground #679
Conversation
wkazmierczak
commented
Aug 20, 2024
•
edited
Loading
edited
- Add JS editor to playground
- Make entered code runnable
937264f
to
2a28b95
Compare
2a28b95
to
2278ff1
Compare
a70d5d4
to
fa9cf49
Compare
docs/src/reactEditor.d.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monacoEditor
docs/src/playgroundReactRunner.ts
Outdated
/** | ||
* from https://github.com/facebook/react/blob/d906de7f602df810c38aa622c83023228b047db6/scripts/babel/transform-prevent-infinite-loops.js | ||
*/ | ||
// biome-ignore lint/suspicious/noExplicitAny: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// biome-ignore lint/suspicious/noExplicitAny: |
docs/src/playgroundReactRunner.ts
Outdated
}; | ||
}; | ||
|
||
export default async function playgroundReactRunner(code: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name implies that this returns some statetfull runner, but If I understand correctly this is a single run
export default async function playgroundReactRunner(code: string) { | |
export default async function executeTypescriptCode(code: string) { |
docs/src/playgroundReactRunner.ts
Outdated
import type TemplateGenerator from '@babel/template'; | ||
import { tsCompilerOptions } from './monacoEditorConfig'; | ||
|
||
function tsToJs(code: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe inline that, not sure if extracting this to function helps here
docs/src/pages/playground.tsx
Outdated
useEffect(() => { | ||
const params = new URLSearchParams(window.location.search); | ||
const codeEditorMode = params.get('mode'); | ||
if (codeEditorMode === 'react') { | ||
setShowReactEditor(true); | ||
} else { | ||
setShowReactEditor(false); | ||
} | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useEffect(() => { | |
const params = new URLSearchParams(window.location.search); | |
const codeEditorMode = params.get('mode'); | |
if (codeEditorMode === 'react') { | |
setShowReactEditor(true); | |
} else { | |
setShowReactEditor(false); | |
} | |
}, []); | |
const showReactEditor = new URLSearchParams(window.location.search).get('mode') === 'react'; |
wouldn't this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error while building, because of client-side only code, but i have refactor this useEffect to make it simpler