-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Move the sidebar related code from viewer.js into PDFSidebar
#7038
Conversation
This looks really nice! It does need a rebase after landing a previous PR. Could you rebase it? |
…iewer.js, rename the classes, and refactor their `render` methods Changes `PDFOutlineView`/`PDFAttachmentView` to be initialized once, since we're always creating them, and refactor their `render` methods to instead pass in the `outline`/`attachments`. For consistency with other "classes", the `PDFOutlineView`/`PDFAttachmentView` are renamed to `PDFOutlineViewer`/`PDFAttachmentViewer`. Also, make sure that the outline/attachments are reset when the document is closed. Currently we keep the old ones around until the `getOutline`/`getAttachments` API calls are resolved for a new document.
The sidebar code has, except for minor fixes/additions (such as attachments), been largely untouch for years. To avoid having a bunch of sidebar code sprinkled throughout viewer.js, this patch moves the sidebar code into a separate file (pdf_sidebar.js), similar to how most other functionality has been moved in the last few years. Besides simply moving code around, this patch also has the added benefit that we now keep track of the sidebar state (not just opened/closed). This now makes it possible to handle both `Preferences` *and* `ViewHistory` settings for the sidebar state in a cleaner way, preventing strange and confusing interactions between the two.
Done, and thanks for the other reviews! |
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/241838708f3dcd3/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/241838708f3dcd3/output.txt Total script time: 0.87 mins Published |
Move the sidebar related code from viewer.js into `PDFSidebar`
Awesome work! This really is much cleaner than before. |
Thank you so much for reviewing this! |
These patches follow in the steps of many previous PRs, which moved code out of
viewer.js
and into separate classes/files. Please refer to the commit messages for more details.Besides the clean-up, this is also necessary to prevent
Preferences
/ViewHistory
from "fighting" each-other on document load, when addressing issue #6935.First of all, we currently don't track the state of the sidebar, besides open/close. Second of all, just adding a
ViewHistory
setting could lead to weird/unintuitive behaviour when both a preference and setting exists. An easy solution to the above, based on these patches, could then be e.g. https://gist.github.com/Snuffleupagus/7aa031391399962846b0.@timvandermeij Is this something that you would be willing to review?