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

Extending zip output with more sub-files #2938

Open
adamSherwoodGenieAI opened this issue Jan 16, 2025 · 2 comments
Open

Extending zip output with more sub-files #2938

adamSherwoodGenieAI opened this issue Jan 16, 2025 · 2 comments

Comments

@adamSherwoodGenieAI
Copy link

Hi @dolanmiu Thanks for this great library.

I'm just running into an issue with trying to add a commentsExtended.xml subfile to the exported zip file (for MS Word compatibility).

From what I can tell, the simplest way to make this possible would be to publicly expose the Compiler class, which is not currently part of the public api. Alternatively the compiler field on the Packer class could be made public.

In either case, it would enable user code to call Compiler.compile directly, get the returned JSZip, ad additional files to the JSZip, and finally generate the zip.

If you're open to the idea, I'm happy to open a PR to make the changes. Let me know what you think

@dolanmiu
Copy link
Owner

Hey

Prefer if it was added the same way as the rest of the other .xml files are added, so we aren't exposing any internals

@adamSherwoodGenieAI
Copy link
Author

Understood. In that case how about adding an additional argument to the Packer methods that is typed as IXmlifyedFile[]? That array can then be passed to Compiler.compile as an additional argument.

public static async toBase64String(
    file: File,
    prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType],
    overrides?: IXmlifyedFile[],
): Promise<string> {
    const zip = this.compiler.compile(file, convertPrettifyType(prettify), overrides);
    /* ...  */
}

And after the statically defined subfiles, Compiler.compile can add them to the JSZip like so:

for (const subFile in overrides) {
    zip.file(subFile.path, subFile.data);
}

Would you be open to that or do you have another approach in mind?

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

No branches or pull requests

2 participants