Skip to content

Commit

Permalink
fix: 🐛 closeImpliedLinks was mutating the input graphs
Browse files Browse the repository at this point in the history
I now clone to graph instead. This fixes the `.breadcrumbs-implied` class
  • Loading branch information
SkepticMystic committed Jul 21, 2021
1 parent 3b9fa72 commit 5898872
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/sharedFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Graph } from "graphlib";
import * as graphlib from "graphlib";
import { parseTypedLink } from "juggl-api";
import type { App, FrontMatterCache, TFile, WorkspaceLeaf } from "obsidian";
import { dropHeaderOrAlias, splitLinksRegex } from "src/constants";
Expand Down Expand Up @@ -263,7 +264,7 @@ export function superDebug(settings: BreadcrumbsSettings, log: any): void {
}

export function closeImpliedLinks(real: Graph, implied: Graph): Graph {
const closedG = real;
const closedG = graphlib.json.read(graphlib.json.write(real));
implied.edges().forEach((impliedEdge) => {
closedG.setEdge(impliedEdge.w, impliedEdge.v);
});
Expand Down Expand Up @@ -390,3 +391,15 @@ export function permute(permutation: any[]): any[][] {
export function dropMD(path: string) {
return path.split(".md", 1)[0];
}

export const copyToClipboard = (str: string) => {
const el = document.createElement("textarea");
el.value = str;
el.setAttribute("readonly", "");
el.style.position = "absolute";
el.style.left = "-9999px";
document.body.appendChild(el);
el.select();
document.execCommand("copy");
document.body.removeChild(el);
};

0 comments on commit 5898872

Please sign in to comment.