Skip to content

Commit

Permalink
hover editor, node labels, infer friends, shortcut for search
Browse files Browse the repository at this point in the history
  • Loading branch information
zsviczian committed May 28, 2022
1 parent 16a3b1b commit b7d1c5b
Show file tree
Hide file tree
Showing 14 changed files with 469 additions and 132 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"ts-multiselect": "^0.0.10"
},
"devDependencies": {
"obsidian-excalidraw-plugin": "1.6.26-10",
"obsidian-excalidraw-plugin": "1.6.33",
"@babel/core": "^7.16.12",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
Expand Down
5 changes: 4 additions & 1 deletion src/Components/ToolsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class ToolsPanel {
private wrapperDiv: HTMLDivElement;
private buttons: ToggleButton[] = [];
public linkTagFilter: LinkTagFilter;
public searchElement: HTMLInputElement;

constructor(
private contentEl: HTMLElement,
Expand Down Expand Up @@ -45,8 +46,10 @@ export class ToolsPanel {
new PageSuggest(
this.plugin.app,
inputEl,
this.plugin
this.plugin,
contentEl
);
this.searchElement = inputEl;

//-------
//Filter
Expand Down
27 changes: 16 additions & 11 deletions src/Scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ export class Scene {
private removeOnDelete: Function;
private removeOnRename: Function;
private blockUpdateTimer: boolean = false;
private toolsPanel: ToolsPanel;
public toolsPanel: ToolsPanel;
private historyPanel: HistoryPanel;
private vaultFileChanged: boolean = false;
public pinLeaf: boolean = false;

public focusSearchAfterInitiation: boolean = true;

constructor(plugin: ExcaliBrain, newLeaf: boolean, leaf?: WorkspaceLeaf) {
this.ea = plugin.EA;
this.plugin = plugin;
Expand All @@ -49,10 +50,11 @@ export class Scene {
this.links = new Links(plugin);
}

public async initialize() {
public async initialize(focusSearchAfterInitiation: boolean) {
this.focusSearchAfterInitiation = focusSearchAfterInitiation;
await this.plugin.loadSettings();
await this.initializeScene();
this.toolsPanel = new ToolsPanel((this.leaf.view as TextFileView).contentEl,this.plugin);
await this.initializeScene();
this.historyPanel = new HistoryPanel((this.leaf.view as TextFileView).contentEl,this.plugin);
}

Expand Down Expand Up @@ -207,7 +209,7 @@ export class Scene {
});
return;
}
await (leaf ?? app.workspace.getLeaf(true)).openFile(file as TFile);
await (leaf ?? app.workspace.getLeaf(true)).openFile(file as TFile);
}

public async initializeScene() {
Expand Down Expand Up @@ -256,7 +258,7 @@ export class Scene {
"under 'Links and Transclusion'.\n\n⚠ ExcaliBrain may need to wait for " +
"DataView to initialize its index.\nThis can take up to a few minutes after starting Obsidian.", {textAlign:"center"});
await ea.addElementsToView();
ea.getExcalidrawAPI().zoomToFit(null, 5, 0.1);
ea.getExcalidrawAPI().zoomToFit(null, 5, 0.15);

ea.targetView.linksAlwaysOpenInANewPane = true;

Expand Down Expand Up @@ -482,17 +484,20 @@ export class Scene {
// Render
this.ea.style.opacity = 100;
this.layouts.forEach(layout => layout.render());
const nodeElements = this.ea.getElements();
this.links.render(Array.from(this.toolsPanel.linkTagFilter.selectedLinks));

const elements = this.ea.getElements();
const linkElements = this.ea.getElements().filter(el=>!nodeElements.includes(el));
this.ea.getExcalidrawAPI().updateScene({
elements: elements.filter(
el=>el.type==="arrow"
).concat(elements.filter(el=>el.type!=="arrow"))
elements: linkElements.concat(nodeElements) //send link elements behind node elements
})
this.ea.getExcalidrawAPI().zoomToFit(null,5,0.1);
this.ea.getExcalidrawAPI().zoomToFit(null,5,0.15);

this.toolsPanel.rerender();
if(this.focusSearchAfterInitiation) {
this.toolsPanel.searchElement.focus();
this.focusSearchAfterInitiation = false;
}
this.blockUpdateTimer = false;
}

Expand Down
Loading

0 comments on commit b7d1c5b

Please sign in to comment.