mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 13:48:40 +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 {
|
||||
constructor({ root, initialCode = '', onEvaluate, onStop }) {
|
||||
this.code = initialCode;
|
||||
this.view = initEditor({
|
||||
root,
|
||||
initialCode,
|
||||
|
||||
@ -7,7 +7,6 @@ import { funk42 } from './tunes';
|
||||
import { pianoroll, getDrawOptions } from '@strudel.cycles/core';
|
||||
import './style.css';
|
||||
|
||||
let code = funk42;
|
||||
const repl = initStrudel();
|
||||
const canvas = document.getElementById('roll');
|
||||
canvas.width = canvas.width * 2;
|
||||
@ -15,10 +14,7 @@ canvas.height = canvas.height * 2;
|
||||
|
||||
const editor = new StrudelMirror({
|
||||
root: document.getElementById('editor'),
|
||||
initialCode: code,
|
||||
onChange: (v) => {
|
||||
code = v.state.doc.toString();
|
||||
},
|
||||
initialCode: funk42,
|
||||
onEvaluate,
|
||||
onStop,
|
||||
});
|
||||
@ -28,10 +24,10 @@ async function onEvaluate() {
|
||||
editor.flash();
|
||||
if (!scheduler.started) {
|
||||
scheduler.stop();
|
||||
await evaluate(code);
|
||||
await evaluate(editor.code);
|
||||
drawer.start(scheduler);
|
||||
} else {
|
||||
await evaluate(code);
|
||||
await evaluate(editor.code);
|
||||
drawer.invalidate(); // this is a bit mystic
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user