-
-
Notifications
You must be signed in to change notification settings - Fork 456
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: file exporters #1143
Open
YousefED
wants to merge
46
commits into
main
Choose a base branch
from
feature/file-exporters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feature: file exporters #1143
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the concept of Exporters to BlockNote. An Exporter is a loosely coupled, type safe way to transform documents from BlockNote-style JSON to another format (for example, .pdf and .docx).
Demo for PDF: https://blocknote-git-feature-file-exporters-typecell.vercel.app/interoperability/converting-blocks-to-pdf
Demo for Word: https://blocknote-git-feature-file-exporters-typecell.vercel.app/interoperability/converting-blocks-to-docx
Requirements
Architecture
As a reminder, the BlockNote schema consists of 3 main types:
blocks
,inline content
, andstyles
(see docs). First, exporters define a mapping for each of them. Exporters run Blocks (BlockNote JSON) through the mappings to get a new, "transformed" document.Note: Client-side vs. Server-side
In the current setup, we have chosen to make Exporters work completely client-side. This has the following benefits:
The main downside of this approach is that we'll need to write custom exporters for each file type, instead of creating 1 exporter to HTML and letting third party libraries handle the HTML -> Docx and HTML -> pdf exporting separately. However, it's likely that this approach would also run into limitations or a lot of custom HTML fiddling to make sure the "HTML -> xxx" converter works well.
Docx
The Docx exporter uses the docxJs to create .docx files
PDF
The PDF exporter uses https://react-pdf.org to create .pdf files. I've also looked at the following libraries:
TODO
The current PR is a proof of concept and produces valid pdf and docx files. Now, the main next step is to get as close as possible to the BlockNote "design" as possible for both pdf and docx. This means supporting all types of blocks, inline content, and styles and make sure things like font, font size, line height are similar to the BlockNote defaults (yet, stay customizable)TODO:
general:
Re. files, audio, video
Support for audio / video in pdf / word either doesn't exist or requires quite a bit of research (i.e.: how to embed audio / video in a word document). An "MVP" might just be to insert an icon and a link to the external file, instead of an item with preview / interactivity
pdf
DocX