Skip to content

Commit

Permalink
Prep 0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jun 21, 2021
1 parent a1c505f commit c526d18
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 23 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "breadcrumbs",
"name": "Breadcrumbs",
"version": "0.2.3",
"version": "0.2.4",
"minAppVersion": "0.12.5",
"description": "Visualise the hierarchy of your vault using a breadcrumb trail",
"author": "SkepticMystic",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "breadcrumbs-plugin",
"version": "0.2.3",
"version": "0.2.4",
"description": "Visualise the hierarchy of your vault using a breadcrumb trail",
"main": "main.js",
"scripts": {
Expand Down
73 changes: 52 additions & 21 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,40 @@ interface fileFrontmatter {
frontmatter: FrontMatterCache;
}

const VIEW_TYPE_BREADCRUMBS = "breadcrumbs";
class BreadcrumbsView extends ItemView {
const VIEW_TYPE_BREADCRUMBS_TRAIL = "breadcrumbs-trail";

class BreadcrumbsTrailView extends ItemView {
plugin: BreadcrumbsPlugin;
settings: BreadcrumbsPluginSettings;

constructor(
leaf: WorkspaceLeaf,
plugin: BreadcrumbsPlugin,
settings: BreadcrumbsPluginSettings
) {
super(leaf);
this.plugin = plugin;
this.settings = settings;
this.registerEvent(
this.app.workspace.on("active-leaf-change", async () => await this.draw())
);
}

onload() {
super.onload();
}

getViewType(): string {
return VIEW_TYPE_BREADCRUMBS_TRAIL;
}

getDisplayText(): string {
return "Breadcrumbs Trail";
}
}

const VIEW_TYPE_BREADCRUMBS_MATRIX = "breadcrumbs-matrix";
class BreadcrumbsMatrixView extends ItemView {
plugin: BreadcrumbsPlugin;
settings: BreadcrumbsPluginSettings;

Expand All @@ -58,11 +90,11 @@ class BreadcrumbsView extends ItemView {
}

getViewType(): string {
return VIEW_TYPE_BREADCRUMBS;
return VIEW_TYPE_BREADCRUMBS_MATRIX;
}

getDisplayText(): string {
return "Breadcrumbs";
return "Breadcrumbs Matrix";
}

getFileFrontmatter(): fileFrontmatter[] {
Expand Down Expand Up @@ -335,14 +367,15 @@ class BreadcrumbsView extends ItemView {
"breadcrumb-trail",
(trailEl) => {
crumbs.forEach((crumb) => {
const link = trailEl.createEl("a", {
cls: "internal-link",
text: crumb,
});
link.href = null;
link.addEventListener("click", () => {
this.app.workspace.openLinkText(crumb, currFile.path);
});
this.makeInternalLinkInEl(trailEl, crumb, currFile);
// const link = trailEl.createEl("a", {
// cls: "internal-link",
// text: crumb,
// });
// link.href = null;
// link.addEventListener("click", () => {
// this.app.workspace.openLinkText(crumb, currFile.path);
// });
trailEl.createDiv({ text: " ^ " });
});
}
Expand All @@ -360,7 +393,7 @@ class BreadcrumbsView extends ItemView {
export default class BreadcrumbsPlugin extends Plugin {
settings: BreadcrumbsPluginSettings;
plugin: BreadcrumbsPlugin;
view: BreadcrumbsView;
view: BreadcrumbsMatrixView;

async onload(): Promise<void> {
console.log("loading plugin");
Expand All @@ -382,8 +415,8 @@ export default class BreadcrumbsPlugin extends Plugin {
checkCallback: (checking: boolean) => {
if (checking) {
return (
this.app.workspace.getLeavesOfType(VIEW_TYPE_BREADCRUMBS).length ===
0
this.app.workspace.getLeavesOfType(VIEW_TYPE_BREADCRUMBS_MATRIX)
.length === 0
);
}
this.initLeaf();
Expand All @@ -392,11 +425,8 @@ export default class BreadcrumbsPlugin extends Plugin {

this.addSettingTab(new BreadcrumbsSettingTab(this.app, this));

this.registerView(VIEW_TYPE_BREADCRUMBS, (leaf: WorkspaceLeaf) => {
// const crumbs = this.getBreadcrumbs(
// await this.initialiseGraph(this.settings)
// );
return (this.view = new BreadcrumbsView(
this.registerView(VIEW_TYPE_BREADCRUMBS_MATRIX, (leaf: WorkspaceLeaf) => {
return (this.view = new BreadcrumbsMatrixView(
leaf,
this.plugin,
this.settings
Expand All @@ -406,7 +436,8 @@ export default class BreadcrumbsPlugin extends Plugin {

initLeaf(): void {
this.app.workspace.getRightLeaf(false).setViewState({
type: VIEW_TYPE_BREADCRUMBS,
type: VIEW_TYPE_BREADCRUMBS_MATRIX,
state: { file: this.app.workspace.getLeaf() },
});
}

Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"0.2.4": "0.12.5",
"0.2.3": "0.12.5",
"0.2.2": "0.12.5",
"0.2.1": "0.12.5",
Expand Down

0 comments on commit c526d18

Please sign in to comment.