From 90e3260aa24e4a330cace1da842fadcb65e39870 Mon Sep 17 00:00:00 2001 From: webreflection Date: Thu, 7 May 2026 16:58:33 +0200 Subject: [PATCH] added a way to specify a print target output --- core/package-lock.json | 4 ++-- core/package.json | 2 +- core/src/plugins/py-editor.js | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index d4b639fd..aaf34cbe 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -1,12 +1,12 @@ { "name": "@pyscript/core", - "version": "0.7.23", + "version": "0.7.24", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@pyscript/core", - "version": "0.7.23", + "version": "0.7.24", "license": "APACHE-2.0", "dependencies": { "@ungap/with-resolvers": "^0.1.0", diff --git a/core/package.json b/core/package.json index af10b168..5139b6b4 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@pyscript/core", - "version": "0.7.23", + "version": "0.7.24", "type": "module", "description": "PyScript", "module": "./index.js", diff --git a/core/src/plugins/py-editor.js b/core/src/plugins/py-editor.js index de5c51c4..2a90c8a6 100644 --- a/core/src/plugins/py-editor.js +++ b/core/src/plugins/py-editor.js @@ -239,12 +239,13 @@ const makeOutDiv = (type) => { return outDiv; }; -const makeBoxDiv = (handler, type) => { +const makeBoxDiv = (handler, type, output) => { const boxDiv = document.createElement("div"); boxDiv.className = `${type}-editor-box`; const editorDiv = makeEditorDiv(handler, type); - const outDiv = makeOutDiv(type); + const outDiv = output ? document.getElementById(output) : makeOutDiv(type); + if (output) outDiv.classList.add(`${type}-editor-output`); boxDiv.append(editorDiv, outDiv); return [boxDiv, outDiv, editorDiv.querySelector("button")]; @@ -427,7 +428,7 @@ const init = async (script, type, interpreter) => { if (!target.hasAttribute("root")) target.setAttribute("root", target.id); // @see https://github.com/JeffersGlass/mkdocs-pyscript/blob/main/mkdocs_pyscript/js/makeblocks.js - const [boxDiv, outDiv, runButton] = makeBoxDiv(context, type); + const [boxDiv, outDiv, runButton] = makeBoxDiv(context, type, script.getAttribute("output")); boxDiv.dataset.env = script.hasAttribute("env") ? env : interpreter; const inputChild = boxDiv.querySelector(`.${type}-editor-input > div`);