diff --git a/manifest.json b/manifest.json index 2e24158..25b9efb 100644 --- a/manifest.json +++ b/manifest.json @@ -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", diff --git a/package-lock.json b/package-lock.json index 9279ca3..c3e2d21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@popperjs/core": "^2.11.6", - "obsidian-dataview": "^0.5.51" + "obsidian-dataview": "^0.5.55" }, "devDependencies": { "@babel/core": "^7.20.2", @@ -27,7 +27,7 @@ "cross-env": "^7.0.3", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.2.1", - "obsidian": "^0.16.3", + "obsidian": "^1.1.1", "obsidian-excalidraw-plugin": "1.7.11", "prettier": "^2.8.0", "rollup": "^2.79.1", @@ -12065,9 +12065,9 @@ } }, "node_modules/luxon": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-2.4.0.tgz", - "integrity": "sha512-w+NAwWOUL5hO0SgwOHsMBAmZ15SoknmQXhSO0hIbJCAmPKSsGeK8MlmhYh2w6Iib38IxN2M+/ooXWLbeis7GuA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.3.0.tgz", + "integrity": "sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==", "engines": { "node": ">=12" } @@ -12624,9 +12624,9 @@ } }, "node_modules/obsidian": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-0.16.3.tgz", - "integrity": "sha512-hal9qk1A0GMhHSeLr2/+o3OpLmImiP+Y+sx2ewP13ds76KXsziG96n+IPFT0mSkup1zSwhEu+DeRhmbcyCCXWw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.1.1.tgz", + "integrity": "sha512-GcxhsHNkPEkwHEjeyitfYNBcQuYGeAHFs1pEpZIv0CnzSfui8p8bPLm2YKLgcg20B764770B1sYGtxCvk9ptxg==", "dev": true, "dependencies": { "@types/codemirror": "0.0.108", @@ -12702,16 +12702,16 @@ "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==" }, "node_modules/obsidian-dataview": { - "version": "0.5.51", - "resolved": "https://registry.npmjs.org/obsidian-dataview/-/obsidian-dataview-0.5.51.tgz", - "integrity": "sha512-DXf+CdsWdBBVIIVJjhFE1V3voWjIp5I6ZT5KrU20fMMMbOw9DBRA6UvPFNaGVvXKfTgmrvxbR8Xx05mhnKTu0g==", + "version": "0.5.55", + "resolved": "https://registry.npmjs.org/obsidian-dataview/-/obsidian-dataview-0.5.55.tgz", + "integrity": "sha512-t52I2ebvO6gCUakfJvuQb7qbNx0yKTdfJJAlJvyyj8+DliwM5wZXFMEio+YVLlXMyRSw2ZGq8eGp19anEIuDbg==", "dependencies": { "@codemirror/language": "git+https://github.com/lishid/cm-language.git", "@codemirror/state": "^6.0.1", "@codemirror/view": "^6.0.1", "emoji-regex": "^10.0.0", "localforage": "^1.10.0", - "luxon": "^2.4.0", + "luxon": "^3.2.0", "obsidian-calendar-ui": "^0.3.12", "papaparse": "^5.3.1", "parsimmon": "^1.18.0", @@ -26833,9 +26833,9 @@ } }, "luxon": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-2.4.0.tgz", - "integrity": "sha512-w+NAwWOUL5hO0SgwOHsMBAmZ15SoknmQXhSO0hIbJCAmPKSsGeK8MlmhYh2w6Iib38IxN2M+/ooXWLbeis7GuA==" + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.3.0.tgz", + "integrity": "sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==" }, "lz-string": { "version": "1.4.4", @@ -27244,9 +27244,9 @@ } }, "obsidian": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-0.16.3.tgz", - "integrity": "sha512-hal9qk1A0GMhHSeLr2/+o3OpLmImiP+Y+sx2ewP13ds76KXsziG96n+IPFT0mSkup1zSwhEu+DeRhmbcyCCXWw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.1.1.tgz", + "integrity": "sha512-GcxhsHNkPEkwHEjeyitfYNBcQuYGeAHFs1pEpZIv0CnzSfui8p8bPLm2YKLgcg20B764770B1sYGtxCvk9ptxg==", "dev": true, "requires": { "@types/codemirror": "0.0.108", @@ -27326,16 +27326,16 @@ } }, "obsidian-dataview": { - "version": "0.5.51", - "resolved": "https://registry.npmjs.org/obsidian-dataview/-/obsidian-dataview-0.5.51.tgz", - "integrity": "sha512-DXf+CdsWdBBVIIVJjhFE1V3voWjIp5I6ZT5KrU20fMMMbOw9DBRA6UvPFNaGVvXKfTgmrvxbR8Xx05mhnKTu0g==", + "version": "0.5.55", + "resolved": "https://registry.npmjs.org/obsidian-dataview/-/obsidian-dataview-0.5.55.tgz", + "integrity": "sha512-t52I2ebvO6gCUakfJvuQb7qbNx0yKTdfJJAlJvyyj8+DliwM5wZXFMEio+YVLlXMyRSw2ZGq8eGp19anEIuDbg==", "requires": { "@codemirror/language": "git+https://github.com/lishid/cm-language.git", "@codemirror/state": "^6.0.1", "@codemirror/view": "^6.0.1", "emoji-regex": "^10.0.0", "localforage": "^1.10.0", - "luxon": "^2.4.0", + "luxon": "^3.2.0", "obsidian-calendar-ui": "^0.3.12", "papaparse": "^5.3.1", "parsimmon": "^1.18.0", diff --git a/package.json b/package.json index afe96fd..0b7ae23 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "author": "", "license": "MIT", "dependencies": { - "obsidian-dataview": "^0.5.51", + "obsidian-dataview": "^0.5.55", "@popperjs/core": "^2.11.6" }, "devDependencies": { @@ -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", diff --git a/rollup.config.js b/rollup.config.js index 2792a76..06289ff 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -14,7 +14,7 @@ export default { output: { dir: '.', entryFileNames: 'main.js', - sourcemap: 'inline', + sourcemap: isProd?false:'inline', format: 'cjs', exports: 'default', }, diff --git a/src/Scene.ts b/src/Scene.ts index 0f1e72b..98e5b26 100644 --- a/src/Scene.ts +++ b/src/Scene.ts @@ -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 = () => { @@ -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({ diff --git a/src/Settings.ts b/src/Settings.ts index a33d881..c78fced 100644 --- a/src/Settings.ts +++ b/src/Settings.ts @@ -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; @@ -69,6 +70,7 @@ export interface ExcaliBrainSettings { } export const DEFAULT_SETTINGS: ExcaliBrainSettings = { + compactView: false, excalibrainFilepath: "excalibrain.md", indexUpdateInterval: 5000, hierarchy: { @@ -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"))) diff --git a/src/Suggesters/PageSuggester.ts b/src/Suggesters/PageSuggester.ts index a9f8476..f8415c5 100644 --- a/src/Suggesters/PageSuggester.ts +++ b/src/Suggesters/PageSuggester.ts @@ -79,7 +79,7 @@ export class PageSuggest extends TextInputSuggest { 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 ); } diff --git a/src/excalibrain-main.ts b/src/excalibrain-main.ts index 291c42b..25b9746 100644 --- a/src/excalibrain-main.ts +++ b/src/excalibrain-main.ts @@ -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); }) } diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index ded9a1d..05c8006 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -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 (field name:: )", 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", diff --git a/styles.css b/styles.css index aa18901..4f3acdb 100644 --- a/styles.css +++ b/styles.css @@ -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;