diff --git a/manifest.json b/manifest.json index 22ebaa9..e481228 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "simple-banner", "name": "Simple Banner", - "version": "0.5.4", + "version": "0.5.5", "minAppVersion": "1.8.9", "description": "Visually enhance your notes with a customizable banner. Supports icons and time/date display.", "author": "Sandro Ducceschi", diff --git a/package-lock.json b/package-lock.json index 7d1cc84..9a4ef7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "simple-banner", - "version": "0.5.4", + "version": "0.5.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "simple-banner", - "version": "0.5.4", + "version": "0.5.5", "license": "MIT", "devDependencies": { "@types/node": "^16.11.6", diff --git a/package.json b/package.json index b71eb68..08f2447 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simple-banner", - "version": "0.5.4", + "version": "0.5.5", "description": "Visually enhance your notes with a customizable banner. Supports icons and time/date display.", "main": "dist/main.js", "scripts": { diff --git a/src/main.ts b/src/main.ts index 28728c5..d2e4574 100644 --- a/src/main.ts +++ b/src/main.ts @@ -206,13 +206,7 @@ export default class SimpleBanner extends Plugin { t.remove() }); - if (this.settings.properties.autohide) { - const inline = document.querySelector('.inline-title'); - const meta = document.querySelector('.metadata-container'); - if (inline && meta) { - inline.after(meta); - } - } + this.updateMetaDOM(true); // @ts-ignore Store.delete(view?.leaf.id); @@ -299,13 +293,7 @@ export default class SimpleBanner extends Plugin { handleLayoutChange() { const view = this.getActiveView(); if (view) { - if (this.settings.properties.autohide) { - const inline = document.querySelector('.inline-title'); - const meta = document.querySelector('.metadata-container'); - if (inline && meta) { - inline.before(meta); - } - } + this.updateMetaDOM() // @ts-ignore if (!Store.exists(view?.leaf.id)) { this.process(view.file, view); @@ -320,6 +308,7 @@ export default class SimpleBanner extends Plugin { const view = this.getActiveView(); if (view instanceof MarkdownView) { this.process(file, view); + this.updateMetaDOM(); } } @@ -335,6 +324,22 @@ export default class SimpleBanner extends Plugin { //---------------------------------- // Helper Methods //---------------------------------- + updateMetaDOM(reset = false) { + if (this.settings.properties.autohide) { + const inlines = document.querySelectorAll('.workspace-leaf-content[data-sb] .inline-title'); + const metas = document.querySelectorAll('.workspace-leaf-content[data-sb] .metadata-container'); + if (inlines.length > 0 && metas.length > 0) { + inlines.forEach((inline, idx) => { + if (reset) { + inline.after(metas[idx]); + } else { + inline.before(metas[idx]); + } + }) + } + } + } + getActiveView(): MarkdownView | null { return this.app.workspace.getActiveViewOfType(MarkdownView) || null; }