added a way to specify a print target output

This commit is contained in:
webreflection
2026-05-07 16:58:33 +02:00
parent c2dd1f23d8
commit 90e3260aa2
3 changed files with 7 additions and 6 deletions

View File

@@ -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",

View File

@@ -1,6 +1,6 @@
{
"name": "@pyscript/core",
"version": "0.7.23",
"version": "0.7.24",
"type": "module",
"description": "PyScript",
"module": "./index.js",

View File

@@ -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`);