Skip to content

Commit

Permalink
0.1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
zsviczian committed Apr 2, 2023
1 parent fb203e2 commit 87c7910
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 43 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "excalibrain",
"name": "ExcaliBrain",
"version": "0.1.11",
"version": "0.1.12",
"minAppVersion": "0.15.6",
"description": "A clean, intuitive and editable graph view for Obsidian",
"author": "Zsolt Viczian",
Expand Down
44 changes: 22 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"obsidian-dataview": "^0.5.51",
"obsidian-dataview": "^0.5.55",
"@popperjs/core": "^2.11.6"
},
"devDependencies": {
Expand All @@ -31,7 +31,7 @@
"@rollup/plugin-typescript": "^8.3.0",
"@types/node": "^18.11.9",
"cross-env": "^7.0.3",
"obsidian": "^0.16.3",
"obsidian": "^1.1.1",
"rollup": "^2.79.1",
"rollup-plugin-visualizer": "^5.6.0",
"rollup-plugin-terser": "^7.0.2",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
output: {
dir: '.',
entryFileNames: 'main.js',
sourcemap: 'inline',
sourcemap: isProd?false:'inline',
format: 'cjs',
exports: 'default',
},
Expand Down
24 changes: 17 additions & 7 deletions src/Scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ export class Scene {
ea.style.fontSize = style.fontSize;
this.textSize = ea.measureText("m".repeat(style.maxLabelLength+3));
this.nodeWidth = this.textSize.width + 3 * style.padding;
if(this.plugin.settings.compactView) {
this.nodeWidth = this.nodeWidth * 0.6;
}
this.nodeHeight = 2 * (this.textSize.height + 2 * style.padding);

const frame1 = () => {
Expand Down Expand Up @@ -390,13 +393,20 @@ export class Scene {
: siblings.length >= 10
? 2
: 1;
const childrenCols = children.length <= 12
? [1, 1, 2, 3, 3, 3, 3, 4, 4, 5, 5, 4, 4][children.length]
: 5;
const parentCols = parents.length < 5
? [1, 1, 2, 3, 2][parents.length]
: 3;

const childrenCols = this.plugin.settings.compactView
? (children.length <= 12
? [1, 1, 2, 3, 3, 3, 3, 2, 2, 3, 3, 2, 2][children.length]
: 3)
: (children.length <= 12
? [1, 1, 2, 3, 3, 3, 3, 4, 4, 5, 5, 4, 4][children.length]
: 5);
const parentCols = this.plugin.settings.compactView
? (parents.length < 2
? 1
: 2)
: (parents.length < 5
? [1, 1, 2, 3, 2][parents.length]
: 3);


const lCenter = new Layout({
Expand Down
13 changes: 13 additions & 0 deletions src/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Link } from "./graph/Link";
import { DEFAULT_LINK_STYLE, DEFAULT_NODE_STYLE, PREDEFINED_LINK_STYLES } from "./constants/constants";

export interface ExcaliBrainSettings {
compactView: boolean;
excalibrainFilepath: string;
indexUpdateInterval: number;
hierarchy: Hierarchy;
Expand Down Expand Up @@ -69,6 +70,7 @@ export interface ExcaliBrainSettings {
}

export const DEFAULT_SETTINGS: ExcaliBrainSettings = {
compactView: false,
excalibrainFilepath: "excalibrain.md",
indexUpdateInterval: 5000,
hierarchy: {
Expand Down Expand Up @@ -1564,6 +1566,17 @@ export class ExcaliBrainSettingTab extends PluginSettingTab {
text: t("DISPLAY_HEAD")
});

new Setting(containerEl)
.setName(t("COMPACT_VIEW_NAME"))
.setDesc(fragWithHTML(t("COMPACT_VIEW_DESC")))
.addToggle(toggle => toggle
.setValue(this.plugin.settings.compactView)
.onChange(value => {
this.plugin.settings.compactView = value;
this.dirty = true;
})
)

const filepathList = new Setting(containerEl)
.setName(t("EXCLUDE_PATHLIST_NAME"))
.setDesc(fragWithHTML(t("EXCLUDE_PATHLIST_DESC")))
Expand Down
2 changes: 1 addition & 1 deletion src/Suggesters/PageSuggester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class PageSuggest extends TextInputSuggest<Page> {
el.ariaLabel = page.path;
el.setText(
(page.isFolder || page.isTag)
? page.path
? page.path.replace(/^folder:/,this.plugin.settings.folderNodeStyle.prefix??"📂").replace(/^tag:/,this.plugin.settings.tagNodeStyle.prefix??"🏷️")
: page.name
);
}
Expand Down
39 changes: 31 additions & 8 deletions src/excalibrain-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,39 @@ export default class ExcaliBrain extends Plugin {
const self = this;
setTimeout(async()=>{
//@ts-ignore
const starredPlugin = app.internalPlugins.getPluginById("starred");
if(!starredPlugin) {
const bookmarksPlugin = app.internalPlugins.getPluginById("bookmarks");
if(!bookmarksPlugin) { //code to be removed when bookmarks plugin is released, only leave return
//@ts-ignore
const starredPlugin = app.internalPlugins.getPluginById("starred");
if(!starredPlugin) {
return;
}
self.starred = (await starredPlugin.loadData())
.items
.filter((i: any)=>i.type==="file")
.map((i: any)=>i.path)
.filter((p:string)=>(p!==self.settings.excalibrainFilepath) && self.pages.has(p))
.map((p:string)=>self.pages.get(p));
return;
}
self.starred = (await starredPlugin.loadData())
.items
.filter((i: any)=>i.type==="file")
.map((i: any)=>i.path)
.filter((p:string)=>(p!==self.settings.excalibrainFilepath) && self.pages.has(p))
.map((p:string)=>self.pages.get(p));
if(!bookmarksPlugin._loaded) await bookmarksPlugin.loadData();
const groupElements = (items: any[]):any[] => {
if(!items) return;
let elements = items
.filter((i: any)=>i.type==="file")
.map((i: any)=>i.path)
.filter((p:string)=>(p!==self.settings.excalibrainFilepath) && self.pages.has(p))
.map((p:string)=>self.pages.get(p));
elements = elements.concat(items
.filter((i: any)=>i.type==="folder")
.map((i: any)=>i.path)
.filter((p:string)=>(p!==self.settings.excalibrainFilepath) && self.pages.has(`folder:${p}`))
.map((p:string)=>self.pages.get(`folder:${p}`)));
items.filter((i: any)=>i.type==="group").forEach((g: any)=>
elements = elements.concat(groupElements(g.items)));
return elements;
}
self.starred = groupElements(bookmarksPlugin.instance.items);
})
}

Expand Down
2 changes: 2 additions & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export default {
BOLD_FIELDS_NAME: "Add selected field with BOLD",
BOLD_FIELDS_DESC: "Add selected field to text with bold typeface, i.e. (**field name**:: ) resulting in (<b>field name</b>:: )",
DISPLAY_HEAD: "Display",
COMPACT_VIEW_NAME: "Compact view",
COMPACT_VIEW_DESC: "Display the graph in a compact view",
EXCLUDE_PATHLIST_NAME: "Filepaths to exclude",
EXCLUDE_PATHLIST_DESC: "Enter comma-separated list of filepaths to exclude from the index.",
RENDERALIAS_NAME: "Display alias if available",
Expand Down
3 changes: 2 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
z-index: 1;
position: absolute;
bottom: 0px;
padding-left: 10px;
padding-left: 7rem;
padding-bottom: 10px;
width: 100%;
padding-right: 10px;
overflow: hidden;
Expand Down

0 comments on commit 87c7910

Please sign in to comment.