Skip to content

Commit a84e741

Browse files
author
adi
committed
fixed code-zone changing issues
1 parent 62f4ef7 commit a84e741

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

dev/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ <h1>Python</h1>
3636
</script>
3737
</wc-code>
3838

39+
<h1>Python example 2</h1>
40+
<p>Python code example here</p>
41+
<wc-code mode="python" file-name="python-file.py">
42+
<script type="wc-content">
43+
for a in range(100):
44+
print(a, a + 5, 5*a)
45+
</script>
46+
</wc-code>
47+
3948
<h1>Code Zones !</h1>
4049
<p>javascript code zone</p>
4150
<wc-code-zone mode="javascript" theme="blackboard">

src/languages/python/python.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ${webcomponent.value}`)
4747
}
4848

4949
setPrintFn () {
50-
pyodide.runPython(`
50+
this.subInterpreter.run(`
5151
def print(*args):
5252
from js import WCCode
5353
zone = WCCode.zones.get(${this.zone.zoneId})

src/wc-code.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ WCCode.WCCode = class extends WCCodeMirror {
9595

9696
async initLanguage () {
9797
this.loadingBar.setText('initializing language...')
98-
if (!this.languageOptions.initilalized) {
98+
if (!this.languageOptions.initialized) {
9999
// if the language has an init function,
100100
// init it !
101101
if (this.languageOptions.init) {
@@ -114,7 +114,7 @@ WCCode.WCCode = class extends WCCodeMirror {
114114
async initInterpreter () {
115115
// create the interpreter
116116
if (this.parentZoneElement) {
117-
if (!this.parentZoneElement.initilalized) this.parentZoneElement.init()
117+
if (!this.parentZoneElement.initialized) this.parentZoneElement.init()
118118
} else {
119119
const interpreter = new this.languageOptions.Interpreter(this.zone)
120120
this.zone.setInterpreter(interpreter)

0 commit comments

Comments
 (0)