OK
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user