Seems to be working still... Trying to update packages.
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user