Skip to content

Commit 3cab914

Browse files
committed
adding iframe console into actual editor and getting it autorunning with query string
1 parent 9cad48d commit 3cab914

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/assets/stylesheets/PythonRunner.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
white-space: -moz-pre-wrap;
1818
white-space: -pre-wrap;
1919
white-space: -o-pre-wrap;
20-
width: 100%;
2120
word-wrap: break-word;
2221
overflow-y: auto;
2322

src/components/Editor/Output/Output.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const Output = ({ outputPanels = ["text", "visual"], autoRun = false }) => {
99
const isEmbedded = useSelector((state) => state.editor.isEmbedded);
1010
const searchParams = new URLSearchParams(window.location.search);
1111
const isBrowserPreview = searchParams.get("browserPreview") === "true";
12+
const isAutoRun = autoRun || searchParams.get("autoRun") === "true";
1213

1314
return (
1415
<>
@@ -17,7 +18,7 @@ const Output = ({ outputPanels = ["text", "visual"], autoRun = false }) => {
1718
<RunnerFactory
1819
projectType={project.project_type}
1920
outputPanels={outputPanels}
20-
autoRun={autoRun}
21+
autoRun={isAutoRun}
2122
/>
2223
{isEmbedded && !isBrowserPreview && <RunBar embedded />}
2324
</div>

src/components/Editor/Runners/PythonRunner/PyodideRunner/PyodideRunner.jsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const PyodideRunner = (props) => {
5656
const settings = useContext(SettingsContext);
5757
const isMobile = useMediaQuery({ query: MOBILE_MEDIA_QUERY });
5858
const senseHatAlways = useSelector((s) => s.editor.senseHatAlwaysEnabled);
59+
const isOutputOnly = useSelector((state) => state.editor.isOutputOnly);
5960
const queryParams = new URLSearchParams(window.location.search);
6061
const showVisualTab = queryParams.get("show_visual_tab") === "true";
6162
const [hasVisual, setHasVisual] = useState(showVisualTab || senseHatAlways);
@@ -78,6 +79,10 @@ const PyodideRunner = (props) => {
7879
};
7980
const [inputStackIndex, setInputStackIndex] = useState(0);
8081

82+
useEffect(() => {
83+
console.log("isOutputOnly", isOutputOnly);
84+
});
85+
8186
useEffect(() => {
8287
const handleKeyDown = (event) => {
8388
if (event.key === "ArrowUp") {
@@ -414,6 +419,11 @@ const PyodideRunner = (props) => {
414419
{t("output.textOutput")}
415420
</span>
416421
</Tab>
422+
{!isOutputOnly && (
423+
<Tab key={1}>
424+
<span className="react-tabs__tab-text">Console</span>
425+
</Tab>
426+
)}
417427
</TabList>
418428
{!hasVisual && !isEmbedded && isMobile && (
419429
<RunnerControls skinny />
@@ -427,6 +437,16 @@ const PyodideRunner = (props) => {
427437
ref={output}
428438
></pre>
429439
</TabPanel>
440+
{!isOutputOnly && (
441+
<TabPanel key={1}>
442+
<iframe
443+
title="console"
444+
src="http://localhost:3012/en/embed/viewer/ipython-console?browserPreview=true&autoRun=true"
445+
crossOrigin
446+
style={{ width: "100%", height: "100%" }}
447+
/>
448+
</TabPanel>
449+
)}
430450
</Tabs>
431451
</div>
432452
</>
@@ -446,6 +466,11 @@ const PyodideRunner = (props) => {
446466
{t("output.textOutput")}
447467
</span>
448468
</Tab>
469+
{/* {!isOutputOnly && (
470+
<Tab key={2}>
471+
<span className="react-tabs__tab-text">Console</span>
472+
</Tab>
473+
)} */}
449474
</TabList>
450475
{!isEmbedded && hasVisual && <OutputViewToggle />}
451476
{!isEmbedded && isMobile && <RunnerControls skinny />}
@@ -463,6 +488,20 @@ const PyodideRunner = (props) => {
463488
ref={output}
464489
></pre>
465490
</TabPanel>
491+
{/* {!isOutputOnly && (
492+
<TabPanel key={2}>
493+
<editor-wc
494+
autoRun={true}
495+
class="c-editor__wc"
496+
code={`from IPython import embed\nembed()`}
497+
load_remix_disabled={true}
498+
embedded={false}
499+
output_only={true}
500+
output_split_view={false}
501+
use_editor_styles={true}
502+
></editor-wc>
503+
</TabPanel>
504+
)} */}
466505
</Tabs>
467506
)}
468507
</div>

0 commit comments

Comments
 (0)