Похоже, что froala позволяет это:
https://wysiwyg-editor.froala.help/hc/en-us/articles/115000555949-Can-I-insert-images-as-base64-
, но обратите внимание, что пример JS не будет работать для TypeScript как есть.
Вы должны изменить его немного из-за: https://github.com/microsoft/TypeScript/issues/4163
, который должен быть связан с таким параметром редактора, как этот:
<textarea [froalaEditor]="options" [(froalaModel)]="editorContent"></textarea>
и размещенный вам код компонента:
public options:Object = {
placeholderText: 'Edit Your Content Here!',
charCounterCount: true,
toolbarButtonsXS: ['bold', 'italic', 'underline', 'paragraphFormat', 'alert'],
toolbarButtonsSM: ['bold', 'italic', 'underline', 'paragraphFormat', 'alert'],
toolbarButtonsMD: ['bold', 'italic', 'underline', 'paragraphFormat', 'alert'],
toolbarButtons: ['uploadFile', 'fullscreen', 'bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', 'fontFamily', 'fontSize', 'color', 'emoticons', 'inlineStyle', 'paragraphStyle', 'paragraphFormat', 'align', 'formatOL', 'formatUL', 'outdent'],
events: {
'image.beforeUpload': function(files) {
console.log("Start");
const editor = this;
if (files.length) {
console.log("Files: "+files.length);
// Create a File Reader.
const reader = new FileReader();
reader.onload = (e) => {
var result = reader.result;
editor.image.insert(result, null, null, editor.image.get());
};
// Read image as base64.
reader.readAsDataURL(files[0]);
console.log("Behind event");
// Read image as base64.
reader.readAsDataURL(files[0]);
}
//editor.popups.hideAll();
// Stop default upload chain.
return false;
}
}