diff --git a/main.js b/main.js index 4d7ad7b6..304317b5 100644 --- a/main.js +++ b/main.js @@ -20849,11 +20849,13 @@ function getReflexiveClosure(g, userHiers, closeAsOpposite = true) { }); return copy; } -function addNodesIfNot(g, nodes, attr) { - nodes.forEach((node) => { - if (!g.hasNode(node)) - g.addNode(node, attr); - }); +function addNodesIfNot(g, nodes, attr = { order: 9999 }) { + for (const node of nodes) { + g.updateNode(node, (exstantAttrs) => { + const extantOrder = exstantAttrs.order; + return Object.assign(Object.assign({}, exstantAttrs), { order: extantOrder && extantOrder < 9999 ? extantOrder : attr.order }); + }); + } } function addEdgeIfNot(g, source, target, attr) { if (!g.hasEdge(source, target)) @@ -24845,7 +24847,6 @@ class MatrixView extends require$$0.ItemView { iSamesII.push(this.toInternalLinkObj(s, false, parent)); }); }); - /// A real sibling implies the reverse sibling is.push(...iSamesII); // !SECTION iu = this.removeDuplicateImplied(ru, iu); @@ -49850,12 +49851,12 @@ class BCPlugin extends require$$0.Plugin { for (const item of listItems) { const currItem = lines[item.position.start.line]; const afterBulletCurr = afterBulletReg.exec(currItem)[1]; - const dropWikiCurr = dropWikiLinksReg.exec(afterBulletCurr)[1]; - let fieldCurr = fieldReg.exec(afterBulletCurr)[1].trim() || null; + const note = dropWikiLinksReg.exec(afterBulletCurr)[1]; + let field = fieldReg.exec(afterBulletCurr)[1].trim() || null; // Ensure fieldName is one of the existing up fields. `null` if not - if (fieldCurr !== null && !upFields.includes(fieldCurr)) { - problemFields.push(fieldCurr); - fieldCurr = null; + if (field !== null && !upFields.includes(field)) { + problemFields.push(field); + field = null; } const { parent } = item; if (parent >= 0) { @@ -49863,16 +49864,16 @@ class BCPlugin extends require$$0.Plugin { const afterBulletParent = afterBulletReg.exec(parentNote)[1]; const dropWikiParent = dropWikiLinksReg.exec(afterBulletParent)[1]; hierarchyNoteItems.push({ - currNote: dropWikiCurr, - parentNote: dropWikiParent, - field: fieldCurr, + note, + parent: dropWikiParent, + field, }); } else { hierarchyNoteItems.push({ - currNote: dropWikiCurr, - parentNote: null, - field: fieldCurr, + note, + parent: null, + field, }); } } @@ -50125,15 +50126,14 @@ class BCPlugin extends require$$0.Plugin { const { HNUpField, userHiers } = this.settings; const upFields = getFields(userHiers, "up"); hierarchyNotesArr.forEach((hnItem, i) => { - var _a, _b, _c; - const upField = (_a = hnItem.field) !== null && _a !== void 0 ? _a : (HNUpField || upFields[0]); - const downField = (_b = getOppFields(userHiers, upField)[0]) !== null && _b !== void 0 ? _b : `${upField}`; - if (hnItem.parentNote === null) { - const s = hnItem.currNote; - const t = (_c = hierarchyNotesArr[i + 1]) === null || _c === void 0 ? void 0 : _c.currNote; - //@ts-ignore + var _a, _b; + const { note, field, parent } = hnItem; + const upField = field !== null && field !== void 0 ? field : (HNUpField || upFields[0]); + const downField = (_a = getOppFields(userHiers, upField)[0]) !== null && _a !== void 0 ? _a : `${upField}`; + if (parent === null) { + const s = note; + const t = (_b = hierarchyNotesArr[i + 1]) === null || _b === void 0 ? void 0 : _b.note; addNodesIfNot(mainG, [s, t]); - //@ts-ignore addEdgeIfNot(mainG, s, t, { dir: "down", field: downField }); } else { @@ -50141,18 +50141,14 @@ class BCPlugin extends require$$0.Plugin { dir: "up", field: upField, }; - //@ts-ignore - addNodesIfNot(mainG, [hnItem.currNote, hnItem.parentNote]); - //@ts-ignore - addEdgeIfNot(mainG, hnItem.currNote, hnItem.parentNote, aUp); + addNodesIfNot(mainG, [note, parent]); + addEdgeIfNot(mainG, note, parent, aUp); const aDown = { dir: "down", field: downField, }; - //@ts-ignore - addNodesIfNot(mainG, [hnItem.parentNote, hnItem.currNote]); - //@ts-ignore - addEdgeIfNot(mainG, hnItem.parentNote, hnItem.currNote, aDown); + addNodesIfNot(mainG, [parent, note]); + addEdgeIfNot(mainG, parent, note, aDown); } }); } diff --git a/src/MatrixView.ts b/src/MatrixView.ts index a4e2f0ec..87eff57a 100644 --- a/src/MatrixView.ts +++ b/src/MatrixView.ts @@ -130,14 +130,11 @@ export default class MatrixView extends ItemView { const { reals, implieds } = realsnImplieds[dir]; filteredRealNImplied[dir].reals = reals .filter((real) => hier[dir].includes(real.field)) - .map((item) => - this.toInternalLinkObj(item.to, true) - ) as internalLinkObj[]; + .map((item) => this.toInternalLinkObj(item.to, true)); + filteredRealNImplied[dir].implieds = implieds .filter((implied) => hier[dir].includes(implied.field)) - .map((item) => - this.toInternalLinkObj(item.to, false) - ) as internalLinkObj[]; + .map((item) => this.toInternalLinkObj(item.to, false)); } let { @@ -168,7 +165,6 @@ export default class MatrixView extends ItemView { }); }); - /// A real sibling implies the reverse sibling is.push(...iSamesII); // !SECTION diff --git a/src/graphUtils.ts b/src/graphUtils.ts index 1aa9e463..5a741451 100644 --- a/src/graphUtils.ts +++ b/src/graphUtils.ts @@ -104,11 +104,17 @@ export function getReflexiveClosure( export function addNodesIfNot( g: MultiGraph, nodes: string[], - attr?: { order: number } + attr = { order: 9999 } ) { - nodes.forEach((node) => { - if (!g.hasNode(node)) g.addNode(node, attr); - }); + for (const node of nodes) { + g.updateNode(node, (exstantAttrs) => { + const extantOrder: number | undefined = exstantAttrs.order; + return { + ...exstantAttrs, + order: extantOrder && extantOrder < 9999 ? extantOrder : attr.order, + }; + }); + } } export function addEdgeIfNot( diff --git a/src/main.ts b/src/main.ts index 509c5ea9..31704bcd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1123,6 +1123,7 @@ export default class BCPlugin extends Plugin { values.forEach((target) => { const targetOrder = this.getTargetOrder(frontms, target); + this.populateMain( mainG, basename,