diff --git a/packages/codemirror/codemirror.mjs b/packages/codemirror/codemirror.mjs index 6ad94209..a2c70599 100644 --- a/packages/codemirror/codemirror.mjs +++ b/packages/codemirror/codemirror.mjs @@ -186,6 +186,10 @@ export class StrudelMirror { this.root.style.backgroundColor = 'var(--background)'; cmEditor.style.backgroundColor = 'transparent'; } + const settings = codemirrorSettings.get(); + this.setFontSize(settings.fontSize); + this.setFontFamily(settings.fontFamily); + // stop this repl when another repl is started this.onStartRepl = (e) => { if (e.detail !== this.id) { diff --git a/packages/core/repl.mjs b/packages/core/repl.mjs index fd0d8a3b..b3c7a543 100644 --- a/packages/core/repl.mjs +++ b/packages/core/repl.mjs @@ -62,10 +62,6 @@ export function repl({ }; setTime(() => scheduler.now()); // TODO: refactor? const evaluate = async (code, autostart = true, shouldHush = true) => { - if (code === state.activeCode && state.started) { - logger('[eval] skip: not dirty') - return; - } if (!code) { throw new Error('no code to evaluate'); } diff --git a/website/src/components/HeadCommonNext.astro b/website/src/components/HeadCommonNext.astro new file mode 100644 index 00000000..9f323a7a --- /dev/null +++ b/website/src/components/HeadCommonNext.astro @@ -0,0 +1,58 @@ +--- +import { pwaInfo } from 'virtual:pwa-info'; +import '../styles/index.css'; + +const { BASE_URL } = import.meta.env; +const baseNoTrailing = BASE_URL.endsWith('/') ? BASE_URL.slice(0, -1) : BASE_URL; +--- + + + + + + + + + + + + + + + + + + + + + + + +{pwaInfo && } + + diff --git a/website/src/pages/vanilla/2.astro b/website/src/pages/vanilla/2.astro index 543d5fed..0db75a1d 100644 --- a/website/src/pages/vanilla/2.astro +++ b/website/src/pages/vanilla/2.astro @@ -1,13 +1,11 @@ --- -import HeadCommon from '../../components/HeadCommon.astro'; -// import { Repl } from '../repl/Repl.jsx'; - +import HeadCommonNext from '../../components/HeadCommonNext.astro'; import { Repl2 } from '../../repl/Repl2'; --- - + Strudel REPL diff --git a/website/src/repl/Repl2.jsx b/website/src/repl/Repl2.jsx index d153b80e..afc81198 100644 --- a/website/src/repl/Repl2.jsx +++ b/website/src/repl/Repl2.jsx @@ -8,7 +8,7 @@ import { logger, getDrawContext, silence, evalScope, controls } from '@strudel.c import { cx } from '@strudel.cycles/react'; import { getAudioContext, webaudioOutput, initAudioOnFirstClick } from '@strudel.cycles/webaudio'; import { transpiler } from '@strudel.cycles/transpiler'; -import { StrudelMirror } from '@strudel/codemirror'; +import { StrudelMirror, defaultSettings } from '@strudel/codemirror'; import { createClient } from '@supabase/supabase-js'; /* import { writeText } from '@tauri-apps/api/clipboard'; import { nanoid } from 'nanoid'; */ @@ -33,6 +33,7 @@ import { useCallback, useRef, useEffect } from 'react'; // import { prebake } from '@strudel/repl'; import { prebake /* , resetSounds */ } from './prebake.mjs'; import * as tunes from './tunes.mjs'; +import { useStore } from '@nanostores/react'; export const ReplContext = createContext(null); @@ -139,10 +140,23 @@ export function Repl2({ embedded = false }) { }); } return () => { - editor.clear(); + editorRef.current?.clear(); }; }, []); + // this can be simplified once SettingsTab has been refactored to change codemirrorSettings directly! + // this will be the case when the main repl is being replaced + const _settings = useStore(settingsMap, { keys: Object.keys(defaultSettings) }); + useEffect(() => { + let editorSettings = {}; + Object.keys(defaultSettings).forEach((key) => { + if (_settings.hasOwnProperty(key)) { + editorSettings[key] = _settings[key]; + } + }); + editorRef.current?.updateSettings(editorSettings); + }, [_settings]); + // // UI Actions //