Skip to content

Commit

Permalink
feat(demo): prevent page to be reloaded while uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
CHNB128 committed Sep 26, 2021
1 parent cf8f011 commit 3a272f8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ const quill = new Quill('#editor', {
return node
},
onFileUploaded: (node, { url }) => {
// Allow page to be closed
window.onbeforeunload = () => {};
},
upload: file => {
// Prevent page to be closed while file in uploading
window.onbeforeunload = () => {
return "You have attempted to leave this page. Are you sure?";
}
// return a Promise that resolves in a link to the uploaded image
return new Promise((resolve, reject) => {
setTimeout(() => {
Expand Down

0 comments on commit 3a272f8

Please sign in to comment.