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

downloading file as docx does not function as intended #1

Open
rhyses-pieces opened this issue Aug 11, 2021 · 2 comments
Open

downloading file as docx does not function as intended #1

rhyses-pieces opened this issue Aug 11, 2021 · 2 comments

Comments

@rhyses-pieces
Copy link

Hello! Thank you for creating this project. I was tinkering around with a fork of this project for my friends when I discovered that the Download file option doesn't work. Here are the steps I did to recreate the issue:

  1. Write content in editor
  2. Save the content with a new name (Untitled > Test)
  3. Click Download
  4. Successfully downloaded Test.docx
  5. Open Test.docx in another editor (like Word) or upload file on Google Docs
  6. Resulting file is empty. There is no content saved on the document whatsoever.

I looked around to see if there were other export options for the Quill editor, but it seems like there isn't an easy way to export the data unless you create a custom module.

Since I'm still quite new to ReactJS, I'm having some trouble of modifying the existing code to export into HTML instead. Would this kind of functionality require a lot of refactoring?

@j-berman
Copy link
Owner

Hm, I'm not sure what happened! I recall spending a decent amount of time getting this to work. Can see the relevant code here:

handleDownloadDoc = () => {
const { docName } = this.state
// https://github.com/quilljs/quill/issues/1996
let html = '<html><head><meta charset="UTF-8"></head><body>'
const jQueryQuillEditor = $('#editor').find('.ql-editor').clone()
// all CSS will be set inline so that it will print in document
makeCssInline(jQueryQuillEditor)
html += jQueryQuillEditor.html()
html += '</body></html>'
const file = htmlDocx.asBlob(html)
file.name = docName + '.docx'
downloadFileLocally(file)
}

console logging around that section should reveal the cause of the issue. Don't think it would require much refactoring.

@rhyses-pieces
Copy link
Author

Today, I tested the downloaded file again in the online Microsoft Word app and it seems to work there. However, when I download that same file from the online Microsoft Word app and open it in Google Docs, the file shows up as blank. Repeated testing show the same result, whereas Pandoc-converted .docx files work fine in Microsoft Word online and Google Docs.

I'm assuming it might have to do with how the file is being encoded in the Microsoft Word XML format. I'll try your suggestion and console log the whole thing to see what's up!

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