mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 21:58:31 +00:00
fix: boolean settings
This commit is contained in:
parent
1cdb5964c6
commit
b462f19ef1
@ -12,7 +12,7 @@ import { highlightMiniLocations, isPatternHighlightingEnabled, updateMiniLocatio
|
||||
import { keybindings } from './keybindings.mjs';
|
||||
import { initTheme, activateTheme, theme } from './themes.mjs';
|
||||
import { updateWidgets, sliderPlugin } from './slider.mjs';
|
||||
import { persistentMap } from '@nanostores/persistent';
|
||||
import { persistentAtom } from '@nanostores/persistent';
|
||||
|
||||
const extensions = {
|
||||
isLineWrappingEnabled: (on) => (on ? EditorView.lineWrapping : []),
|
||||
@ -40,7 +40,10 @@ export const defaultSettings = {
|
||||
fontSize: 18,
|
||||
};
|
||||
|
||||
export const codemirrorSettings = persistentMap('codemirror-settings', defaultSettings);
|
||||
export const codemirrorSettings = persistentAtom('codemirror-settings', defaultSettings, {
|
||||
encode: JSON.stringify,
|
||||
decode: JSON.parse,
|
||||
});
|
||||
|
||||
// https://codemirror.net/docs/guide/
|
||||
export function initEditor({ initialCode = '', onChange, onEvaluate, onStop, root }) {
|
||||
@ -254,7 +257,8 @@ export class StrudelMirror {
|
||||
for (let key in extensions) {
|
||||
this.reconfigureExtension(key, settings[key]);
|
||||
}
|
||||
codemirrorSettings.set({ ...codemirrorSettings.get(), ...settings });
|
||||
const updated = { ...codemirrorSettings.get(), ...settings };
|
||||
codemirrorSettings.set(updated);
|
||||
}
|
||||
changeSetting(key, value) {
|
||||
if (extensions[key]) {
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<strudel-editor code={`s("bd")`}></strudel-editor>
|
||||
|
||||
<p>This is another REPL:</p>
|
||||
<strudel-editor is-line-numbers-displayed="0"><!--
|
||||
<strudel-editor><!--
|
||||
n(run(4).sub(4))
|
||||
.chord("<C^7#11 E^7#11>/16")
|
||||
.dict('ireal')
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { hash2code, logger } from '@strudel.cycles/core';
|
||||
import { codemirrorSettings } from '@strudel/codemirror';
|
||||
import { codemirrorSettings, defaultSettings } from '@strudel/codemirror';
|
||||
import './vanilla.css';
|
||||
|
||||
let editor;
|
||||
@ -112,6 +112,6 @@ function setFormValues(form, values) {
|
||||
const form = document.querySelector('form[name=settings]');
|
||||
setFormValues(form, codemirrorSettings.get());
|
||||
form.addEventListener('change', () => {
|
||||
const values = getFormValues(form, codemirrorSettings.get());
|
||||
const values = getFormValues(form, defaultSettings);
|
||||
editor?.updateSettings(values);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user