Skip to content

Commit

Permalink
0.0.04 Sidepane keyboard+click commands standarized
Browse files Browse the repository at this point in the history
  • Loading branch information
TfT Hacker committed Sep 9, 2022
1 parent 29f03bc commit 89cc341
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ main.js
# obsidian
data.json

build
build

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
8 changes: 8 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ This plugin helps you to see the connections between the different parts of your

The basic idea is I want to see when links, block references and embeds have associations with other files in my vault. The problem is you have to search, open backlinks and such to find out what is going on. But there are so many strange new worlds of networked thought to discover in my vault. This plugin attempts to surface that information and not be to intrusive (or not too intrusive).

The Strange New Worlds plugin is abbreviated as SNW in this documentation.

# Lazy networking (linking)
I am not known to be lazy, but for this plugin I had to be. This plugin leverages the indexing Obsidian does in the background, which is amazing. However, for performance reasons some things don't update right away. So some of the numbers shown by this plugin may be off as you work with links, embeds and blocks. But eventaully they will be correct. Eventually is better than nothing, right?

# Prototype insatity
So I have invested 0 time into the presentation and formatting. So I am sorry it is ugly. But its a prototype. Let us prove the concept before adding the polish. Having said that, I left many breadcrumbs in the CSS for you to format the presentation. Consult the sytles css for the class definitions: https://github.com/TfTHacker/obsidian42-strange-new-worlds/blob/master/src/styles.css

# SNW Pane Shortcuts
When references are viewed in the right side pane, they can be clicked on to open the referenced documents. By default, they will open into the active pane. However, using a keyboard plus click combinations allow for more flexibility in how documents are opened:
+ Shift + Click - Opens reference in a vertical side pane
+ Alt + Click - Opens reference in a horizontal side pane
+ CTRL/CMD + Click - Opens reference in a new window

# odd issues
Modifying the underyling Obsidian rendering engine is not easy. It is a complex piece of software. There are some issues I have not been able to resolve, so have had to compromise. I will list such examples as they surface here:
- An embed marked to render its display that is on its own line will force the reference counter to the next line. So if you have typed on a line something like this, all by itself: `![[MyPage#header1]]` it will show any block reference counts on the following line. However if the same text is entered as: `- ![[MyPage#header1]]`, that is, with any other text, it will render the block references as by design.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian42-strange-new-worlds",
"name": "Obsidian42: Strange New Worlds",
"version": "0.0.03",
"version": "0.0.04",
"minAppVersion": "0.16.2",
"description": "Revealing networked thought and the strange new worlds created by your vault",
"author": "TfTHacker",
Expand Down
13 changes: 7 additions & 6 deletions src/sidepane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,20 @@ export class SidePaneView extends ItemView {
document.querySelectorAll('.snw-sidepane-link').forEach(el => {
el.addEventListener('click', (e: PointerEvent) => {
e.preventDefault();
console.log('hello')
const target = e.target as HTMLElement;
const filePath = target.getAttribute("data-href");
const LineNu = Number(target.getAttribute("data-line-number"));
const fileT = app.metadataCache.getFirstLinkpathDest(filePath, filePath);
console.log(e)
if(e.shiftKey)
this.thePlugin.app.workspace.getLeaf(true).openFile(fileT);
this.thePlugin.app.workspace.getLeaf("split", "vertical").openFile(fileT);
else if(e.ctrlKey || e.metaKey)
this.thePlugin.app.workspace.getLeaf("split", "horizontal").openFile(fileT) // (app.workspace.splitActiveLeaf('horizontal')).openFile(fileT);
this.thePlugin.app.workspace.getLeaf("window").openFile(fileT);
else if(e.altKey)
this.thePlugin.app.workspace.getLeaf("window").openFile(fileT) // (app.workspace.splitActiveLeaf('horizontal')).openFile(fileT);
else
this.thePlugin.app.workspace.getLeaf("split", "vertical").openFile(fileT) //(app.workspace.splitActiveLeaf('vertical')).openFile(fileT);
this.thePlugin.app.workspace.getLeaf("split", "horizontal").openFile(fileT);
else {
this.thePlugin.app.workspace.getLeaf(false).openFile(fileT);
}
if(LineNu!=0) {
setTimeout(() => {
this.thePlugin.app.workspace.activeLeaf.view.setEphemeralState({line: LineNu })
Expand Down
9 changes: 9 additions & 0 deletions todo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sidebar
- should open into current document if empty, not open new documents
- preview popup - can it position to location in document?
- embed/blocks displayed in pane should include full reference (not just the originating document) - hopefully will help with preview
- can we integrate graph view
- provide a preview of the link



1 change: 0 additions & 1 deletion todo.txt

This file was deleted.

2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"0.0.01": "0.13.8",
"0.0.03": "0.16.2"
"0.0.04": "0.16.2"
}

0 comments on commit 89cc341

Please sign in to comment.