Ionaru / easy-markdown-editor

EasyMDE: A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://stackblitz.com/edit/easymde
MIT License
2.31k stars 308 forks source link

Allow .iix file type for images if .iix is in the imageAccept property #575

Open robhumphries5 opened 6 months ago

robhumphries5 commented 6 months ago

Is your feature request related to a problem? Please describe. I am using EasyMDE with ServiceNow and images are stored at paths ending with .iix. EasyMDE is interpreting these as links. I understand .iix is not necessarily an image, but in this case I am also explicitly using the "Import an Image" action and I have added image/iix to the imageAccept property of the editor.

Describe the solution you'd like EasyMDE to process .iix link paths as images if .iix is in the imageAccept property

Describe alternatives you've considered There are alternatives in ServiceNow like creating an endpoint that converts requests for /abc.png to /abc.iix and return the result.

Additional context N/A

robhumphries5 commented 6 months ago

I have added a workaround like this but it would be nice if iix was supported

editor.codemirror.on("changes",function(event){
    var value = event.getTextArea().value;
    var regex = /[^!]\[[a-z0-9]{32}\.iix/gm;
    var linksThatShouldBeImages = value.match(regex);
    if(!linksThatShouldBeImages){
        return;
    }
    linksThatShouldBeImages.forEach(function(link){
        var firstChar = link.substring(0,1);
        var rest = link.substring(1,link.length);
        value = value.replace(link,firstChar+"!"+rest);
    });
    editor.value(value);

});