-
Notifications
You must be signed in to change notification settings - Fork 1.7k
WIP: add support for j/k - vi-style navigation #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
You should not manipulate the DOM directly. I would add another |
For the |
@sorin-davidoi, |
If it toggles the sidebar, I think it belongs to the sidebar component. There is no harm in adding a second event listener there. |
What about j/k and potentially h/l? Can I handle them in chapterNavigation? |
Yeah, those should be fine there 👍 |
@sorin-davidoi, how should I implement going between chapters, e.g. go from 3.3 to 2.0 or 4.0? |
src/theme/book.js
Outdated
|
||
switch (e.key) { | ||
case 'F9': | ||
if (html.classList.contains("sidebar-hidden")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you extract this into a separate function (since it is the same logic as in the click
handler)? We could then just call it from the switch and the click
handler would be
sidebarToggleButton.addEventListener('click', toggleSidebar);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did.
@sorin-davidoi, how should I implement going between chapters, e.g. go from 3.3 to 2.0 or 4.0? Maybe chapters/subchapters links should have distinguishing tags, so that JS will go by first URL which has necessary tag? Don't know how to do it, left TODOs, maybe someone else will complete. |
Maybe we should focus to But it's a nice idea to have vi keys navigation. 👍 |
The vi navigation bindings for left / right (j/k) are super handy. What about focusing here only on that, since the code is already there are any objections of merging this? IMO the sidebar navigation could be handled as a follow-up PR. Any opinions? |
break; | ||
case 'l': | ||
e.preventDefault(); | ||
// TODO: add code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems that the author abandoned this PR, I created #1408 to follow up on this.
I want to add suport for h/l (vi-like), F9 (or something else)
to open/close left navigation panel.
What tags/ids of DOM elments should I manipulate to open/close side panel?