Skip to content

Commit

Permalink
fixed code-zone changing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
adi committed May 24, 2021
1 parent 62f4ef7 commit a84e741
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ <h1>Python</h1>
</script>
</wc-code>

<h1>Python example 2</h1>
<p>Python code example here</p>
<wc-code mode="python" file-name="python-file.py">
<script type="wc-content">
for a in range(100):
print(a, a + 5, 5*a)
</script>
</wc-code>

<h1>Code Zones !</h1>
<p>javascript code zone</p>
<wc-code-zone mode="javascript" theme="blackboard">
Expand Down
2 changes: 1 addition & 1 deletion src/languages/python/python.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ${webcomponent.value}`)
}

setPrintFn () {
pyodide.runPython(`
this.subInterpreter.run(`
def print(*args):
from js import WCCode
zone = WCCode.zones.get(${this.zone.zoneId})
Expand Down
4 changes: 2 additions & 2 deletions src/wc-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ WCCode.WCCode = class extends WCCodeMirror {

async initLanguage () {
this.loadingBar.setText('initializing language...')
if (!this.languageOptions.initilalized) {
if (!this.languageOptions.initialized) {
// if the language has an init function,
// init it !
if (this.languageOptions.init) {
Expand All @@ -114,7 +114,7 @@ WCCode.WCCode = class extends WCCodeMirror {
async initInterpreter () {
// create the interpreter
if (this.parentZoneElement) {
if (!this.parentZoneElement.initilalized) this.parentZoneElement.init()
if (!this.parentZoneElement.initialized) this.parentZoneElement.init()
} else {
const interpreter = new this.languageOptions.Interpreter(this.zone)
this.zone.setInterpreter(interpreter)
Expand Down

0 comments on commit a84e741

Please sign in to comment.