📄 htmlData support
This commit is contained in:
parent
19930d8022
commit
e98f74f169
@ -37,11 +37,30 @@ export default class Export extends Plugin {
|
|||||||
// } );
|
// } );
|
||||||
|
|
||||||
// Insert a text into the editor after clicking the button.
|
// Insert a text into the editor after clicking the button.
|
||||||
this.listenTo( view, 'execute', async () => {
|
// this.listenTo( view, 'execute', async () => {
|
||||||
asBlob(this.editor.getData()).then((data: any) => {
|
// asBlob(this.editor.getData()).then((data: any) => {
|
||||||
saveAs(data, 'file.docx') // save as docx file
|
// saveAs(data, 'file.docx') // save as docx file
|
||||||
}) // asBlob() return Promise<Blob|Buffer>
|
// }) // asBlob() return Promise<Blob|Buffer>
|
||||||
|
|
||||||
|
// editor.editing.view.focus();
|
||||||
|
// } );
|
||||||
|
|
||||||
|
// POST fetch docx and download
|
||||||
|
this.listenTo( view, 'execute', async () => {
|
||||||
|
fetch('http://localhost:3000/docx', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ htmlData: this.editor.getData() }),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.blob())
|
||||||
|
.then(blob => {
|
||||||
|
saveAs(blob, 'stou.docx') // save as docx file
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
editor.editing.view.focus();
|
editor.editing.view.focus();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user