patleeman / obsidian-open-in-new-tab

MIT License
94 stars 8 forks source link

Support Outgoing Links #1

Closed chenmaoran closed 1 year ago

chenmaoran commented 1 year ago

This plugin works perfectly in File Explorer. It would be nice if it supported opening Outgoing Links, hopefully it will.

patleeman commented 1 year ago

I responded in the thread but its probably better to have this discussion here.

Are you referring to the functionality similar to what obsidian-no-dupe-leaves provides?

Like when you click a link in the editor?

patleeman commented 1 year ago

One of the issues with no-dupe-leaves is that it monkey patches a core component of obsidian which I think will be frowned upon. I'll need to see if there is a different way to hook into the behavior.

chenmaoran commented 1 year ago

I have installed the "obsidian-no-dupe-leaves" plugin, but when I click Outing Links in preview mode, it still replaces the current tab instead of opening it in a new tab.

patleeman commented 1 year ago

So the idea is that when you click on a backlink inside a note, it should open in a new tab?

chenmaoran commented 1 year ago

Yes!

patleeman commented 1 year ago

Okay, let me try to hack on this when I get time.

chenmaoran commented 1 year ago

Appreciate~

patleeman commented 1 year ago

@chenmaoran Released 1.0.5. You an update in BRAT42

willasm commented 1 year ago

Almost perfect now, only one problem. Links to headers in the same page also open in a new tab. That makes my table of contents not function as intended. Still better overall than the default behavior.

patleeman commented 1 year ago

Thanks for the report @willasm!

Do you have an example page you could provide so i can test it?

willasm commented 1 year ago

Sure, try this.

# Table of contents
[[#Header 1]]
[[#Header 2]]
[[#Header 3]]

## Header 1

## Header 2

## Header 3

The links still go to the correct header, but open in another tab with a copy of the same file. In this case ideally you do want to stay on the same page.

patleeman commented 1 year ago

I appreciate the help! Let me dig in.

patleeman commented 1 year ago

@willasm can you give 1.0.6 a try? It should fix the behavior around headings and blocks

willasm commented 1 year ago

That fixed the example I gave you but I noticed one other method that does not work. Here is a sample...


# Table of contents 1
[[#Header 1]]
[[#Header 2]]
[[#Header 3|Alternate Name]]

# Table of contents 2
[[LinkDemo#Header 1]]
[[LinkDemo#Header 2]]
[[LinkDemo#Header 3]]

## Header 1

## Header 2

## Header 3

The first table of contents does work, but the second example does not. The only difference is the filename before the hashtag. In this case the filename is the current file which is a valid method of entering the link. If the filename is another note, it does open the other note in a new tab but does not jump to the header.

I guess I could change my TOC template to just use the first method, but I suspect eventually someone else will notice this and bring this up.

At any rate, great stuff and thank you very much for this.

patleeman commented 1 year ago

Let me take a look and try to fix it! Thanks for helping me debug it!

patleeman commented 1 year ago

@willasm 1.0.7 should fix the issue!

willasm commented 1 year ago

Wow that was quick! Yes that fixed it when the filename is the current file. However, if the filename links to another file it correctly opens that note in a new tab if not already open otherwise it uses an existing tab if it is present, but it does not jump to the header in the link.

I hope that I explained that clear enough? Here is an example..

[[CurrentFilename#Header 1]] This works!

[[SomeOtherFilename#Header 1]] This works but does not jump to Header 1

Thanks again!!

willasm commented 1 year ago

That is amazing! v1.0.8 is working perfectly. I have not been able to find any other odd case scenarios in my testing. This one's working perfectly for me.

Thanks again 👍

patleeman commented 1 year ago

I actually found a weird case with backlinks in folders. 1.0.9 should fix it.

Thanks for helping me debug this @willasm!