I've developed a custom insertImageDialog hook to enable file uploads directly within the editor.
$('div#insertImageDialog input[type=file]').ajaxfileupload({
action: $file.attr('data-action'),
onStart: function() {
$loader.show();
},
onComplete: function(response) {
$loader.hide();
if (response.success) {
callback(response.imagePath); // <---- oO
dialogClose();
} else {
alert(response.message);
$file.val('');
}
}
});
Initially, this functionality works as expected when inserting an image.
However, subsequent attempts result in an error:
Uncaught TypeError: Cannot call method 'removeChild' of null Markdown.Editor.js:1683 commandProto.doLinkOrImage.linkEnteredCallback Markdown.Editor.js:1683 self.initMarkdownEditor.editor.hooks.set.$.ajaxfileupload.onComplete
File uploading functions correctly outside the editor, suggesting a potential scoping issue with the callback function.
This problem has been causing frustration throughout the day.