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

feat: print spectra #2786

Merged
merged 15 commits into from
Jul 19, 2024
Merged

feat: print spectra #2786

merged 15 commits into from
Jul 19, 2024

Conversation

hamed-musallam
Copy link
Member

Copy link

cloudflare-workers-and-pages bot commented Dec 4, 2023

Deploying nmrium with  Cloudflare Pages  Cloudflare Pages

Latest commit: d408ec4
Status: ✅  Deploy successful!
Preview URL: https://c448f1bc.nmrium.pages.dev
Branch Preview URL: https://print-spectra.nmrium.pages.dev

View logs

Copy link

codecov bot commented Dec 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (840c3e5) 53.42% compared to head (48eaf2d) 53.42%.

❗ Current head 48eaf2d differs from pull request most recent head 0073612. Consider uploading reports for the commit 0073612 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2786   +/-   ##
=======================================
  Coverage   53.42%   53.42%           
=======================================
  Files          52       52           
  Lines        2456     2456           
  Branches       95       95           
=======================================
  Hits         1312     1312           
  Misses       1143     1143           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hamed-musallam hamed-musallam linked an issue Dec 4, 2023 that may be closed by this pull request
@lpatiny
Copy link
Member

lpatiny commented Jul 5, 2024

@hamed-musallam

Could you finalize this PR ?

The goal is that when you print from the browser fill either an A4, B4, Letter (?) page depending of your general preferences.

It could be related to: https://stackoverflow.com/questions/16649943/css-to-set-a4-paper-size

Currently we have in the bottom the grey banner that should not be present and some green edit buttons on the top.

The size is also not setup automatically and it currently depends on the size of your browser window.

image

@lpatiny
Copy link
Member

lpatiny commented Jul 9, 2024

We have currently 3 zones that should not be displayed

  • the outline of the molecule
  • 2 grey squares in the bottom
image

We after to find out how the NMRium div can be resized to either A4 or letter before printing.

Paper size (in mm) could be defined in the General Preferences using one of those options:

  • A4: 297 x 210
  • A3: 420 x 297
  • Letter: 279 x 216
  • Tabloid: 432 x 279

I guess we will need some padding depending the printers.

In CSS size can be specified in mm

@lpatiny
Copy link
Member

lpatiny commented Jul 10, 2024

Google docs offers similar feature but in our case it will always be landscape:
image

@hamed-musallam hamed-musallam force-pushed the print-spectra branch 3 times, most recently from 489c4cb to 33d5535 Compare July 10, 2024 16:57
@lpatiny
Copy link
Member

lpatiny commented Jul 11, 2024

Looks great, thanks !

Couple of little points:

I found out that the place we put the delta(ppm) is different in 1D and 2D.

1D it is in the grey banner in the bottom:
image

2D it is over this grey banner
image

This has as consequence than when printing currently we need to display this banner and for 2D it appears like an empty grey banner:

image

2 possibilities:

  • for 1D we move the d(ppm) over the grey bottom banner and this banner is hidden when printing
  • for 2D we move the d(ppm) in the grey zone and when we print the grey banner becomes white

I would go for the first possibility even if we loose a little bit of space for the spectrum.

The second issue is how the size of the paper is expected to be decided ? I didn't see in the code the selection of the paper size and if I change to A3 for example the spectrum would not enlarge:

2024-07-11 06 56 11

On firefox there are also 2 pages rather than one:

image

Did you know that you can emulate the @media: print from the developer tools?
SHIFT + CMD + P and then look for media. You can then inspect the dom of the page as it would be rendered for priting.

image

When I do this, we have the panels on the right and a grey zone at the bottom:

image

If you need a new feature to hide the panels when printing (from react-science), do not hesitate to ask us.

@lpatiny
Copy link
Member

lpatiny commented Jul 11, 2024

@targos Hamed wrote me:

I'm thinking, Instead of hiding the panels, toolbars, and header, and change the structure we can check whether it's possible to inject the viewer into an iframe and print from there. This needs to be investigated

You was speaking to me about some features of react that allows to copy dom possibly in another window. Could you detail a little bit this idea ?

@targos
Copy link
Member

targos commented Jul 11, 2024

My idea is really abstract for now. I don't know how to do it (the React feature is createPortal)

@hamed-musallam hamed-musallam force-pushed the print-spectra branch 2 times, most recently from 067c82a to b2b6bc8 Compare July 16, 2024 09:55
@lpatiny
Copy link
Member

lpatiny commented Jul 16, 2024

Would using https://stackoverflow.com/questions/1234008/detecting-browser-print-event help in order to catch the 'File -> print' event ?

@lpatiny
Copy link
Member

lpatiny commented Jul 16, 2024

In seems also that when you cancel the print dialog box there is no resize and we stay with the zoomed layout.

2024-07-16 12 29 48

@lpatiny
Copy link
Member

lpatiny commented Jul 16, 2024

Dialog box is really a great idea ! Could you save this information in the workspace as well so that it remembers the choice ? I don't think it is the case currently.

@hamed-musallam
Copy link
Member Author

it still not, We should save them within the workspace. Should we store them at the top level as follows?

{
  printPageOptions: {
    layout: 'portrait',
    size: 'A4',
    padding: '0cm'
  }
}

Or should they be included under the 'general' section in the 'General' tab of the general settings?

@lpatiny
Copy link
Member

lpatiny commented Jul 16, 2024

As long as we always present the print dialog we don't need to add it in the general preferences but this could evolve in the future. It could become part of the general settings and be editable there as well.

@hamed-musallam hamed-musallam force-pushed the print-spectra branch 3 times, most recently from b136045 to 65d3477 Compare July 17, 2024 10:44
Copy link
Member

@lpatiny lpatiny left a comment

Choose a reason for hiding this comment

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

Functionalities looks good to me.

@hamed-musallam hamed-musallam force-pushed the print-spectra branch 3 times, most recently from aea04bc to d13edc9 Compare July 18, 2024 09:59
@hamed-musallam
Copy link
Member Author

@lpatiny

can you test again on Firefox, Chrome, and Safari

@hamed-musallam hamed-musallam merged commit 1287bc1 into main Jul 19, 2024
11 checks passed
@hamed-musallam hamed-musallam deleted the print-spectra branch July 19, 2024 11:11
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.

Printing spectrum
3 participants