Skip to content

NOW MANAGED ON CODEBERG

Refreshed markdown cm instance layout on size change

Dan Brownaaa2205df105
diff --git a/resources/js/components/editor-toolbox.js b/resources/js/components/editor-toolbox.js
index 354bf0a86..3a1442d75 100644
--- a/resources/js/components/editor-toolbox.js
+++ b/resources/js/components/editor-toolbox.js
@@ -41,7 +41,9 @@ class EditorToolbox {
if (cName === tabName) this.contentElements[i].style.display = 'block';
}
- if (openToolbox) this.elem.classList.add('open');
+ if (openToolbox && !this.elem.classList.contains('open')) {
+ this.toggle();
+ }
}
}
diff --git a/resources/js/components/markdown-editor.js b/resources/js/components/markdown-editor.js
index def3db5af..a14047d2f 100644
--- a/resources/js/components/markdown-editor.js
+++ b/resources/js/components/markdown-editor.js
@@ -112,6 +112,11 @@ class MarkdownEditor {
if (scrollText) {
this.scrollToText(scrollText);
}
+
+ // Refresh CodeMirror on container resize
+ const resizeDebounced = debounce(() => code.updateLayout(this.cm), 100, false);
+ const observer = new ResizeObserver(resizeDebounced);
+ observer.observe(this.elem);
}
// Update the input content and render the display.