mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-13 00:18:08 +00:00
Refreshed markdown cm instance layout on size change
Intended to fix positioning quirks caused by changing codemirror instance size when you have lines that wrap and cause line height changes. Often caused by editor toolbox expand/collapse. This adds a debounced resize observer to refresh editor layout on size change. Also tweaks toolbox expand/collapse to more consistently set aria attribute. For #3186
This commit is contained in:
parent
4aed3f8558
commit
aaa2205df1
2 changed files with 8 additions and 1 deletions
resources/js/components
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue