Skip to content

Commit

Permalink
fix: don't show trail on kanbans
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jul 13, 2021
1 parent 7ddd85b commit eb8fefc
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 45 deletions.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const VIEW_TYPE_BREADCRUMBS_MATRIX = "breadcrumbs-matrix";

export const TRAIL_ICON = "breadcrumbs-trail-icon";
export const TRAIL_ICON_SVG = '<path fill="currentColor" stroke="currentColor" d="M48.8,4c-6,0-13.5,0.5-19.7,3.3S17.9,15.9,17.9,25c0,5,2.6,9.7,6.1,13.9s8.1,8.3,12.6,12.3s9,7.8,12.2,11.5 c3.2,3.7,5.1,7.1,5.1,10.2c0,14.4-13.4,19.3-13.4,19.3c-0.7,0.2-1.2,0.8-1.3,1.5s0.1,1.4,0.7,1.9c0.6,0.5,1.3,0.6,2,0.3 c0,0,16.1-6.1,16.1-23c0-4.6-2.6-8.8-6.1-12.8c-3.5-4-8.1-7.9-12.6-11.8c-4.5-3.9-8.9-7.9-12.2-11.8c-3.2-3.9-5.2-7.7-5.2-11.4 c0-7.8,3.6-11.6,8.8-14S43,8,48.8,8c4.6,0,9.3,0,11,0c0.7,0,1.4-0.4,1.7-1c0.3-0.6,0.3-1.4,0-2s-1-1-1.7-1C58.3,4,53.4,4,48.8,4 L48.8,4z M78.1,4c-0.6,0-1.2,0.2-1.6,0.7l-8.9,9.9c-0.5,0.6-0.7,1.4-0.3,2.2c0.3,0.7,1,1.2,1.8,1.2h0.1l-2.8,2.6 c-0.6,0.6-0.8,1.4-0.5,2.2c0.3,0.8,1,1.3,1.9,1.3h1.3l-4.5,4.6c-0.6,0.6-0.7,1.4-0.4,2.2c0.3,0.7,1,1.2,1.8,1.2h10v4 c0,0.7,0.4,1.4,1,1.8c0.6,0.4,1.4,0.4,2,0c0.6-0.4,1-1,1-1.8v-4h10c0.8,0,1.5-0.5,1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4,0.6L9.2,60.5 c-0.6,0.6-0.7,1.4-0.4,2.2c0.3,0.7,1,1.2,1.8,1.2h3l-6.5,6.8c-0.6,0.6-0.7,1.4-0.4,2.2s1,1.2,1.8,1.2H13l-8.5,8.6 C4,83.2,3.8,84,4.2,84.8C4.5,85.5,5.2,86,6,86h16v5.4c0,0.7,0.4,1.4,1,1.8c0.6,0.4,1.4,0.4,2,0c0.6-0.4,1-1,1-1.8V86h16 c0.8,0,1.5-0.5,1.8-1.2c0.3-0.7,0.1-1.6-0.4-2.2L35,74h4.4c0.8,0,1.5-0.5,1.8-1.2s0.2-1.6-0.4-2.2l-6.5-6.8h3 c0.8,0,1.5-0.5,1.8-1.2c0.3-0.7,0.2-1.6-0.4-2.2L25.4,46.6C25.1,46.2,24.5,46,24,46L24,46z M24,50.9l8.7,9h-3 c-0.8,0-1.5,0.5-1.8,1.2s-0.2,1.6,0.4,2.2l6.5,6.8h-4.5c-0.8,0-1.5,0.5-1.8,1.2c-0.3,0.7-0.1,1.6,0.4,2.2l8.5,8.6H10.8l8.5-8.6 c0.6-0.6,0.7-1.4,0.4-2.2c-0.3-0.7-1-1.2-1.8-1.2h-4.5l6.5-6.8c0.6-0.6,0.7-1.4,0.4-2.2c-0.3-0.7-1-1.2-1.8-1.2h-3L24,50.9z"/>'

