FIX: inline title/autohide issues

- when having multiple tabs open it was still possible for the frontmatter properties to be out of place
This commit is contained in:
Sandro Ducceschi 2025-06-27 12:07:18 +02:00
parent 5a79baa8f2
commit bcb6e60467
4 changed files with 23 additions and 18 deletions

View file

@ -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",

4
package-lock.json generated
View file

@ -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",

View file

@ -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": {

View file

@ -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;
}