Skip to content

Commit

Permalink
feat: Better default values, allow customizing juggl through code block
Browse files Browse the repository at this point in the history
  • Loading branch information
HEmile committed Jan 12, 2022
1 parent e92021d commit 5c4b876
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Visualisations/CBJuggl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {ParsedCodeblock} from "../interfaces";
import type BCPlugin from "../main";
import {getPlugin, IJugglSettings} from 'juggl-api';
import {JUGGL_CB_DEFAULTS} from "../constants";

function indentToDepth(indent: string) {
return indent.length / 2 + 1;
Expand Down Expand Up @@ -28,12 +29,16 @@ export function createdJugglCB(plugin: BCPlugin,
// TODO: Error handling
return;
}
for (let key in JUGGL_CB_DEFAULTS) {
if (key in args && args[key] === undefined) {
args[key] = JUGGL_CB_DEFAULTS[key];
}
}
console.log({args});
const nodes = lines
.filter(([indent, node]) => meetsConditions(indent, node, froms, min, max))
.map(([_, node]) => node);
console.log({nodes})
const juggl = jugglPlugin.createJuggl(target, null, null, nodes)
console.log("Created juggl!")
const juggl = jugglPlugin.createJuggl(target, args, null, nodes)
plugin.addChild(juggl);
juggl.load();
console.log({juggl});
Expand Down
26 changes: 26 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
UserHier,
visTypes,
} from "./interfaces";
import {IJugglSettings} from "juggl-api";

export const MATRIX_VIEW = "BC-matrix";
export const STATS_VIEW = "BC-stats";
Expand Down Expand Up @@ -61,6 +62,31 @@ export const CODEBLOCK_FIELDS = [
"implied",
];


export const JUGGL_CB_DEFAULTS: IJugglSettings = {
autoAddNodes: false,
autoExpand: false,
autoZoom: false,
coreStore: "Obsidian",
expandInitial: false,
fdgdLayout: 'cola',
filter: '',
height: '650px',
hoverEdges: false,
layout: 'force-directed',
limit: 400,
mergeEdges: true,
metaKeyHover: true,
mode: 'workspace',
navigator: true,
openWithShift: false,
styleGroups: [],
toolbar: true,
width: '100%',
zoomSpeed: 1,
};
CODEBLOCK_FIELDS.push(...Object.keys(JUGGL_CB_DEFAULTS));

export const blankUserHier = (): UserHier => {
return { up: [], same: [], down: [], next: [], prev: [] };
};
Expand Down

0 comments on commit 5c4b876

Please sign in to comment.