From 61c9770d853d60725dbb8b1f2b84451c98cb07e1 Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Tue, 30 Nov 2021 11:07:29 +0200 Subject: [PATCH] fix(DownView): :bug: Don't depend on `Create Index > make wikilinks` setting --- src/Components/Down.svelte | 13 +++++++------ src/Components/Stats.svelte | 7 ++++--- src/main.ts | 13 +++++++------ src/sharedFunctions.ts | 2 +- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Components/Down.svelte b/src/Components/Down.svelte index f5a4b11f..4486fa5d 100644 --- a/src/Components/Down.svelte +++ b/src/Components/Down.svelte @@ -1,4 +1,5 @@ diff --git a/src/Components/Stats.svelte b/src/Components/Stats.svelte index d8931a17..4584e6db 100644 --- a/src/Components/Stats.svelte +++ b/src/Components/Stats.svelte @@ -23,20 +23,21 @@ nodesToo = true ) { const gInfo = hierData[dir][gType]; + const { wikilinkIndex } = settings; if (nodesToo) { gInfo.nodes = gInfo.graph.nodes(); gInfo.nodesStr = gInfo.nodes - .map((n) => makeWiki(settings.wikilinkIndex, n)) + .map((n) => makeWiki(n, wikilinkIndex)) .join("\n"); } gInfo.edges = gInfo.graph.edges(); const edgeStrArr = gInfo.graph.mapEdges( (k, a, s, t) => - `${makeWiki(settings.wikilinkIndex, nodesToo ? s : t)} ${ + `${makeWiki(nodesToo ? s : t, wikilinkIndex)} ${ ARROW_DIRECTIONS[dir] - } ${makeWiki(settings.wikilinkIndex, nodesToo ? t : s)}` + } ${makeWiki(nodesToo ? t : s, wikilinkIndex)}` ); gInfo.edgesStr = edgeStrArr.join("\n"); } diff --git a/src/main.ts b/src/main.ts index 1f776a77..d6db9cbf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1147,9 +1147,11 @@ export default class BCPlugin extends Plugin { // !SECTION OneSource - createIndex(allPaths: string[][]): string { + createIndex( + allPaths: string[][], + asWikilinks: boolean = this.settings.wikilinkIndex + ): string { let index = ""; - const { wikilinkIndex, aliasesInIndex } = this.settings; const copy = cloneDeep(allPaths); const reversed = copy.map((path) => path.reverse()); reversed.forEach((path) => path.shift()); @@ -1171,10 +1173,9 @@ export default class BCPlugin extends Plugin { ) { continue; } else { - index += `${indent.repeat(depth)}- ${makeWiki( - wikilinkIndex, - currNode - )}`; + index += `${indent.repeat(depth)}- ${ + asWikilinks ? makeWiki(currNode) : currNode + }`; index += "\n"; diff --git a/src/sharedFunctions.ts b/src/sharedFunctions.ts index a851ee24..4c4ec3a5 100644 --- a/src/sharedFunctions.ts +++ b/src/sharedFunctions.ts @@ -134,7 +134,7 @@ export function complement(A: T[], B: T[]) { return A.filter((a) => !B.includes(a)); } -export function makeWiki(wikiQ: boolean, str: string) { +export function makeWiki(str: string, wikiQ = true) { let copy = str.slice(); if (wikiQ) { copy = "[[" + copy;