From d7501bde118c85072cf70a7928b07b1db286bbd2 Mon Sep 17 00:00:00 2001 From: ojack Date: Fri, 11 Feb 2022 16:45:16 +0100 Subject: [PATCH] eval line and eval block working --- frontend/web-editor/public/bundle.js | 15 +++++++++++++-- frontend/web-editor/src/store.js | 11 +++++++++++ frontend/web-editor/src/views/EditorComponent.js | 4 ++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/frontend/web-editor/public/bundle.js b/frontend/web-editor/public/bundle.js index 4ce0469..e935e8e 100644 --- a/frontend/web-editor/public/bundle.js +++ b/frontend/web-editor/public/bundle.js @@ -26038,6 +26038,7 @@ module.exports = function store (state, emitter) { }) + emitter.on('editor:randomize', function(evt) { const editor = state.editor.editor if (evt.shiftKey) { @@ -26066,6 +26067,16 @@ module.exports = function store (state, emitter) { }) }) + emitter.on('editor:evalLine', (line) => { + console.log('EVALUATING', line) + repl.eval(line) + }) + + emitter.on('editor:evalBlock', (block) => { + console.log('evaluating block') + repl.eval(block) + }) + emitter.on('gallery:shareSketch', function (editor) { console.log('waiting to share', state.editor.editor.getValue()) }) @@ -26109,8 +26120,8 @@ module.exports = class Editor extends Component { load (element) { this.editor = new HydraEditor(this.textEl) - this.editor.on("*", (e, t) => { - this.emit(e) + this.editor.on("*", (e, args) => { + this.emit(e, args) }) // hacky, maybe not necessary this.innerText = document.getElementsByClassName('CodeMirror')[0] diff --git a/frontend/web-editor/src/store.js b/frontend/web-editor/src/store.js index 822d078..e067099 100644 --- a/frontend/web-editor/src/store.js +++ b/frontend/web-editor/src/store.js @@ -14,6 +14,7 @@ module.exports = function store (state, emitter) { }) + emitter.on('editor:randomize', function(evt) { const editor = state.editor.editor if (evt.shiftKey) { @@ -42,6 +43,16 @@ module.exports = function store (state, emitter) { }) }) + emitter.on('editor:evalLine', (line) => { + console.log('EVALUATING', line) + repl.eval(line) + }) + + emitter.on('editor:evalBlock', (block) => { + console.log('evaluating block') + repl.eval(block) + }) + emitter.on('gallery:shareSketch', function (editor) { console.log('waiting to share', state.editor.editor.getValue()) }) diff --git a/frontend/web-editor/src/views/EditorComponent.js b/frontend/web-editor/src/views/EditorComponent.js index d96fe99..bf5e584 100644 --- a/frontend/web-editor/src/views/EditorComponent.js +++ b/frontend/web-editor/src/views/EditorComponent.js @@ -12,8 +12,8 @@ module.exports = class Editor extends Component { load (element) { this.editor = new HydraEditor(this.textEl) - this.editor.on("*", (e, t) => { - this.emit(e) + this.editor.on("*", (e, args) => { + this.emit(e, args) }) // hacky, maybe not necessary this.innerText = document.getElementsByClassName('CodeMirror')[0]