Giter Club home page Giter Club logo

obsidian-jump-to-link's Introduction

Obsidian Plugin: Jump to link

Quickly navigate between links, or jump to any word on the page using hotkeys.

Jump To Link

Jump to Anywhere (RegEx based navigation)

Lightspeed

Settings

How to use (Link Navigation)

  • Open command palette (Ctrl+P), find and choose Jump to link command
  • You can use hotkey (Ctrl + ' by default)
  • If there are any links in opened file you should see letters over them which should be pressed to open the link
  • Hold Shift while pressing link letters should open note in a new pane

How to use Jump to Anywhere (Editor Navigation)

  • Use the command palette, or press the hotkey (Ctrl + ; by default) to instantly jump to any word on the page!
  • If you hold Shift while pressing the hotkey, you will select to the word you jump to.
  • Jump to Anywhere is a RegEx based navigation feature, similar to vim-easymotion.
  • Jump to Anywhere works both in regular editor mode, and in VIM mode!
  • Custom RegEx can be configured to user preference
  • Default configuration adds a label on words 3 characters or greater: [Regex: \b\w{3,}\b]
  • Suggested Characters used for link hints setting for Jump to Anywhere: asdfghhjklqwertyuiopzxcvbnm
    • These settings ensure that all 26 letters are available for jumping in documents with large amounts of text.
    • If there are more matches than available letters, the label will show undefined and it will not be possible to jump there.

How to use Lightspeed

Lightspeed is originally a vim plugin similar to vim-sneak or easymotion. See this issue for videos.

You can either assign a hotkey, or use it in combination with the Obsidian vimrc plugin:

exmap jumpToLink obcommand mrj-jump-to-link:activate-lightspeed-jump
nmap gs :jumpToLink

The idea and original code is from @kohane27.

The look of it when invoked can be modified with CSS. By default, it is:

.theme-dark, .theme-light {
  --jump-to-link-lightspeed-color: var(--text-muted);
}

Lightspeed is only supported in the new Codemirror 6 editor.

How to install the plugin

Install plugin from the Community Plugins section.

Known issues

Support

obsidian-jump-to-link's People

Contributors

jiyee avatar jsonmartin avatar kometenstaub avatar mrjackphil avatar roman-balzer avatar tadashi-aikawa avatar voidawake avatar vultix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

obsidian-jump-to-link's Issues

Link letter popups in front matter for yaml tags

The frontmatter yaml style tags get assigned a letter per tag in preview mode. However only the last letter normally is shown and then the sequential letters are hidden for each additional tag. tags: [ tag1, tag2, tag3, tag4 ] will depict "d" for all tags in the top left corner. Then the first link in the body will use "e".

In edit mode the yaml tags do not receive a tag and link letter assignment works as expected if frontmatter is not set to not be shown in "editor" options.

Reference the screenshots below

Edit Mode:
Screen Shot 2021-02-27 at 11 45 46 PM

Preview with out frontmatter
Screen Shot 2021-02-27 at 11 45 28 PM

Preview with frontmatter
Screen Shot 2021-02-27 at 11 50 04 PM

Update README.md

Based on #13 issue. I don't see what I mention some features in documentation.. Needs to be fixed.

Feature request: Add plain URLs to targets

Hi. Thank you for an amazing pluginπŸ˜„

I thought it seems to be handy that not only jump to internal/external links, but also plain URLs.
So I tried to implement it as follows.

2021-01-27_01h14_18

    getSourceLinkHints = (cmEditor: Editor): SourceLinkHint[] => {
        // expecting either [[Link]] or [[Link|Title]]
        const regExInternal = /\[\[(.+?)(\|.+?)?\]\]/g;
        // expecting [Title](link)
        const regExExternal = /\[.+?\]\((.+?)\)/g;
+       // expecting http://hogehoge or https://hogehoge
+       const regExUrl = /(?<= |\n|^)(https?:\/\/[^ \n]+)/g;

	const strs = cmEditor.getValue();

	let linksWithIndex: { index: number, type: 'internal' | 'external', linkText: string }[] = [];
	let regExResult;

	while(regExResult = regExInternal.exec(strs)) {
		const linkText = regExResult[1];
		linksWithIndex.push({ index: regExResult.index, type: 'internal', linkText });
	}
		
	while(regExResult = regExExternal.exec(strs)) {
		const linkText = regExResult[1];
		linksWithIndex.push({ index: regExResult.index, type: 'external', linkText })
	}
        
+       while(regExResult = regExUrl.exec(strs)) {
+       	const linkText = regExResult[1];
+       	linksWithIndex.push({ index: regExResult.index, type: 'external', linkText })
+       }

What do you think?

Stays active after the jump

I am having an issue where I use the plug in and then jump somwhere and even though I cannot see the links anymore, when I type a letter, it still takes me to a new page.

Jump to symbol

This would be a great expansion for this plugin.
I assume it should work similarly to the ease motion plugin for Vim.

TypeError: Cannot read property 'toUpperCase' of undefined

Hi,

I'm not able to use the plugin on Obsidian 0.12.12 running in Ubuntu 20.04.

Here's the error I'm getting when using a shortcut:

Command failed to execute:  mrj-jump-to-link:activate-jump-to-link
app.js:1 TypeError: Cannot read property 'toUpperCase' of undefined
    at JumpToLink._this.getLinkHintLetters (eval at <anonymous> (app.js:1), <anonymous>:365:51)
    at JumpToLink._this.getSourceLinkHints (eval at <anonymous> (app.js:1), <anonymous>:355:41)
    at JumpToLink._this.manageSourceLinkHints (eval at <anonymous> (app.js:1), <anonymous>:147:54)
    at Object.JumpToLink._this.handleJumpToLink [as callback] (eval at <anonymous> (app.js:1), <anonymous>:122:23)
    at bS (app.js:1)
    at e.executeCommandById (app.js:1)
    at e.onTrigger (app.js:1)
    at e.handleKey (app.js:1)
    at e.onKeyEvent (app.js:1)

And this is what is thrown if I run it through command pallette:

Uncaught TypeError: Cannot read property 'toUpperCase' of undefined
    at JumpToLink._this.getLinkHintLetters (eval at <anonymous> (app.js:1), <anonymous>:365:51)
    at JumpToLink._this.getSourceLinkHints (eval at <anonymous> (app.js:1), <anonymous>:355:41)
    at JumpToLink._this.manageSourceLinkHints (eval at <anonymous> (app.js:1), <anonymous>:147:54)
    at Object.JumpToLink._this.handleJumpToLink [as callback] (eval at <anonymous> (app.js:1), <anonymous>:122:23)
    at bS (app.js:1)
    at t.onChooseItem (app.js:1)
    at t.onChooseSuggestion (app.js:1)
    at t.selectSuggestion (app.js:1)
    at e.useSelectedItem (app.js:1)
    at Object.func (app.js:1)

Trying to use jump-to-regex functionality hangs Obsidian completely.

Plugin crashes after first run if link selection is required

Jump to link only works if there's a single link in view


When I run jump to link in an area with only 1 link in view, it works correctly unlimited times but outputs the following error to console each time:

image

And this to terminal (only once):

image


When I run jump to link in an area with >1 links in view, it shows the letter hover suggestions correctly, but outputs the error below after pressing any keys.

image

Doing key combinations on the suggestions does not result in the links being followed, but the suggestions do disappear after keypress or escape. Now, any key press whatsoever results in the error being printed again (the error number increments). The suggestions do not reappear after running the plugin through command palette.


I'm not sure if this started happening after an obsidian update or a plugin update

Obsidian 0.16.3 (insider) build
Plugins installed:
image

Not working on Pad/iOS

Do you know of any reason why this plugin won't work on iOS? Always comes up with the follwing error and I'm not too sure how to get proper error messages out in iOS.

image

Would love to use this on my iPad with the keyboard but can't work out why it crashes? Have checked it out locally and compared with some of my personal plugins and all seems OK.

Happy to make the changes myself was wondering if you knew of the reason before I start heading down rabbit holes.

Bug: `Jump to Link` does not work in Source Mode

this seems to be a very similar case to #31. While the issue has been resolved at that time, it re-occured. I deleted my app.json like a commenter described in #31, and jump to link works again.

After an hour or so of trying to reproduce what exactly causes the issue, I found what exactly causes the bug:

When in the Obsidian settings, under Editor β†’ General β†’ Default Editing Mode, I select Source Mode (while not using the Legacy Editor), and I then open a new panel, Jump to Link won't work in Source Mode anymore – but it still works in Reading Mode and Live Preview. When I set the default editor setting to Live Preview, open a new pane, and then switch to Source Mode via Command Palette, Jump to Link does work in Source Mode.

So all in all, it seems, it is not Source Mode which causes the problem, but rather initializing a new pane in Source mode. Whether a pane which was not initialized in Source mode is later switched to Source Mode seems to be irrelevant for this bug.


My current workaround is to use the Force View Mode Plugin, which forces source mode even though Live Preview is my default editor mode, because it hasn't been updated since the introduction of live preview. So basically, my workaround only works by abusing the bug of an outdated other plugin. (lol)


This is the log I get when the command fails to work in Source Mode:

Command failed to execute:  mrj-jump-to-link:activate-jump-to-link
app.js:1 TypeError: cmEditor.coordsChar is not a function
    at getVisibleLineText (eval at <anonymous> (app.js:1:1494667), <anonymous>:47:37)
    at SourceLinkProcessor.getSourceLinkHints (eval at <anonymous> (app.js:1:1494667), <anonymous>:308:41)
    at SourceLinkProcessor.init (eval at <anonymous> (app.js:1:1494667), <anonymous>:316:32)
    at JumpToLink.handleJumpToLink (eval at <anonymous> (app.js:1:1494667), <anonymous>:430:88)
    at JumpToLink.action (eval at <anonymous> (app.js:1:1494667), <anonymous>:568:22)
    at Mz (app.js:1:1618036)
    at e.executeCommandById (app.js:1:1619289)
    at eval (eval at <anonymous> (app.js:1:1494667), <anonymous>:74:11954)
    at e.o [as executeCommandById] (eval at <anonymous> (app.js:1:1494667), <anonymous>:23:77227)
    at e.onTrigger (app.js:1:1158645)

Lightspeed jump: restrict to current line and auto jump

Thanks for this handy plugin! I have a small FR. Can I jump to a word on the current line? Now, it searches through the entire note, but sometimes you just want to jump to somewhere on the line.

Also, when there is only one candidate location, can it auto-jump to it? I think this will further increase the efficiency :)

Popover remains when navigating by clicking.

In popover mode, when I hit the hotkey, the popovers appear.
When I then click on a link with the mouse, the popovers remain in place and cover up the new page - until I hit a key on the keyboard.

Doesn't work with Live Preview

Hi, I cannot seem to get this plugin working with live preview. Is this something that will be worked on? It would be amazing to use jump to link and jump anywhere in the WYSIWYG editor.

Jump to anywhere isn't working

I tried this feature both as a keyboard shortcut and from command palette.

I'm on mac os and obsidian version is 0.12.4

Not sure what I missed here

Support custom URI Schemes

Currently, my notes have links like this which are currently not handled by your plugin (even though http/https links work fine)

Created [LI-37](youtrack://issue/LI-37) to track this effort.

Trying to jump to the link above returns this error message toast.

image

[Feature request] Lightspeed.nvim-similar execution for "Jump to Anywhere"

Hello mrjackphil! Thank you for creating such an awesome plugin! It provides an even more fluent Vim experience.

Introduction

In short, Lightspeed.nvim is a motion plugin very similar to vim-easymotion. The reason for a Lightspeed-similar execution is to remove much visual clutter.

With the current "Jump to Anywhere" implementation, if I want to, say, jump to consectetur, this is the screen after triggering activate-jump-to-anywhere:

screenshot-2022-03-31-19-53-56

This is the screen for Lightspeed-simliar implementation:
screenshot-2022-03-31-19-54-23

Current implementation:

Trigger activate-jump-to-anywhere -> all words are parsed for tags -> press the two keys on tag to jump to desired word

Lightspeed-similar implementation:

Trigger activate-jump-to-anywhere -> press first two characters of desired word -> provides tags that matches jumpToAnywhereRegex for jump

Having trouble implementing

I've looked into handleJumpToRegex in main.ts. The crust of the matter is that, how do I capture two extra keypress sequence after triggering activate-jump-to-anywhere?

    handleJumpToRegex = () => {
        const { app, settings: { letters } } = this
        const currentView = app.workspace.activeLeaf.view;
        const mode = this.getMode(currentView);

        ****************************************
        let capturedTwoKeys = "" // e.g., "ow"
        let twoKeysRegex = "\b" + capturedTwoKeys; // replaced `jumpToAnywhereRegex` since it needs to be generated on-the-fly when we trigger `activate-jump-to-anywhere`.
        ****************************************
        
        switch (mode) {
            case VIEW_MODE.LIVE_PREVIEW:
                const cm6Editor: EditorView = (<{ editor?: { cm: EditorView } }>currentView).editor.cm;
                const livePreviewLinks = new LivePreviewRegexProcessor(cm6Editor, letters, **twoKeysRegex**).init();
                this.markPlugin.setLinks(livePreviewLinks);
                this.app.workspace.updateOptions();
                this.handleActions(livePreviewLinks, cm6Editor);
                break;
            case VIEW_MODE.PREVIEW:
                break;
            /* OMITTED */
            default:
                break;
        }
    }

I tried adding an addEventListener: document.addEventListener('keydown', (event) => console.log(event.key));, but it's not captured in Normal mode, only in Insert mode.

I'm also confused as to where I should look for reference: obsidian.d.ts or codemirror?

Any help is much appreciated. Thank you!

Changing the hotkey or having a command

Hey,

I'm really interested in the plugin but ctrl-' is already used for me πŸ˜…
Do you plan to add a way to change the mapping?

An easy way would be to add an Obsidian Command, that we can remap easily in the Hotkeys setting. (I don't know if there is a performance difference, I wouldn't expect any).

Adding a command is quite easy: (I've hesitated to do a PR but it's not clear if I should start with master or the open PR).

this.addCommand({
			id: "jump-to-link",
			name: "Jump to link",
			callback: () => this.jumpToLink(),
			hotkeys: [],
		})
    jumpToLink() {
		let currentView: any = this.app.workspace.activeLeaf;
		let cmInst = currentView.view.sourceMode.cmEditor;

		if (!(currentView instanceof MarkdownView)) {
                    return
		}

		const urls = getUrlsFromText(cmInst);
		console.log('triggered')

		this.showJumpLetters(this.app, urls, cmInst)
  }

Allow for jumping while selecting in Vim mode

I'd love it if you could start selecting text in Vim visual mode, visual line mode, or visual block mode, trigger jump, and have your selection persist after the jump. As of now, triggering a jump command cancels your selection.

This feature would allow you to highlight specific blocks of text extremely rapidly via the keyboard.

Ability to jump to native app uri schemes in Edit Mode

Hey there,

The plugin is able to recognize links that are not https://:

image`
This seems to be for any non-standard url scheme, e.g: things:///show?id=VFh5iLZkuHkQZoTK7ib36L omnifocus://, etc

However, when triggering it via the "jump to link" hotkeys I get this error message:
image

We are able to visit these links both by clicking on them, and by using "jump to link" when in Preview Mode:
image

It is just in Edit mode that this does not seem to be working.

Thank you for the great plugin.

[BUG] Open in new pane crashes plugin

Hi,

I'm using Jump To Link 0.4.2 with latest insider build of Obsidian (0.15.2). When I try to open a link in new pane (by using hinted letter with shift) the plugin crashes. Below is the devtools console ouptut when it happens:

plugin:mrj-jump-to-link:503 Uncaught TypeError: Cannot read property 'cm' of undefined
    at removePopovers (VM132 plugin:mrj-jump-to-link:503)
    at HTMLDivElement.handleKeyDown (VM132 plugin:mrj-jump-to-link:535)
removePopovers @ plugin:mrj-jump-to-link:503
handleKeyDown @ plugin:mrj-jump-to-link:535

Link hints for preview mode

Let me start by saying this plugin is wonderful! I use Vimium every day and this is exactly what I was hoping for when the plugin API went live.

I generally prefer to navigate my notes in preview mode and this plugin only seems to work in source mode. I briefly looked into adding the functionality to get this to work in preview mode and it certainly isn't trivial as far as I can tell. Still, I wanted to create a feature request for this.

Feature Request: Jump to Dataview-rendered note links

Love this plugin for bringing Vimium-like functionality to Obsidian's preview mode. I just discovered that it doesn't recognize notes/links rendered via the Dataview, another great plugin. Is it feasible to have Jump to Link "see" rendered lists and tables and find the links within them?

Open in new pane feature request

Hi,

Thanks for the great plugin!

One feature I would love to see implemented is the option to open the new note in a new pane - This would greatly enhance navigating notes through Andy Mode and without a mouse.

Hopefully my time will free up by Christmas and I'll be able to send a PR, creating the issue just in case anyone else comes across the idea.

Vault internal Markdown links won't open

Hey, first of all: thanks for your great Plugin, I try to switch to keyboard only and links where one of the things where I still had to use the mouse.

Unfotunately it seems that it doesn't work with markdown styled internal links. The [[Wikilinks]] work perfectly and so does external markdown links like [David Hasselhoff](https://en.wikipedia.org/wiki/David_Hasselhoff) but if internal links like [David Hasselhof](../1%20Idols/Super%20Idols/David%20Hasselhoff.md) does not work and gives me the following error:

main.ts:80 Uncaught (in promise) Error: Invalid URL
at handleHotkey (eval at (app.js:1), :152:47)
at HTMLDocument.handleKeyDown (eval at (app.js:1), :187:29)
handleHotkey @ main.ts:80
handleKeyDown @ main.ts:122

The link is valid if I command+click it or at least it finds the note in this case.

Is there a is there a bug or are my links just shit?

Jump to anywhere limited

If there are too many words on the screen I only get short cuts for words on the top half and nothing for the bottom half. Is this expected and just a limitation of too many words?
image

FR: Recognise manually created links

Similarly to issue #19, it would be awesome if Jump To Link would recognise non-standard wikilinks. For example, many plugins create manual links (Dataview, Breadcrumbs). My suggestion is that your plugin would pick up any link with the .internal-link class. This would apply to all links, not just anchor links

Add Jump to Line Command

It would be very handy if there was one more command that allowed you to jump to the beginning of a specific line. As of now, you cannot navigate to any white space. Combined with the other feature request of #32, this plugin would turn obsidian into a text editing powerhouse.

Also, awesome work getting this plugin working with live preview!

Feature Request: Modifier key to open context menu

First, such a great quality of life plugin! My idea/request is to make it possible to open the context menu from the keyboard for a given link.

Currently: You can use a modifier key to open the link in a new pane rather than the existing one.

Proposed: Add an additional modifier key that opens the context menu for the given link, as though you right-clicked it.

[bug] should trim link on jump

I create link to another file and use alter display name for it.

For example:
Edit mode:
image
Preview mode:
image

I can easily open it by ctrl+click combination when i'm in editing mode and just by click in preview mode:
image

But when i use ctrl+' and type shortcut from panel, i get new created file:
image

And each time i try to open this link that way, i new file creates:
image


I use only your plugin and support for Vimrc by community (+ Vim editor by Obsidian).

[Bug] Pop-Ups Not Reliably Appearing in Live Preview

In using the jump-to-link command, the pop-up flags to trigger a link do not reliably appear on each link in Live Preview mode. They typically will appear if I invoke the jump to link command at the top of the page, but as I scroll further down the page they may not appear at all, or else they appear in places other than the currently visible portion of the note. For instance, the flags might appear on links at the top of the page rather than at whatever portion of the note that I am currently viewing.

`Jump to link` fails in Source Mode

it does nothing, and I get the following console output

app.js:1 TypeError: cmEditor.coordsChar is not a function
    at getVisibleLineText (eval at <anonymous> (app.js:1:1433712), <anonymous>:47:37)
    at SourceLinkProcessor.getSourceLinkHints (eval at <anonymous> (app.js:1:1433712), <anonymous>:308:41)
    at SourceLinkProcessor.init (eval at <anonymous> (app.js:1:1433712), <anonymous>:316:32)
    at JumpToLink.handleJumpToLink (eval at <anonymous> (app.js:1:1433712), <anonymous>:430:88)
    at JumpToLink.action (eval at <anonymous> (app.js:1:1433712), <anonymous>:569:22)
    at WR (app.js:1:1552123)
    at e.executeCommandById (app.js:1:1553368)
    at eval (eval at <anonymous> (app.js:1:1433712), <anonymous>:74:11668)
    at e.o [as executeCommandById] (eval at <anonymous> (app.js:1:1433712), <anonymous>:23:77225)
    at T.eval (eval at <anonymous> (app.js:1:1433712), <anonymous>:15:16522)

progressive filtering of locations with keystrokes

Like easy motion it would be nice to see all the links on a page using "jump to anywhere" filter based on the first keystroke.

i cant take a screen shot of it but:

if the keys pop up and they're aa to zz then if my first kestroke is e then i'd like it to then ONLY show the ea through ez tooltips because the scope of where I want to go has been narrowed.

:)

Lightspeed jump: jump to the middle of the word

Right now you can only jump to the beginning of the word with the Lightspeed jump since it's using the jump-to-anywhere logic. Is it possible to let you jump anywhere in the word with Lightspeed, like in the original nvim plugin?

Make the keys a little more home-row friendly :)

Great plugin, the only thing I would really suggest is not to use straight alphabetical, I'd rather have to type two letters than ever use z or o in the link shortcut.

Maybe focus on the home row first, then other easy to reach keys like t or n and then double up? I'm not sure if how vimium does it is available anywhere but that works pretty well?

Just a suggestion, obviously - it's already great!

Make it work on Dataview links

It does not show popovers on Dataview links.

It only works (popovers appear) on [[WikiLinks]].

Can you make the first thing happen?

How to recreate the problem:

  1. Create a note
  2. Create a WikiLink
  3. Create a Dataview table
  4. Run Jump To Link
  5. You will see that it only places the popover on the wikilink.

Tall popups on some custom themes

I'm using the minimal theme by @kepano. The popups are very tall. I'm not a js coder, but found that adding a snippet min-height:16px; to overwrite the jl.popover class bring the height down.

Should the above be added to ensure popovers are standard size between themes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.