generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(List/Matrix View): ✨ Setting to list field names to check for al…
…ternate link text Basically, you can choose to use aliases to display notes, instead of file name
- Loading branch information
1 parent
d8ca26d
commit 52f0321
Showing
10 changed files
with
265 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,69 @@ | ||
<script lang="ts"> | ||
import type { App,TFile, View } from "obsidian"; | ||
import type { BreadcrumbsSettings } from "src/interfaces"; | ||
import { openOrSwitch } from "src/sharedFunctions"; | ||
import type { App, TFile, View } from "obsidian"; | ||
import type { BreadcrumbsSettings } from "src/interfaces"; | ||
import { openOrSwitch } from "src/sharedFunctions"; | ||
export let sortedTrails: string[][]; | ||
export let app: App; | ||
export let settings: BreadcrumbsSettings; | ||
export let currFile: TFile; | ||
export let sortedTrails: string[][]; | ||
export let app: App; | ||
export let settings: BreadcrumbsSettings; | ||
export let currFile: TFile; | ||
const activeLeafView = app.workspace.activeLeaf.view | ||
const activeLeafView = app.workspace.activeLeaf.view; | ||
function hoverPreview(event: MouseEvent, view: View): void { | ||
const targetEl = event.target as HTMLElement; | ||
function hoverPreview(event: MouseEvent, view: View, to: string): void { | ||
const targetEl = event.target as HTMLElement; | ||
view.app.workspace.trigger("hover-link", { | ||
event, | ||
source: view.getViewType(), | ||
hoverParent: view, | ||
targetEl, | ||
linktext: targetEl.innerText, | ||
}); | ||
} | ||
let showAll = settings.showAll; | ||
$: buttonText = showAll ? "Shortest" : "All"; | ||
$: trailsToShow = showAll ? sortedTrails : [sortedTrails[0]]; | ||
view.app.workspace.trigger("hover-link", { | ||
event, | ||
source: view.getViewType(), | ||
hoverParent: view, | ||
targetEl, | ||
linktext: to, | ||
}); | ||
} | ||
let showAll = settings.showAll; | ||
$: buttonText = showAll ? "Shortest" : "All"; | ||
$: trailsToShow = showAll ? sortedTrails : [sortedTrails[0]]; | ||
</script> | ||
|
||
<span class="breadcrumbs-trail-path-container"> | ||
<div class="trails-div"> | ||
{#each trailsToShow as trail} | ||
<div> | ||
{#if trail.length === 0} | ||
<span>{settings.noPathMessage}</span> | ||
{:else} | ||
{#each trail as crumb, i} | ||
<span | ||
class="internal-link breadcrumbs-link" | ||
on:click={async (e) => await openOrSwitch(app, crumb, currFile, e)} | ||
on:mouseover={(e) => hoverPreview(e, activeLeafView)}> | ||
{crumb} | ||
</span> | ||
{#if i < trail.length - 1} | ||
<span>{' ' + settings.trailSeperator + ' '}</span> | ||
{/if} | ||
{/each} | ||
{/if} | ||
</div> | ||
{/each} | ||
</div> | ||
<div class="trails-div"> | ||
{#each trailsToShow as trail} | ||
<div> | ||
{#if trail.length === 0} | ||
<span>{settings.noPathMessage}</span> | ||
{:else} | ||
{#each trail as crumb, i} | ||
<span | ||
class="internal-link breadcrumbs-link" | ||
on:click={async (e) => | ||
await openOrSwitch(app, crumb, currFile, e)} | ||
on:mouseover={(e) => hoverPreview(e, activeLeafView, crumb)} | ||
> | ||
{crumb} | ||
</span> | ||
{#if i < trail.length - 1} | ||
<span>{" " + settings.trailSeperator + " "}</span> | ||
{/if} | ||
{/each} | ||
{/if} | ||
</div> | ||
{/each} | ||
</div> | ||
|
||
{#if sortedTrails.length > 1} | ||
{#if sortedTrails.length > 1} | ||
<div> | ||
<button | ||
class="button-div" | ||
on:click={() => showAll = !showAll}> | ||
{buttonText} | ||
</button> | ||
<button class="button-div" on:click={() => (showAll = !showAll)}> | ||
{buttonText} | ||
</button> | ||
</div> | ||
{/if} | ||
{/if} | ||
</span> | ||
|
||
|
||
<style> | ||
span.breadcrumbs-trail-path-container { | ||
span.breadcrumbs-trail-path-container { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
</style> | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters