Skip to content
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

Feature Request: Better navigation for large brews #1756

Closed
RealPendragon opened this issue Oct 16, 2021 · 11 comments · Fixed by #2162
Closed

Feature Request: Better navigation for large brews #1756

RealPendragon opened this issue Oct 16, 2021 · 11 comments · Fixed by #2162

Comments

@RealPendragon
Copy link

If you have a brew with a lot of pages it's easy to lose track, what would help a lot would be a way to jump to certain places easily. Some possible ways would be:

  • Having a page display like [ 5 / 31 ] like most PDF readers where you can change the first number to jump to the specified rendered page.
  • Being able to click on the rendered headers to jump to the place where they are in the code.
  • Having a mini ToC or book mark toggle that let's you jump to headers in both code and rendered version of the brew.

But anything that makes navigation easier would be appreciated. Maybe even a way to cascade pages to hide them temporarily in the code.

@snctfd
Copy link

snctfd commented Oct 29, 2021

I agree that this would be an excellent addition, as it is a feature that most TeX and Markdown editors have already, e.g. Overleaf, TeXstudio, etc. I certainly noticed that it was missing as soon as my document got larger than a single page.

@lucastucious
Copy link
Contributor

lucastucious commented Nov 10, 2021

Is a Search/Replace tool in editor something considered as "better navigation" or it need its own ticket ?

@calculuschild
Copy link
Member

@lucastucious You can make a separate ticket if you want.

@G-Ambatte
Copy link
Collaborator

Find/Replace already exists as an issue in #1201. @jeddai has made some progress on this recently, hopefully it will reach testing/implementation/release phases soon.

@G-Ambatte
Copy link
Collaborator

I came up with these notes while between other projects today, recording them here for inclusion in a later PR.


Moving the brew preview programmatically:

  1. Add the id 'BrewRenderer' to the brew rendering iFrame.
  2. Move the brew in the iFrame: document.getElementById('BrewRenderer').src='#pX' where X is the page number to move to
  3. Update the brew URL: window.location.hash='pX'

Moving the source code programmatically:

  1. In the CodeMirror document, call setCursor({line, 1}) to move to the first character of the selected line.

@calculuschild
Copy link
Member

See also #241

@ericscheid
Copy link
Collaborator

  1. Update the brew URL: window.location.hash='pX'

This won't scroll the preview pane because the preview pane is an <iframe>

You might be able to element.ScrollIntoView(true) instead.
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

@G-Ambatte
Copy link
Collaborator

G-Ambatte commented May 3, 2022

Step 2 moves the Brew, step 3 updates the URL so a refresh will bring the user back to the same position. But scrollIntoView might be a better alternative than the sudden jump of .src='#pX'

@ericscheid
Copy link
Collaborator

Step 2 moves the Brew, step 3 updates the URL so a refresh will bring the user back to the same position.

Ah, of course. Yep, step 2 will work.

You'll also need a step 4 that gets window.location.hash on page load and then does that step 2.

@G-Ambatte
Copy link
Collaborator

Ah right, of course that's not working. Should probably either drop that step then, or implement it.

@G-Ambatte
Copy link
Collaborator

window.frames['BrewRenderer'].contentDocument.getElementById('pX').scrollIntoView({behaviour: 'auto', block: 'start'});

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 a pull request may close this issue.

6 participants