Created
May 22, 2022 12:15
-
-
Save lokize/78aa7c52170405e2f98b28e282039554 to your computer and use it in GitHub Desktop.
uploadAdapter Ckeditor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// esse é o meu uploadAdapter | |
export default class UploadAdapter { | |
constructor(loader) { | |
// The file loader instance to use during the upload. | |
this.loader = loader; | |
} | |
// Starts the upload process. | |
upload() { | |
return new Promise((resolve, reject) => { | |
const reader = new window.FileReader(); | |
reader.addEventListener("load", () => { | |
resolve({ default: reader.result }); | |
}); | |
reader.addEventListener("error", (err) => { | |
reject(err); | |
}); | |
reader.addEventListener("abort", () => { | |
reject(); | |
}); | |
this.loader.file.then((file) => { | |
reader.readAsDataURL(file); | |
}); | |
}); | |
} | |
// Aborts the upload process. | |
abort() { | |
// | |
} | |
} | |
export const uploader = function (editor) { | |
editor.plugins.get("FileRepository").createUploadAdapter = (loader) => | |
new UploadAdapter(loader); | |
}; | |
// esse é o jeito que invoco ele no código | |
uploader(editor) { | |
editor.plugins.get("FileRepository").createUploadAdapter = (loader) => { | |
return new UploadAdapter(loader); | |
}; | |
}, |
lubien
commented
May 22, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment