Skip to content

Commit

Permalink
0.1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
zsviczian committed Aug 29, 2022
1 parent 59151c4 commit 4402447
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 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.10",
"version": "0.1.11",
"minAppVersion": "0.15.6",
"description": "A clean, intuitive and editable graph view for Obsidian",
"author": "Zsolt Viczian",
Expand Down
20 changes: 14 additions & 6 deletions src/Scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export class Scene {
ea.addElementsToView();
}
const frame3 = () => {
api.zoomToFit(null, 5, 0.15);
if(this.plugin.settings.allowAutozoom) api.zoomToFit(null, 5, 0.15);
ea.targetView.linksAlwaysOpenInANewPane = true;
this.addEventHandler();
this.historyPanel = new HistoryPanel((this.leaf.view as TextFileView).contentEl,this.plugin);
Expand Down Expand Up @@ -550,19 +550,19 @@ export class Scene {
})

ea.getExcalidrawAPI().updateScene({appState: {viewBackgroundColor: this.plugin.settings.backgroundColor}});
ea.getExcalidrawAPI().zoomToFit(null,5,0.15);
if(this.plugin.settings.allowAutozoom) ea.getExcalidrawAPI().zoomToFit(null,5,0.15);

/**REACT 18
ea.targetView.ownerWindow.requestAnimationFrame(()=>{
ea.getExcalidrawAPI().updateScene({appState: {viewBackgroundColor: this.plugin.settings.backgroundColor}});
ea.targetView.ownerWindow.requestAnimationFrame(()=>{
ea.getExcalidrawAPI().zoomToFit(null,5,0.15);
if(this.plugin.settings.allowAutozoom) ea.getExcalidrawAPI().zoomToFit(null,5,0.15);
});
});
*/

this.toolsPanel.rerender();
if(this.focusSearchAfterInitiation) {
if(this.focusSearchAfterInitiation && this.plugin.settings.allowAutofocuOnSearch) {
this.toolsPanel.searchElement.focus();
this.focusSearchAfterInitiation = false;
}
Expand Down Expand Up @@ -615,7 +615,7 @@ export class Scene {
}
if(this.zoomToFitOnNextBrainLeafActivate) {
this.zoomToFitOnNextBrainLeafActivate = false;
self.ea.getExcalidrawAPI().zoomToFit(null, 5, 0.15);
if(self.plugin.settings.allowAutozoom) self.ea.getExcalidrawAPI().zoomToFit(null, 5, 0.15);
}
self.blockUpdateTimer = false;
return;
Expand Down Expand Up @@ -667,8 +667,16 @@ export class Scene {

await this.plugin.createIndex(); //temporary

let leafToOpen = leaves[0];
if(leaves.length>0) {
brainEventHandler(leaves[0]);
const lastFilePath = app.workspace.getLastOpenFiles()[0];
if(lastFilePath && lastFilePath !== "") {
const leaf = leaves.filter(l=>(l.view as FileView)?.file.path === lastFilePath);
if(leaf.length>0) {
leafToOpen = leaf[0];
}
}
brainEventHandler(leafToOpen);
}
}

Expand Down
28 changes: 27 additions & 1 deletion src/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export interface ExcaliBrainSettings {
ontologySuggesterTrigger: string;
ontologySuggesterMidSentenceTrigger: string;
boldFields: boolean;
allowAutozoom: boolean;
allowAutofocuOnSearch: boolean;
}

export const DEFAULT_SETTINGS: ExcaliBrainSettings = {
Expand Down Expand Up @@ -148,6 +150,8 @@ export const DEFAULT_SETTINGS: ExcaliBrainSettings = {
ontologySuggesterTrigger: ":::",
ontologySuggesterMidSentenceTrigger: "(",
boldFields: false,
allowAutozoom: true,
allowAutofocuOnSearch: true,
};

const HIDE_DISABLED_STYLE = "excalibrain-hide-disabled";
Expand Down Expand Up @@ -1675,7 +1679,29 @@ export class ExcaliBrainSettingTab extends PluginSettingTab {
this.plugin.settings.showNeighborCount = value;
this.dirty = true;
}))


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

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

containerEl.createEl("h1", {
cls: "excalibrain-settings-h1",
text: t("STYLE_HEAD")
Expand Down
4 changes: 4 additions & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export default {
"<b>Toggle off:</b> will display the current section of the tag, e.g. assuming the tag above, the graph will display only #reading, #books, #sci-fi respectively as you navigate the tag hierarchy.",
SHOW_COUNT_NAME: "Display neighbor count",
SHOW_COUNT_DESC: "Show the number of children, parents, friends next to the node gate",
ALLOW_AUTOZOOM_NAME: "Autozoom",
ALLOW_AUTOZOOM_DESC: "<b>Toggle ON:</b> Allow autozoom<br><b>Toggle OFF:</b> Disable autozoom",
ALLOW_AUTOFOCUS_ON_SEARCH_NAME: "Autofocus on search",
ALLOW_AUTOFOCUS_ON_SEARCH_DESC: "<b>Toggle ON:</b> Allow autofocus on Search<br><b>Toggle OFF:</b> Disable autofocus",
TAGLIST_NAME: "Formatted tags",
TAGLIST_DESC: "You can specify special formatting rules for Nodes based on tags. If multiple tags are present on the page the first matching a specification " +
"will be used. <br>Tagnames should start with <mark>#</mark> and may be incomplete. i.e. <code>#book</code> will match #books, #book/fiction, etc.<br>" +
Expand Down
8 changes: 8 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,14 @@ export default class ExcaliBrain extends Plugin {
return false;
}
}
if(this.scene?.isCentralLeafStillThere()) {
const f = app.vault.getAbstractFileByPath(path.split("#")[0]);
if(f && f instanceof TFile) {
this.scene.centralLeaf.openFile(f);
this.scene.renderGraphForPath(path);
return false;
}
}
//had to add this, because the leaf that opens the file does not get focus, thus the on leaf change
//event handler does not run
this.scene?.renderGraphForPath(path,false);
Expand Down

0 comments on commit 4402447

Please sign in to comment.