diff --git a/main.ts b/main.ts index 453cafc..814aa08 100644 --- a/main.ts +++ b/main.ts @@ -388,6 +388,7 @@ export default class VirtualFooterPlugin extends Plugin { private embedRefreshTimeouts: WeakMap = new WeakMap(); private embedLastScanByView: WeakMap = new WeakMap(); private footerPaddingObservers: WeakMap = new WeakMap(); + private livePreviewFooterStyleApplied: WeakMap = new WeakMap(); private canvasRefreshTimeout: number | null = null; private canvasRefreshInProgress = false; private canvasInteractionHandler: ((event: Event) => void) | null = null; @@ -2385,6 +2386,7 @@ export default class VirtualFooterPlugin extends Plugin { const containerEl = view.containerEl.querySelector(SELECTOR_EDITOR_CONTENT_CONTAINER_PARENT); contentEl?.classList.add(CSS_VIRTUAL_FOOTER_CM_PADDING); containerEl?.classList.add(CSS_VIRTUAL_FOOTER_REMOVE_FLEX); + this.livePreviewFooterStyleApplied.set(view, true); // Keep Live Preview bottom spacing stable even when Obsidian rewrites inline styles. if (contentEl) { @@ -2421,18 +2423,30 @@ export default class VirtualFooterPlugin extends Plugin { const container = viewOrContainer instanceof MarkdownView ? viewOrContainer.containerEl : viewOrContainer; const contentEl = container.querySelector(SELECTOR_EDITOR_CONTENT_AREA); const containerEl = container.querySelector(SELECTOR_EDITOR_CONTENT_CONTAINER_PARENT); + const view = viewOrContainer instanceof MarkdownView ? viewOrContainer : null; + if (view && !this.livePreviewFooterStyleApplied.get(view)) { + return; + } contentEl?.classList.remove(CSS_VIRTUAL_FOOTER_CM_PADDING); containerEl?.classList.remove(CSS_VIRTUAL_FOOTER_REMOVE_FLEX); - // Remove the inline padding-bottom style + // Restore native-like bottom spacing instead of clearing it entirely. if (contentEl) { const observedContentEl = contentEl as HTMLDivElement & { observer?: MutationObserver }; - contentEl.style.removeProperty('padding-bottom'); + const containerHeight = container.clientHeight; + if (containerHeight > 0) { + contentEl.style.setProperty('padding-bottom', `${this.computeFooterBottomPaddingPx(containerHeight)}px`); + } else { + contentEl.style.removeProperty('padding-bottom'); + } if (observedContentEl.observer) { observedContentEl.observer.disconnect(); delete observedContentEl.observer; } } + if (view) { + this.livePreviewFooterStyleApplied.delete(view); + } } /** diff --git a/manifest.json b/manifest.json index c168020..855b1ce 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "virtual-footer", "name": "Virtual Content", - "version": "1.0.34", + "version": "1.0.35", "minAppVersion": "0.15.0", "description": "Display markdown text (including dataview queries or Bases) at the bottom, top or in the sidebar for all notes which match a specified rule, without modifying them.", "author": "Signynt", diff --git a/package.json b/package.json index a489ba0..76e893e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "virtual-footer", - "version": "1.0.34", + "version": "1.0.35", "description": "Display markdown text (including dataview queries or Bases) at the bottom, top or in the sidebar for all notes which match a specified rule, without modifying them.", "main": "main.js", "scripts": {