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: odt export #1331

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Feature: odt export #1331

wants to merge 16 commits into from

Conversation

YousefED
Copy link
Collaborator

@YousefED YousefED commented Dec 18, 2024

This PR adds an ODT exporter, with support for a customizable header & footer.

Copy link

vercel bot commented Dec 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Feb 10, 2025 11:40am
blocknote-website ✅ Ready (Inspect) Visit Preview Feb 10, 2025 11:40am

Copy link
Collaborator Author

@YousefED YousefED left a comment

Choose a reason for hiding this comment

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

I've left some early comments. Besides that, I found the following with the example:

  • example exported document doesn't open in Word for Mac
  • on libreoffice, "Numbered List Item Nested funky center" doesn't have the blue font color as in the example
  • Tables always seem to be full width. Also (probably related), column width is not taken into account (see "wide cell" in testDocument.ts)
  • The images have an extra border around them, can we get rid of this?
  • the first two colored bg paragraphs have a white space between them. On docx / pdf this does not happen, and also not with the red numbered lists. Not sure if possible to fix, but would be nice
  • Could you also fix the CI build?

package.json Outdated Show resolved Hide resolved
public async toODTDocument(
blocks: Block<B, I, S>[],
options?: {
header?: string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we want to be able to use more than a string as header / footer. Can you compare with the other exporters?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed, other exporters offer more customizability by using underlying libraries.
In this case, I wasn't sure about exposing the XML/JSX syntax to the end-user - it's a bit unusual and might be confusing for some.

We can export certain elements as JSX components and allow users to use them for more customization, but it'll likely still be just a subset of what's possible;

);
const editorWidth = 623;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what kind of unit is this / where does this number come from?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Width of the BN editor in px.
I needed to somehow get a % value from previewWidth, which seems to be a px value.
Not sure how else to get it, other than by using editorWidth - let me know if you have any suggestions.

packages/xl-odt-exporter/src/odt/defaultSchema/blocks.tsx Outdated Show resolved Hide resolved
packages/xl-odt-exporter/src/odt/imageUtil.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,75 @@
import { BlockNoteSchema, defaultBlockSpecs, PageBreak } from "@blocknote/core";
import { testDocument } from "@shared/testDocument.js";
import { BlobReader, TextWriter, ZipReader } from "@zip.js/zip.js";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you mentioned admzip didn't work for you. Curious what was the exact case, but if zip.js works better, let's also move the other exporter(s) to zip.js so that the codebase remains consistent?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The only other place adm-zip is used is in DOCX exporter tests, which run server-side. Client-side, in the browser, adm-zip didn't work well. Tried to patch process to fix it (cthackers/adm-zip#529) but other Node-dependency-related issues popped up.

@areknawo
Copy link
Collaborator

areknawo commented Feb 10, 2025

example exported document doesn't open in Word for Mac

The ODT file can now be opened in Word, but there seem to be some compatibility issues.
Not sure if they are expected in Word or caused by the exporter.

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.

2 participants