Keeping last project open

This commit is contained in:
2025-10-15 11:39:22 +02:00
parent d3a8396033
commit 1dc9d1114e
5 changed files with 71 additions and 13 deletions

View File

@ -25,13 +25,15 @@
onChange?: (value: string) => void;
onExecute?: (code: string, source: 'selection' | 'block' | 'document') => void;
editorSettings: EditorSettingsStore;
mode: 'composition' | 'livecoding';
}
let {
value = '',
onChange,
onExecute,
editorSettings
editorSettings,
mode = 'composition'
}: Props = $props();
let editorContainer: HTMLDivElement;
@ -44,6 +46,13 @@
function handleExecute() {
if (!editorView) return;
if (mode === 'composition') {
const doc = getDocument(editorView.state);
flash(editorView, doc.from, doc.to);
onExecute?.(doc.text, 'document');
return;
}
const selection = getSelection(editorView.state);
if (selection.text) {
flash(editorView, selection.from, selection.to);