10000 Expose py-editor code content read/write (#2087) · Narnar-Codes/pyscript@2ac5ca7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ac5ca7

Browse files
Expose py-editor code content read/write (pyscript#2087)
* Expose py-editor code content read/write * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent cb9ee6f commit 2ac5ca7

File tree

3 files changed

+85
-67
lines changed

3 files changed

+85
-67
lines changed

pyscript.core/package-lock.json

Lines changed: 67 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyscript.core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pyscript/core",
3-
"version": "0.4.40",
3+
"version": "0.4.41",
44
"type": "module",
55
"description": "PyScript",
66
"module": "./index.js",
@@ -61,10 +61,10 @@
6161
"@webreflection/toml-j0.4": "^1.1.3",
6262
"@xterm/addon-fit": "^0.10.0",
6363
"@xterm/addon-web-links": "^0.11.0",
64-
"bun": "^1.1.10",
64+
"bun": "^1.1.12",
6565
"chokidar": "^3.6.0",
6666
"codemirror": "^6.0.1",
67-
"eslint": "^9.3.0",
67+
"eslint": "^9.4.0",
6868
"rollup": "^4.18.0",
6969
"rollup-plugin-postcss": "^4.0.2",
7070
"rollup-plugin-string": "^3.0.0",

pyscript.core/src/plugins/py-editor.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,21 @@ const init = async (script, type, interpreter) => {
184184
let target;
185185
defineProperties(script, {
186186
target: { get: () => target },
187+
code: {
188+
get: () => context.pySrc,
189+
set: (insert) => {
190+
if (isSetup) return;
191+
editor.update([
192+
editor.state.update({
193+
changes: {
194+
from: 0,
195+
to: editor.state.doc.length,
196+
insert,
197+
},
198+
}),
199+
]);
200+
},
201+
},
187202
process: {
188203
/**
189204
* Simulate a setup node overriding the source to evaluate.

0 commit comments

Comments
 (0)
0