Search code examples
javascriptwmd-editor

Customizing WMD Editor Button From It's Default - Can't get rid of the wmd-prompt-background


I use the WMD editor like the one used here.

I have a custom upload feature that is done via a popup, and handles the insertion of the markdown automatically e.g. the wmd editor doesn't need to handle that at all.

I have used the editor hook as described in the example in the docs, but I still can't figure out how to disable/remove the prompt background that is shown by default... (the same background/overlay used here when you click the image button, etc.)

This is my code:

    // initialize the editor
    var editor1 = new Markdown.Editor(converter1, "", options);

    //customize upload button on button bar... remove default functionality, activate popup on click
    editor1.hooks.set("insertImageDialog", function (callback) {

        var a = $('#wmd-button-bar').data('stgt');
        popup('/inc_upload.asp?t=' + a, 'Upload a File', 350, 500);

        return true; // tell the editor that we'll take care of getting the image url
    });

editor1.run();

Solution

  • Figured it out, I just needed a null callback.

    // initialize the editor
    var editor1 = new Markdown.Editor(converter1, "", options);
    
    //customize upload button on button bar... remove default functionality, activate popup on click
    editor1.hooks.set("insertImageDialog", function (callback) {
    
        var a = $('#wmd-button-bar').data('stgt');
        popup('/inc_upload.asp?t=' + a, 'Upload a File', 350, 500);
        callback(null);
        return true; // tell the editor that we'll take care of getting the image url
    });
    
     editor1.run();