From b913e1c50d85194969a8d1b86f41bfe7be5d7066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20=C3=9Eo=CC=81r=20Jo=CC=81nsson?= Date: Sat, 9 Nov 2024 15:13:24 +0100 Subject: [PATCH 1/2] REPL: solo and sync configuration --- packages/codemirror/codemirror.mjs | 18 +++++++++++------- packages/repl/repl-component.mjs | 4 ++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/codemirror/codemirror.mjs b/packages/codemirror/codemirror.mjs index 180ff103e..5886c4769 100644 --- a/packages/codemirror/codemirror.mjs +++ b/packages/codemirror/codemirror.mjs @@ -133,6 +133,7 @@ export class StrudelMirror { autodraw, prebake, bgFill = true, + solo = true, ...replOptions } = options; this.code = initialCode; @@ -143,6 +144,7 @@ export class StrudelMirror { this.drawContext = drawContext; this.onDraw = onDraw || this.draw; this.id = id || s4(); + this.solo = solo; this.drawer = new Drawer((haps, time, _, painters) => { const currentFrame = haps.filter((hap) => hap.isActive(time)); @@ -159,12 +161,14 @@ export class StrudelMirror { replOptions?.onToggle?.(started); if (started) { this.drawer.start(this.repl.scheduler); - // stop other repls when this one is started - document.dispatchEvent( - new CustomEvent('start-repl', { - detail: this.id, - }), - ); + if (this.solo) { + // stop other repls when this one is started + document.dispatchEvent( + new CustomEvent('start-repl', { + detail: this.id, + }), + ); + } } else { this.drawer.stop(); updateMiniLocations(this.editor, []); @@ -219,7 +223,7 @@ export class StrudelMirror { // stop this repl when another repl is started this.onStartRepl = (e) => { - if (e.detail !== this.id) { + if (this.solo && e.detail !== this.id) { this.stop(); } }; diff --git a/packages/repl/repl-component.mjs b/packages/repl/repl-component.mjs index e6e0ee0ec..d2217b829 100644 --- a/packages/repl/repl-component.mjs +++ b/packages/repl/repl-component.mjs @@ -10,6 +10,8 @@ if (typeof HTMLElement !== 'undefined') { static observedAttributes = ['code']; settings = codemirrorSettings.get(); editor = null; + sync = false; + solo = true; constructor() { super(); } @@ -49,6 +51,8 @@ if (typeof HTMLElement !== 'undefined') { }); this.dispatchEvent(event); }, + solo: this.solo, + sync: this.sync, }); // init settings this.editor.updateSettings(this.settings); From a7d74ed6d60a5e4fb363702151d83fbf5d65a1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20=C3=9Eo=CC=81r=20Jo=CC=81nsson?= Date: Wed, 20 Nov 2024 16:28:07 +0100 Subject: [PATCH 2/2] REPL: solo and sync configuration; codeformat --- packages/repl/repl-component.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/repl/repl-component.mjs b/packages/repl/repl-component.mjs index d2217b829..362084132 100644 --- a/packages/repl/repl-component.mjs +++ b/packages/repl/repl-component.mjs @@ -51,8 +51,8 @@ if (typeof HTMLElement !== 'undefined') { }); this.dispatchEvent(event); }, - solo: this.solo, - sync: this.sync, + solo: this.solo, + sync: this.sync, }); // init settings this.editor.updateSettings(this.settings);