MamoruDS / obsidian-open-link-with

Open external link with specific brower in Obsidian

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Only works in preview

svallory opened this issue · comments

Hi, thanks for the cool plugin!

I noticed that clicking on links in edit mode does not open them in the selected browser

I'm using the latest version of Obsidian on a Mac

Hi, sorry for the late reply to you.

This plugin currently only works in preview mode, and I agree that it needs to work in edit mode as well. But after some attempts, I found it kinda different. In my attempts, the web page opens in both the default browser and the browser configured in the plugin simultaneously after clicking(with modifier key) on the link.

The principle behind this is that the link in edit mode is actually not a hyperlink, obsidian using inner function to handle the click event, which is unable to be hijacked(or disabled) by the plugin. So this function can be implemented, but in a broken way. The alternative solution is to use a different modifier (alt or shift) to start the click event, but this can feel strange and cause potential conflict problems.

Anyway, I will add the modifier method as an optional configuration to the plugin, at least it's better than not having it at all.

No worries, @MamoruDS!

I would suggest leaving it as is for now and opening an issue in Obsidian regarding this. Maybe they can add a hook to the click action you can intercept.

I think the most important thing is to make this behavior obvious by describing it in the begging of the documentation so people installing the plugin knows right away ;)

By upgrading the plugin to version 0.1.4, the browser's override behavior will work properly in edit mode.

@MamoruDS
With the version 0.1.5, this plugin seems that still only works in preview mode, and it even prevents opening links in edit mode(live preview), which is not as expected.
图片
图片
Could you help to check that? Not sure if it is a personal problem. BTW, thanks for building this cool plugin.
My current workaround is to activate this plugin when needing to open a link in a specific browser, then deactivate it. So it would be pretty handy if there is a command which can be assigned a shortcut to toggle this plugin on/off.

@MamoruDS
Thanks for your plugins!
Same problem that could not opening links in edit mode(live preview), but I solved it by adding some code based on your main.js code.
I just learned js, maybe there are some bugs. Share with you @XMB-7. you can try it!
image
image

Still doesn't work in the preview mode.
Version 0.1.8.

Hi,
I confirm clicking on links directly has no effect in live preview. However, I noticed that unwrapping the link (with Alt + Click) to show the URL and clicking on the URL does open it, whereas it should not (at least, it does not without the plugin). I'm really no JS specialist, but maybe the event is captured at the wrong moment or something ?...
Thanks for the plugin anyway !

I believe I have a solution to this issue. The root cause of this problem is my insufficient study of Obsidian click actions, from my testing, Obsidian's click actions can be summarized in the following table:

Ctrl Alt Shift Edit Edit (live preview) Read
cursor open open
🖱️ open open (new panel) open (new panel)
🖱️ cursor cursor open
🖱️ cursor cursor open
🖱️ 🖱️ open (new split) open (new split) open (new split)
🖱️ 🖱️ open (new panel) open (new panel) open (new panel)
🖱️ 🖱️ cursor cursor open
🖱️ 🖱️ 🖱️ open (new window) open (new window) open (new window)

The appropriate implementation should follow Obsidian's default click behaviors, I will give a quick fix on this

Hey, I just released version 0.1.9 of this plugin which should fix the issue of links not working in live preview mode. And also, if you're using an in-app view as your link opener, all modifiers (combinations) should now work like in Obsidian's default. But keep in mind that, since the plugin's current setting only support one modifier binding and modifiers can be combined in different ways, I'll make it more flexible in the future version. Also, some custom modifier bindings won't work in this version since they are used for cursor move/selection which are treated as non-clickable. Please let me know if there are any other issues

Fix confirmed, thanks for the great work!

It works great indeed, thanks a lot !