Skip to content

New "bookmark" plugin allows hotkey fast-travel to specific steps#852

Merged
henrikingo merged 4 commits intoimpress:masterfrom
smucclaw:plugin-bookmark
Oct 31, 2023
Merged

New "bookmark" plugin allows hotkey fast-travel to specific steps#852
henrikingo merged 4 commits intoimpress:masterfrom
smucclaw:plugin-bookmark

Conversation

@mengwong
Copy link
Copy Markdown
Contributor

@mengwong mengwong commented Mar 5, 2023

resolves #850

mengwong added 2 commits March 5, 2023 22:25
similar to "click", we can now fast travel using hotkeys e.g. 1 2 3
@mengwong
Copy link
Copy Markdown
Contributor Author

mengwong commented Mar 5, 2023

i will make the linter happy

@janishutz
Copy link
Copy Markdown
Contributor

You still have double quotes in the code that's why it complains. Please run

npm run all

before pushing

Copy link
Copy Markdown
Contributor

@janishutz janishutz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for creating this plugin. My suggestion is to add some more in-code documentation, so it is easier for a new user to read the code and understand what happens

// window.console.log(`bookmark: recognizing hotkey ${event.code} goes to ${dest}`)
var newTarget = document.getElementById( dest[0] ); // jshint ignore:line

// Window.console.log(`bookmark: recognizing hotkey ${event.code} goes to ${dest}`)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really want to leave the debug code commented out in here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have taken it out, will push a new rev. Still working on the test failure.

div.dataset.bookmarkKeyList.split( " " ).forEach( ( k ) => {
if ( hotkeys.hasOwnProperty( k ) ) {
hotkeys[ k ].push( div.id );
} else { hotkeys[ k ] = [ div.id ]; } } ); } } );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move those closing brackets to separate lines? This makes the code more legible for beginners, imo. Also some explanation might be needed for the code here, if someone with less coding (well js, anyway) knowledge than you have reads this code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol i'm surprised the linter even let me do that … haha

I don't really think there's anything to be gained from adding a bunch of punctuation over multiple lines… my preference is to keep things as short as possible so you can see everything on one screen. They used to say "you can write Fortran in any language", now I suppose they should say "you can write Python in any language" 😺

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter is not properly configured for that. I have an issue open to talk about moving to eslint and how to configure it

@@ -18,48 +22,51 @@
* Copyright 2016-2017 Henrik Ingo (@henrikingo)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can credit yourself here as well!


If you assign the same key to multiple steps, that hotkey will cycle among them.

WARNING: It's up to you to avoid reserved hotkeys H, B, P, ?, etc.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't you just disallow the usage of those keys?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so, it would clobber the other plugins … I'll think about how to resolve the interaction effects.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok. If you want to override a reserved key, just do it.

@mengwong
Copy link
Copy Markdown
Contributor Author

mengwong commented Mar 5, 2023

You know, the weird thing that's going on, is that both my PRs, which are generally unrelated, both are failing tests in similar ways … maybe a curse is following me around

@mengwong
Copy link
Copy Markdown
Contributor Author

mengwong commented Mar 5, 2023

if I could get this to run after init, the step-N ids would be allocated, and I wouldn't have to worry about divs not having ids.

@mengwong
Copy link
Copy Markdown
Contributor Author

mengwong commented Mar 6, 2023

so, I did run npm run all before submitting the PR, and it turns out that fixing the linter errors was what led to the test failures. Everything is fine at 2c43ff3 😄

@mengwong
Copy link
Copy Markdown
Contributor Author

mengwong commented Mar 6, 2023

ah, null !== undefined

https://www.quora.com/Why-did-Tony-Hoare-the-developer-of-Android-Studio-says-The-Null-References-is-my-billion-dollar-mistake

JS is the best language EVAR

> null != undefined
false
> null !== undefined
true

@janishutz
Copy link
Copy Markdown
Contributor

Fun fact, this is actually one of my most favourite (and at the same time most hated) features of js

@mengwong
Copy link
Copy Markdown
Contributor Author

mengwong commented Mar 7, 2023

Thanks for helping me get this PR shipshape, I appreciate it. I am building an app involving this codebase and will keep an eye out for problems. If there are no problems I will follow up in a while and maybe we can have another think about integrating this into master.

@janishutz
Copy link
Copy Markdown
Contributor

Okay, great! Can you post a link to your project here, if it's open source?

@mengwong
Copy link
Copy Markdown
Contributor Author

Okay, great! Can you post a link to your project here, if it's open source?

I will … once it is more presentable … still trying to figure out a bunch of things.

@henrikingo henrikingo merged commit d0ba7ff into impress:master Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should the goto plugin support non-navigation input keys?

3 participants