burkeen / pagedown

Automatically exported from code.google.com/p/pagedown
Other
0 stars 0 forks source link

Double postprocessing when using image dialog hook #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I get:

![![enter image description here][5]][5]

What steps will reproduce the problem?

1. made a page much like the demopage
2. initialized it like the following

<script type="text/javascript">
    function my_dialog(callback){
        alert ("hello");
        var retval = callback("http://xyz.png/x.png");
        return true
    }
    var converter1 = Markdown.getSanitizingConverter();
    var editor1 = new Markdown.Editor(converter1);
    editor1.hooks.set("insertImageDialog",my_dialog)
    editor1.run();
</script> 

3. pressed the image link

What is the expected output? What do you see instead?
![enter image description here][5]

What version of the product are you using? On what operating system?
N/A

Please provide any additional information below.

I can make it work if commenting out the 
                postProcessing();

inside the linkEnteredCallback function

Original issue reported on code.google.com by gards...@gmail.com on 7 Oct 2011 at 2:47

GoogleCodeExporter commented 9 years ago
This is actually by design. The callback cannot be called directly from the 
insertImageDialog hook; this function needs to have exited before the callback 
is called. Otherwise you'd be returning the link *before* telling the editor 
that you'll be doing that (by returning true from the hook).

I admit the documentation wasn't 100% clear about this; I have added a 
paragraph at the bottom.

Original comment by b...@stackoverflow.com on 7 Oct 2011 at 3:04