We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5a985b4 commit 4e156f6Copy full SHA for 4e156f6
packages/cherry-markdown/src/toolbars/Sidebar.js
@@ -29,14 +29,15 @@ export default class Sidebar extends Toolbar {
29
list.appendChild(menus);
30
this.options.dom.appendChild(list);
31
// 将侧栏列表高度写入 CSS 变量,便于定位
32
- if (typeof document !== 'undefined') {
33
- setTimeout(() => {
+ if (typeof document !== 'undefined' && typeof ResizeObserver !== 'undefined') {
+ const observer = new ResizeObserver(() => {
34
const height = list.scrollHeight;
35
// 高度为 0 时保持默认 120px,不覆盖
36
if (height > 0) {
37
this.$cherry.wrapperDom.style.setProperty('--sidebar-list-height', `${height}px`);
38
}
39
- }, 0);
+ });
40
+ observer.observe(list);
41
42
43
0 commit comments