mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-27 21:48:27 +00:00
fix: codemirror reeval
This commit is contained in:
parent
352e647d37
commit
b5b0156e08
@ -128,6 +128,7 @@ export const flash = (view, ms = 200) => {
|
|||||||
|
|
||||||
export class StrudelMirror {
|
export class StrudelMirror {
|
||||||
constructor({ root, initialCode = '', onEvaluate, onStop }) {
|
constructor({ root, initialCode = '', onEvaluate, onStop }) {
|
||||||
|
this.code = initialCode;
|
||||||
this.view = initEditor({
|
this.view = initEditor({
|
||||||
root,
|
root,
|
||||||
initialCode,
|
initialCode,
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import { funk42 } from './tunes';
|
|||||||
import { pianoroll, getDrawOptions } from '@strudel.cycles/core';
|
import { pianoroll, getDrawOptions } from '@strudel.cycles/core';
|
||||||
import './style.css';
|
import './style.css';
|
||||||
|
|
||||||
let code = funk42;
|
|
||||||
const repl = initStrudel();
|
const repl = initStrudel();
|
||||||
const canvas = document.getElementById('roll');
|
const canvas = document.getElementById('roll');
|
||||||
canvas.width = canvas.width * 2;
|
canvas.width = canvas.width * 2;
|
||||||
@ -15,10 +14,7 @@ canvas.height = canvas.height * 2;
|
|||||||
|
|
||||||
const editor = new StrudelMirror({
|
const editor = new StrudelMirror({
|
||||||
root: document.getElementById('editor'),
|
root: document.getElementById('editor'),
|
||||||
initialCode: code,
|
initialCode: funk42,
|
||||||
onChange: (v) => {
|
|
||||||
code = v.state.doc.toString();
|
|
||||||
},
|
|
||||||
onEvaluate,
|
onEvaluate,
|
||||||
onStop,
|
onStop,
|
||||||
});
|
});
|
||||||
@ -28,10 +24,10 @@ async function onEvaluate() {
|
|||||||
editor.flash();
|
editor.flash();
|
||||||
if (!scheduler.started) {
|
if (!scheduler.started) {
|
||||||
scheduler.stop();
|
scheduler.stop();
|
||||||
await evaluate(code);
|
await evaluate(editor.code);
|
||||||
drawer.start(scheduler);
|
drawer.start(scheduler);
|
||||||
} else {
|
} else {
|
||||||
await evaluate(code);
|
await evaluate(editor.code);
|
||||||
drawer.invalidate(); // this is a bit mystic
|
drawer.invalidate(); // this is a bit mystic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user