This commit is contained in:
2025-12-01 18:04:56 +01:00
parent e9b0e9d856
commit 9ad6cae249
5 changed files with 133 additions and 6 deletions

View File

@@ -21,6 +21,7 @@
let activeTab = $state<'html' | 'css' | 'shared' | 'app'>(mode === 'item' ? 'html' : 'shared');
let editMode = $state<EditMode>('normal');
let previousItemId = $state<string | null>(null);
function getKeymapExtension(m: EditMode) {
switch (m) {
@@ -152,6 +153,22 @@
sharedEditor?.dispatch({ effects: keymapCompartment.reconfigure(ext) });
appEditor?.dispatch({ effects: keymapCompartment.reconfigure(ext) });
});
$effect(() => {
if (mode === 'item' && item && item.id !== previousItemId) {
previousItemId = item.id;
if (htmlEditor) {
htmlEditor.dispatch({
changes: { from: 0, to: htmlEditor.state.doc.length, insert: item.html }
});
}
if (cssEditor) {
cssEditor.dispatch({
changes: { from: 0, to: cssEditor.state.doc.length, insert: item.css }
});
}
}
});
</script>
<div class="panel">