export const splitLinksRegex = new RegExp(/\[\[(.+?)\]\]/g);
export const dropHeaderOrAlias = new RegExp(/\[\[([^#|]+)\]\]/);
Expand Down
90 changes: 45 additions & 45 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BreadcrumbsSettingTab } from "src/BreadcrumbsSettingTab";
import {
DATAVIEW_INDEX_DELAY,
TRAIL_ICON,
TRAIL_ICON_SVG,
VIEW_TYPE_BREADCRUMBS_MATRIX
} from "src/constants";
import type {
Expand Down Expand Up @@ -96,10 +97,7 @@ export default class BreadcrumbsPlugin extends Plugin {
}, DATAVIEW_INDEX_DELAY);
});

addIcon(
TRAIL_ICON,
'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.2L35,74h4.4c0.8,0,1.5-0.5,1.8-1.2s0.2-1.6-0.4-2.2l-6.5-6.8h3 c0.8,0,1.5-0.5,1.8-1.2c0.3-0.7,0.2-1.6-0.4-2.2L25.4,46.6C25.1,46.2,24.5,46,24,46L24,46z M24,50.9l8.7,9h-3 c-0.8,0-1.5,0.5-1.8,1.2s-0.2,1.6,0.4,2.2l6.5,6.8h-4.5c-0.8,0-1.5,0.5-1.8,1.2c-0.3,0.7-0.1,1.6,0.4,2.2l8.5,8.6H10.8l8.5-8.6 c0.6-0.6,0.7-1.4,0.4-2.2c-0.3-0.7-1-1.2-1.8-1.2h-4.5l6.5-6.8c0.6-0.6,0.7-1.4,0.4-2.2c-0.3-0.7-1-1.2-1.8-1.2h-3L24,50.9z"/>'
);
addIcon(TRAIL_ICON, TRAIL_ICON_SVG);

this.addCommand({
id: "show-breadcrumbs-matrix-view",
Expand All @@ -126,7 +124,6 @@ export default class BreadcrumbsPlugin extends Plugin {
neighbours: neighbourObj,
relationship: string
): void {
// NOTE I removed an if(neighbours[relationship]) check here
g.setNode(currFileName, currFileName);
neighbours[relationship].forEach((node) =>
g.setEdge(currFileName, node, relationship)
Expand Down Expand Up @@ -265,56 +262,59 @@ export default class BreadcrumbsPlugin extends Plugin {
}

async drawTrail(): Promise<void> {
if (this.settings.showTrail) {
if (!this.settings.showTrail) { return }

const { gParents, gChildren } = this.currGraphs;
const closedParents = closeImpliedLinks(gParents, gChildren)
const sortedTrails = this.getBreadcrumbs(closedParents);
const currFile = this.app.workspace.getActiveFile();
const settings = this.settings
const currFile = this.app.workspace.getActiveFile();
const frontm = this.app.metadataCache.getFileCache(currFile)?.frontmatter ?? {};
if (frontm['kanban-plugin']) { return }

// Get the container div of the active note
const previewView = document.querySelector(
"div.mod-active div.view-content div.markdown-preview-view"
);
previewView.querySelector('div.breadcrumbs-trail')?.remove()
const { gParents, gChildren } = this.currGraphs;
const closedParents = closeImpliedLinks(gParents, gChildren)
const sortedTrails = this.getBreadcrumbs(closedParents);
const settings = this.settings

const trailDiv = createDiv()
previewView.prepend(trailDiv)
// Get the container div of the active note
const previewView = document.querySelector(
"div.mod-active div.view-content div.markdown-preview-view"
);
previewView.querySelector('div.breadcrumbs-trail')?.remove()

this.visited.push([currFile.path, trailDiv])
const trailDiv = createDiv()
previewView.prepend(trailDiv)

trailDiv.className = `breadcrumbs-trail is-readable-line-width${settings.respectReadableLineLength
? " markdown-preview-sizer markdown-preview-section"
: ""
}`
this.visited.push([currFile.path, trailDiv])

previewView.prepend(trailDiv);
trailDiv.className = `breadcrumbs-trail is-readable-line-width${settings.respectReadableLineLength
? " markdown-preview-sizer markdown-preview-section"
: ""
}`

trailDiv.empty();
previewView.prepend(trailDiv);

trailDiv.empty();

if (settings.trailOrTable === 1) {
new TrailPath({
target: trailDiv,
props: { sortedTrails, app: this.app, settings, currFile }
})
} else if (settings.trailOrTable === 2) {
new TrailGrid({
target: trailDiv,
props: { sortedTrails, app: this.app, plugin: this }
})
} else {
new TrailPath({
target: trailDiv,
props: { sortedTrails, app: this.app, settings, currFile }
});
new TrailGrid({
target: trailDiv,
props: { sortedTrails, app: this.app, plugin: this }
})
}

if (settings.trailOrTable === 1) {
new TrailPath({
target: trailDiv,
props: { sortedTrails, app: this.app, settings, currFile }
})
} else if (settings.trailOrTable === 2) {
new TrailGrid({
target: trailDiv,
props: { sortedTrails, app: this.app, plugin: this }
})
} else {
new TrailPath({
target: trailDiv,
props: { sortedTrails, app: this.app, settings, currFile }
});
new TrailGrid({
target: trailDiv,
props: { sortedTrails, app: this.app, plugin: this }
})
}

}


Expand Down

0 comments on commit eb8fefc

Please sign in to comment.