froala / wysiwyg-editor

The next generation Javascript WYSIWYG HTML Editor.
https://www.froala.com/wysiwyg-editor
Other
5.28k stars 672 forks source link

Froala Editor load Microsoft Word content from AJAX #3766

Open yogen-darji-hs opened 4 years ago

yogen-darji-hs commented 4 years ago

How to load stored MS word file into Froala Editor?

I've template file with MS word and I want user to edit template using Froala Editor.

I've tried several option but it loads binary data not actual word content with format.


cache-control: private
content-disposition: attachment; filename="Test.docx"
content-length: 12645
content-type: octet-stream

froalaEditor= new FroalaEditor('#content', {...});

$.ajax({
            url: '/API/XXX/DownloadTemplateFile?templateId=1',
            type: "GET",
            contentType: "application/json;charset=utf-8",
            traditional: true,
            success: function (data) {
                // froalaEditor.$el[0].innerHTML = data
                var reader = new FileReader();
                reader.onload = function () {
                 var arrayBuffer = this.result,
                    array = new Uint8Array(arrayBuffer),
                    froalaEditor.$el[0].innerHTML = array

                }
                let blob = new Blob([data], { type: 'octet-stream' });
                reader.readAsArrayBuffer(blob);

            },
            error: function (data) {

            }
casualuser commented 4 years ago

Hello,

So at the moment, there are no any ways to read directly from or write into MS Word format files. You can copy formatted content from opened MSWord document and paste it into Froala Editor so most of the markup will be parsed and converted into html. If you want to get Froala Editor reading directly from MSWord files then you can create a feature request here - https://wysiwyg-editor-roadmap.froala.com/public If it will get a lot of votes then potentially it may be included in the next release with new features.