Seems to be working still... Trying to update packages.

This commit is contained in:
Scott Idem
2025-12-05 14:50:06 -05:00
parent b3bad26d8f
commit 1fc58eb18f
6 changed files with 57 additions and 73 deletions

View File

@@ -43,8 +43,8 @@
let editor_element: HTMLDivElement = $state();
let editorView: any = $state(); // Changed to any
let cm_modules: any = $state(); // To hold the dynamically loaded CodeMirror modules
let editor_extensions: any[] = $state([]);
async function initializeCodeMirror() {
if (!browser) return;
@@ -53,7 +53,7 @@
if (!cm_modules) return;
// Reactive declaration for extensions
let editor_extensions = [
editor_extensions = [
// Core extensions
cm_modules.highlightSpecialChars(),
cm_modules.history(),
@@ -122,14 +122,11 @@
});
// Update editor content when `content` prop changes
run(() => {
if (cm_modules && editorView && editorView.state.doc.toString() !== content) {
editorView.setState(
cm_modules.EditorState.create({
doc: content,
extensions: editor_extensions // Use the reactive extensions
})
);
$effect(() => {
if (editorView && content !== editorView.state.doc.toString()) {
editorView.dispatch({
changes: { from: 0, to: editorView.state.doc.length, insert: content || '' }
});
}
});
</script>