diff --git a/app/static/js/core/sheet-buttons.js b/app/static/js/core/sheet-buttons.js index f97cd41..d0195d9 100644 --- a/app/static/js/core/sheet-buttons.js +++ b/app/static/js/core/sheet-buttons.js @@ -44,12 +44,21 @@ async function registerCellToButton(hyperlinkCellRef, scriptName, xwConfig) { typeof globalThis.getAuth === "function" ? await globalThis.getAuth() : ""; - await xlwings.runPython( - window.location.origin + - config.appPath + - `/xlwings/custom-scripts-call/${scriptName}`, - { ...xwConfig, auth: token }, - ); + if (config.onWasm) { + let body = await xlwings.getBookData(xwConfig); + await pyscriptDone; + let r = await window.custom_scripts_call(body, scriptName); + r = JSON.parse(r); + // let actions = r.toJs(); + await xlwings.runActions(r); + } else { + await xlwings.runPython( + window.location.origin + + config.appPath + + `/xlwings/custom-scripts-call/${scriptName}`, + { ...xwConfig, auth: token }, + ); + } } finally { sheet.getRange(selectedRangeAddress).getOffsetRange(1, 0).select(); await context.sync(); diff --git a/app/static/js/core/xlwingsjs/xlwings.js b/app/static/js/core/xlwingsjs/xlwings.js index beb1bb6..66d4bf1 100644 --- a/app/static/js/core/xlwingsjs/xlwings.js +++ b/app/static/js/core/xlwingsjs/xlwings.js @@ -57,6 +57,7 @@ export function init() { config.appPath + "/xlwings/custom-scripts-call/" + element.getAttribute("xw-click"); + // TODO: this is duplicated in sheet-buttons.js if (config.onWasm) { let body = await xlwings.getBookData(xwConfig); await pyscriptDone; diff --git a/app/templates/base.html b/app/templates/base.html index c4b7ec6..6db06d0 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -85,6 +85,7 @@ {% if settings.enable_wasm %} + {% endif %} {% endblock head %} diff --git a/app/templates/examples/hello_world/taskpane_hello.html b/app/templates/examples/hello_world/taskpane_hello.html index 8b82e61..b055274 100644 --- a/app/templates/examples/hello_world/taskpane_hello.html +++ b/app/templates/examples/hello_world/taskpane_hello.html @@ -3,9 +3,6 @@ {% block content %}

Example Task Pane

- {# PyScript Test #} - - diff --git a/app/wasm/main.py b/app/wasm/main.py index 69eeee2..afbbb13 100644 --- a/app/wasm/main.py +++ b/app/wasm/main.py @@ -5,7 +5,6 @@ - Check out https://docs.pyscript.net/2024.5.2/user-guide/workers/ TODO: -- support sheet buttons - make current_user optional - look into toJS vs json (func vs script) - run 10000 custom functions diff --git a/app/wasm/pyscript.json b/app/wasm/pyscript.json index ecdcfae..0a1f327 100644 --- a/app/wasm/pyscript.json +++ b/app/wasm/pyscript.json @@ -4,8 +4,7 @@ "sqlite3", "pydantic", "numpy", - "pandas", - "matplotlib" + "pandas" ], "files": { "/wasm/custom_functions/__init__.py": "./custom_functions/__init__.py",