Angular6 如何在服务器上插入映像而不是angular7中的Base64
我目前正在我的angular项目中与ngx quill合作。我尝试使用编辑器添加图像,但编辑器上载图像base64编码Angular6 如何在服务器上插入映像而不是angular7中的Base64,angular6,angular7,ngx-quill,Angular6,Angular7,Ngx Quill,我目前正在我的angular项目中与ngx quill合作。我尝试使用编辑器添加图像,但编辑器上载图像base64编码 editorText : string editorForm: FormGroup editorContent: any editorStyle = { height: '250px' } objectFormat = [ { insert: 'Hello ' }, { insert: 'World!', attributes: { bold: true
editorText : string
editorForm: FormGroup
editorContent: any
editorStyle = {
height: '250px'
}
objectFormat = [
{ insert: 'Hello ' },
{ insert: 'World!', attributes: { bold: true } },
{ insert: '\n' }
]
myObjStr:string
config = {
toolbar: {
container:
[
['image']
]
}
}
}
ngOnInit() {
this.editorForm = new FormGroup({
'editor': new FormControl(null)
})
任何关于将图像上传到服务器的图像处理过程的建议这不会为您上传图像,但允许用户粘贴已托管的图像url(如插入视频功能):
import { QuillModules, defaultModules } from 'ngx-quill';
export class MyComponent {
quillModules: QuillModules = {
toolbar: {
container: defaultModules.toolbar,
handlers: {
image: imageHandler
}
}
};
}
function imageHandler(this: any) {
imageHandler(this: any) {
const tooltip = this.quill.theme.tooltip;
const originalSave = tooltip.save;
const originalHide = tooltip.hide;
tooltip.save = function(this: any) {
const range = this.quill.getSelection(true);
const value = this.textbox.value;
if (value) {
this.quill.insertEmbed(range.index, 'image', value, 'user');
}
};
// Called on hide and save.
tooltip.hide = function (this: any) {
tooltip.save = originalSave;
tooltip.hide = originalHide;
tooltip.hide();
};
tooltip.edit('image');
tooltip.textbox.placeholder = "Embed URL";
}
}