Skip to content

Commit

Permalink
feat(CreateIndex): CreateIndex Button now copies to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jul 21, 2021
1 parent b76f919 commit 3b9fa72
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/MatrixView.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Graph } from "graphlib";
import { ItemView, TFile, WorkspaceLeaf } from "obsidian";
import { closeImpliedLinks, debug } from "src/sharedFunctions";
import { closeImpliedLinks, copyToClipboard, debug } from "src/sharedFunctions";
import {
DATAVIEW_INDEX_DELAY,
TRAIL_ICON,
Expand Down Expand Up @@ -68,13 +68,11 @@ export default class MatrixView extends ItemView {

squareItems(g: Graph, currFile: TFile, realQ = true): internalLinkObj[] {
let items: string[];
const successors = (g.successors(currFile.basename) ?? []) as string[];
const predecessors = (g.predecessors(currFile.basename) ?? []) as string[];

if (realQ) {
items = successors;
items = (g.successors(currFile.basename) ?? []) as string[];
} else {
items = predecessors;
items = (g.predecessors(currFile.basename) ?? []) as string[];
}
const internalLinkObjArr: internalLinkObj[] = [];
// TODO I don't think I need to check the length here
Expand Down Expand Up @@ -193,10 +191,10 @@ export default class MatrixView extends ItemView {
});

const createIndexButton = this.contentEl.createEl("button", {
text: "Create Index",
text: "Create Index ⚠️",
});
createIndexButton.addEventListener("click", () => {
console.log(this.createIndex(allPaths, currFile.basename, settings));
copyToClipboard(this.createIndex(allPaths, currFile.basename, settings));
});

const [parentFieldName, siblingFieldName, childFieldName] = [
Expand Down

0 comments on commit 3b9fa72

Please sign in to comment.