Index.cshtml
<ejs-richtexteditor id="default" actionComplete="actionComplete"></ejs-richtexteditor>
<script type="text/javascript">
function actionComplete(args) { // Triggered when every action is completed
if (args.requestType == "Image") { // Check image actionComplete
imgelement = args.elements[0];
toBase64(imgelement.src, function (dataUrl) {
imgelement.setAttribute('src', dataUrl) // Set converted base64 image into RTE
})
}
}
function toBase64(url, callback) {
var httpRequest = new XMLHttpRequest();
httpRequest.onload = function () {
var fileReader = new FileReader();
fileReader.onloadend = function () { // Triggered each time the rendering operation complete
callback(fileReader.result);
}
fileReader.readAsDataURL(httpRequest.response); // Read the content of the specified file or Blob
};
httpRequest.open('GET', url);
httpRequest.responseType = 'blob';
httpRequest.send();
}
</script> |