From c177259dededf1d11c48bbced25d16a30b13f9ab Mon Sep 17 00:00:00 2001 From: Signynt <67801159+Signynt@users.noreply.github.com> Date: Sat, 30 Nov 2024 18:35:00 +0100 Subject: [PATCH] Fixed `flex` creating a large gap between the footer and the contents --- main.ts | 22 ++++++++++++++-------- styles.css | 6 +++++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/main.ts b/main.ts index 1aeff2a..434cc69 100644 --- a/main.ts +++ b/main.ts @@ -23,17 +23,23 @@ export default class VirtualFooterPlugin extends Plugin { await this.injectFooterToPreview(view); } else if (state.mode === 'source' && !state.source) { // Remove the padding from the content area to append the footer - const cmContent = view.containerEl.querySelector('.cm-editor .cm-content') as HTMLDivElement; - if (cmContent) { - cmContent.classList.add('virtual-footer-cm-padding'); - } + const [content, container] = [ + view.containerEl.querySelector('.cm-editor .cm-content'), + view.containerEl.querySelector('.markdown-source-view.mod-cm6 .cm-contentContainer') + ] as HTMLDivElement[]; + content?.classList.add('virtual-footer-cm-padding'); + container?.classList.add('virtual-footer-remove-flex'); + await this.injectFooterToEditor(view); } else { // Remove the custom styling from the content area - const cmContent = view.containerEl.querySelector('.cm-editor .cm-content') as HTMLDivElement; - if (cmContent) { - cmContent.classList.remove('virtual-footer-cm-padding'); - } + const [content, container] = [ + view.containerEl.querySelector('.cm-editor .cm-content'), + view.containerEl.querySelector('.markdown-source-view.mod-cm6 .cm-contentContainer') + ] as HTMLDivElement[]; + content?.classList.remove('virtual-footer-cm-padding'); + container?.classList.remove('virtual-footer-remove-flex'); + await this.removeFooter(view); } }; diff --git a/styles.css b/styles.css index d7ec802..50b7b58 100644 --- a/styles.css +++ b/styles.css @@ -6,4 +6,8 @@ .virtual-footer-cm-padding { padding-bottom: var(--p-spacing) !important; -} \ No newline at end of file +} + +.virtual-footer-remove-flex { + flex: 0 1 auto !important; +}