Context:
In a Winform VB.NET application, running on Windows 10, .NET 5.0, I use a TinyMCE embedded in a Webbrowser control to display a WYSIWYG html editor in a form, inspired from this to do it. everything works well so far but I tweak TinyMCE to be able to upload image from local drive following this
Issue:
In this weird embedded TinyMCE, the pop window to add image from local drive opens, the button to browse local directory is there, clickable but do nothing.
Code used: I don't know where the issue is located. VB.NET? JS? Is there some kind of webbrowser limitation? I used Tiny MCE 4.3.4.
Here's the javascript used to init TinyMCE
<script>
tinymce.init({
selector: '#editorcontent',
plugins: ['autolink link lists charmap hr anchor',
'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime nonbreaking',
'table contextmenu directionality paste textcolor',
'image'],
setup : function(ed) {
ed.on('init',function(e) {
ed.execCommand('mceFullScreen');
})},
// enable title field in the Image dialog
image_title: true,
// enable automatic uploads of images represented by blob or data URIs
automatic_uploads: true,
// add custom filepicker only to Image dialog
file_picker_types: 'image',
file_picker_callback: function(cb, value, meta) {
var input = document.createElement('input');
input.setAttribute('type', 'file');
input.setAttribute('accept', 'image/*');
input.onchange = function() {
var file = this.files[0];
var reader = new FileReader();
reader.onload = function () {
var id = 'blobid' + (new Date()).getTime();
var blobCache = tinymce.activeEditor.editorUpload.blobCache;
var base64 = reader.result.split(',')[2];
var blobInfo = blobCache.create(id, file, base64);
blobCache.add(blobInfo);
// call the callback and populate the Title field with the file name
cb(blobInfo.blobUri(), { title: file.name });
};
reader.readAsDataURL(file);
};
input.click();
}
}
);
Additionnal infos: The script works like a charm if it's run in Chrome, FF, or Edge. It seems that.NET Webbrowser behave like IE7.