Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
HEmile committed May 8, 2023
2 parents 1f99183 + ce58da1 commit e5f28fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ export default class SuperchargedLinks extends Plugin {
}

updateContainer(container: HTMLElement, plugin: SuperchargedLinks, selector: string) {
if (!plugin.settings.enableBacklinks) return;
if (!plugin.settings.enableBacklinks && container.getAttribute("data-type") !== "file-explorer") return;
if (!plugin.settings.enableFileList && container.getAttribute("data-type") === "file-explorer") return;
const nodes = container.findAll(selector);
for (let i = 0; i < nodes.length; ++i) {
const el = nodes[i] as HTMLElement;
Expand Down Expand Up @@ -176,6 +177,7 @@ export default class SuperchargedLinks extends Plugin {
_watchContainerDynamic(viewType: string, container: HTMLElement, plugin: SuperchargedLinks, selector: string, own_class = 'tree-item-inner', parent_class = 'tree-item') {
// Used for efficient updating of the backlinks panel
// Only loops through newly added DOM nodes instead of changing all of them
if (!plugin.settings.enableBacklinks) return;
let observer = new MutationObserver((records, _) => {
records.forEach((mutation) => {
if (mutation.type === 'childList') {
Expand Down
9 changes: 8 additions & 1 deletion src/linkAttributes/linkAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ export function updateDivExtraAttributes(app: App, settings: SuperchargedLinksSe
if (!linkName) {
linkName = link.textContent;
}
if (!!link.parentElement.getAttribute('data-path')) {
// File Browser
linkName = link.parentElement.getAttribute('data-path');
} else if (link.parentElement.getAttribute("class") == "suggestion-content" && !!link.nextElementSibling) {
// Auto complete
linkName = link.nextElementSibling.textContent + linkName;
}
const dest = app.metadataCache.getFirstLinkpathDest(getLinkpath(linkName), destName)

if (dest) {
Expand Down Expand Up @@ -137,7 +144,7 @@ export function updateVisibleLinks(app: App, plugin: SuperchargedLinks) {
const tabHeader: HTMLElement = leaf.tabHeaderInnerTitleEl;
if (settings.enableTabHeader) {
// Supercharge tab headers
updateDivExtraAttributes(app, settings, tabHeader, "");
updateDivExtraAttributes(app, settings, tabHeader, "", file.path);
}
else {
clearExtraAttributes(tabHeader);
Expand Down

0 comments on commit e5f28fc

Please sign in to comment.