diff --git a/src/Visualisations/CBJuggl.ts b/src/Visualisations/CBJuggl.ts index 56ec9365..7de88ad3 100644 --- a/src/Visualisations/CBJuggl.ts +++ b/src/Visualisations/CBJuggl.ts @@ -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; @@ -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}); diff --git a/src/constants.ts b/src/constants.ts index bd2c2e36..5c34b68c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -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"; @@ -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: [] }; };