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

✨(frontend) Pad to PDF #31

Merged
merged 8 commits into from
Apr 11, 2024
Merged

✨(frontend) Pad to PDF #31

merged 8 commits into from
Apr 11, 2024

Conversation

AntoLC
Copy link
Collaborator

@AntoLC AntoLC commented Apr 9, 2024

Purpose

Generate a PDF thank to the pad with a template integrated.

Proposal

  • Generate a template with the create_demo command (make demo)
  • Button Print to PDF on the front side
  • Test

Demo

scrnli_4_10_2024_4-43-24.PM.webm

Improvement

The frontend editor is in json at the base, when we want to print to pdf, we convert from json to markdown on the frontside, then from markdown to html on the back side. Each conversion make us loose some data accuracy.

We could improve that by converting directly from the frontend from json to html, the backend will just have to inject the data.

@AntoLC AntoLC added javascript Pull requests that update Javascript code frontend feature labels Apr 9, 2024
@AntoLC AntoLC self-assigned this Apr 9, 2024
@AntoLC AntoLC force-pushed the feature/frontend/print-pdf branch 6 times, most recently from bfeffa9 to cd58140 Compare April 10, 2024 18:05
To spread the data editor to different feature
of our app, we add the editor in the pad store.
It will give an easy access to the editor data.
To allow the frontend to make requests to the backend,
we need to add the frontend's origin
to the CSRF_TRUSTED_ORIGINS setting.
Add the hook useCreatePdfFromMarkdown,
it will be used to generate a pdf from a
a template and a markdown.
Feature to print the pad to pdf.

It display a button in the pad toolbar,
when clicked it will convert the pad to markdown,
send the markdown with a template to the backend
to convert it to pdf and then download the pdf.
When we converted from markdown to html,
we didn't format the html, so it was displayed
like a string in our pdf.
We now format_html the html before we generate
the pdf.
.devcontainer is used to create virtual environment
for development. It is not necessary to be
included in the git repository.
Create the create_demo command.
It creates a demo template for the backend.
We add it in the makefile bootstrap.

We force the template id, this id is the same as
used in the frontend for the moment.
When the template feature will be created in
the frontend side we will not have to force
it anymore.
Add a test to check the pdf export of the
impress app.
It intercept the download of the PDF and
read its content.
We can assert that the template is correctly
rendered, and that the pad text is present as
well.
@AntoLC AntoLC force-pushed the feature/frontend/print-pdf branch from cd58140 to 9828bf3 Compare April 10, 2024 20:06
@AntoLC AntoLC merged commit 0dc1be4 into main Apr 11, 2024
15 of 16 checks passed
@AntoLC AntoLC deleted the feature/frontend/print-pdf branch April 11, 2024 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature frontend javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant