Skip to content

Commit

Permalink
✨ file name in view title
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Dec 23, 2024
1 parent 4385893 commit 5a2835c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/reveal/revealPreviewView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
type Menu,
type WorkspaceLeaf,
} from "obsidian";
import type { SlidesExtendedPlugin } from "src/slidesExtended-Plugin";
import type { Options, SlidesExtendedSettings } from "../@types";
import { YamlParser } from "../yaml/yamlParser";

Expand All @@ -16,16 +17,19 @@ export class RevealPreviewView extends ItemView {

private urlRegex = /#\/(\d*)(?:\/(\d*))?(?:\/(\d*))?/;
private yaml: YamlParser;
private plugin: SlidesExtendedPlugin;

constructor(
leaf: WorkspaceLeaf,
home: URL,
plugin: SlidesExtendedPlugin,
settings: SlidesExtendedSettings,
onCloseListener: () => void,
) {
super(leaf);
this.home = home;
this.yaml = new YamlParser(settings);
this.plugin = plugin;
this.onCloseListener = onCloseListener;

this.addAction("globe", "Open in browser", () => {
Expand Down Expand Up @@ -238,7 +242,8 @@ export class RevealPreviewView extends ItemView {
}

getDisplayText() {
return "Slide preview";
const name = this.plugin.getTargetName();
return name ? `Preview: ${name}` : "Slide preview";
}

getIcon() {
Expand Down
9 changes: 9 additions & 0 deletions src/slidesExtended-Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class SlidesExtendedPlugin extends Plugin {
new RevealPreviewView(
leaf,
this.url,
this,
this.settings,
this.hideView.bind(this),
),
Expand Down Expand Up @@ -146,6 +147,14 @@ export class SlidesExtendedPlugin extends Plugin {
return null;
}

getTargetName(): string {
console.log("target", this.target);
if (!this.target) {
return "";
}
return this.target.name;
}

onChange(file: TAbstractFile) {
if (!this.settings.autoReload) {
return;
Expand Down

0 comments on commit 5a2835c

Please sign in to comment.