mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04: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
@ -41,7 +41,9 @@ class EditorToolbox {
|
|||||||
if (cName === tabName) this.contentElements[i].style.display = 'block';
|
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) {
|
if (scrollText) {
|
||||||
this.scrollToText(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.
|
// Update the input content and render the display.
|
||||||
|
Loading…
Reference in New Issue
Block a user