A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
default to showing code for pyodide notebooks (#1574)
Akshay Agrawal19dc4b01c40e
diff --git a/docs/guides/wasm.md b/docs/guides/wasm.mdindex 8170db4f40..caf03f9bfb 100644--- a/docs/guides/wasm.md+++ b/docs/guides/wasm.md@@ -142,7 +142,8 @@ notebooks in your own webpages.By default, WASM notebooks expose your Python code to viewers. If you'veenabled read-only mode, you can exclude code with-`&include-code=false`.+`&include-code=false`. If you want to include code but have it be hidden+by default, use the parameter `&show-code=false`.A sufficiently determined user would still be ableto obtain your code, so **don't** think of this as a security feature; instead,diff --git a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsxindex bd7aff5166..ff92a7e333 100644--- a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx+++ b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx@@ -29,6 +29,7 @@ import {} from "@/components/ui/dropdown-menu";import { downloadHTMLAsImage } from "@/utils/download";import { downloadAsHTML } from "@/core/static/download-html";+import { isPyodide } from "@/core/pyodide/utils";type VerticalLayout = null;type VerticalLayoutProps = ICellRendererProps<VerticalLayout>;@@ -39,9 +40,14 @@ const VerticalLayoutRenderer: React.FC<VerticalLayoutProps> = ({mode,}) => {const { invisible } = useDelayVisibility(cells.length, mode);++ const urlParams = new URLSearchParams(window.location.search);+ const showCodeDefault = urlParams.get("show-code");const [showCode, setShowCode] = useState(() => {// Default to showing code if the notebook is static- return isStaticNotebook();+ return showCodeDefault === null+ ? isStaticNotebook() || isPyodide()+ : showCodeDefault === "true";});const evaluateCanShowCode = () => {@@ -52,7 +58,6 @@ const VerticalLayoutRenderer: React.FC<VerticalLayoutProps> = ({// If it is a static-notebook or wasm-read-only-notebook, code is always included,// but it can be turned it off via a query parameter (include-code=false)- const urlParams = new URLSearchParams(window.location.search);const includeCode = urlParams.get("include-code");return mode === "read" && includeCode !== "false" && cellsHaveCode;};