Skip to content

Commit

Permalink
adding iframe console into actual editor and getting it autorunning w…
Browse files Browse the repository at this point in the history
…ith query string
  • Loading branch information
loiswells97 committed Oct 30, 2024
1 parent 9cad48d commit 3cab914
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/assets/stylesheets/PythonRunner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
width: 100%;
word-wrap: break-word;
overflow-y: auto;

Expand Down
3 changes: 2 additions & 1 deletion src/components/Editor/Output/Output.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Output = ({ outputPanels = ["text", "visual"], autoRun = false }) => {
const isEmbedded = useSelector((state) => state.editor.isEmbedded);
const searchParams = new URLSearchParams(window.location.search);
const isBrowserPreview = searchParams.get("browserPreview") === "true";
const isAutoRun = autoRun || searchParams.get("autoRun") === "true";

return (
<>
Expand All @@ -17,7 +18,7 @@ const Output = ({ outputPanels = ["text", "visual"], autoRun = false }) => {
<RunnerFactory
projectType={project.project_type}
outputPanels={outputPanels}
autoRun={autoRun}
autoRun={isAutoRun}
/>
{isEmbedded && !isBrowserPreview && <RunBar embedded />}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const PyodideRunner = (props) => {
const settings = useContext(SettingsContext);
const isMobile = useMediaQuery({ query: MOBILE_MEDIA_QUERY });
const senseHatAlways = useSelector((s) => s.editor.senseHatAlwaysEnabled);
const isOutputOnly = useSelector((state) => state.editor.isOutputOnly);
const queryParams = new URLSearchParams(window.location.search);
const showVisualTab = queryParams.get("show_visual_tab") === "true";
const [hasVisual, setHasVisual] = useState(showVisualTab || senseHatAlways);
Expand All @@ -78,6 +79,10 @@ const PyodideRunner = (props) => {
};
const [inputStackIndex, setInputStackIndex] = useState(0);

useEffect(() => {
console.log("isOutputOnly", isOutputOnly);
});

useEffect(() => {
const handleKeyDown = (event) => {
if (event.key === "ArrowUp") {
Expand Down Expand Up @@ -414,6 +419,11 @@ const PyodideRunner = (props) => {
{t("output.textOutput")}
</span>
</Tab>
{!isOutputOnly && (
<Tab key={1}>
<span className="react-tabs__tab-text">Console</span>
</Tab>
)}
</TabList>
{!hasVisual && !isEmbedded && isMobile && (
<RunnerControls skinny />
Expand All @@ -427,6 +437,16 @@ const PyodideRunner = (props) => {
ref={output}
></pre>
</TabPanel>
{!isOutputOnly && (
<TabPanel key={1}>
<iframe
title="console"
src="http://localhost:3012/en/embed/viewer/ipython-console?browserPreview=true&autoRun=true"
crossOrigin
style={{ width: "100%", height: "100%" }}
/>
</TabPanel>
)}
</Tabs>
</div>
</>
Expand All @@ -446,6 +466,11 @@ const PyodideRunner = (props) => {
{t("output.textOutput")}
</span>
</Tab>
{/* {!isOutputOnly && (
<Tab key={2}>
<span className="react-tabs__tab-text">Console</span>
</Tab>
)} */}
</TabList>
{!isEmbedded && hasVisual && <OutputViewToggle />}
{!isEmbedded && isMobile && <RunnerControls skinny />}
Expand All @@ -463,6 +488,20 @@ const PyodideRunner = (props) => {
ref={output}
></pre>
</TabPanel>
{/* {!isOutputOnly && (
<TabPanel key={2}>
<editor-wc
autoRun={true}
class="c-editor__wc"
code={`from IPython import embed\nembed()`}
load_remix_disabled={true}
embedded={false}
output_only={true}
output_split_view={false}
use_editor_styles={true}
></editor-wc>
</TabPanel>
)} */}
</Tabs>
)}
</div>
Expand Down

0 comments on commit 3cab914

Please sign in to comment.