function doClick(button) {
            inputBox.focus();

            if (button.textOp) {
                if (undoManager) {
                    undoManager.setCommandMode();
                }

                var state = new TextareaState(panels);

                if (!state) {
                    return;
                }

                var chunks = state.getChunks();

                // Some commands launch a "modal" prompt dialog.  Javascript
                // can't really make a modal dialog box and the WMD code
                // will continue to execute while the dialog is displayed.
                // This prevents the dialog pattern I'm used to and means
                // I can't do something like this:
                //
                // var link = CreateLinkDialog();
                // makeMarkdownLink(link);
                //
                // Instead of this straightforward method of handling a
                // dialog I have to pass any code which would execute
                // after the dialog is dismissed (e.g. link creation)
                // in a function parameter.
                //
                // Yes this is awkward and I think it sucks, but there's
                // no real workaround.  Only the image and link code
                // create dialogs and require the function pointers.
                var fixupInputArea = function () {

                    inputBox.focus();

                    if (chunks) {
                        state.setChunks(chunks);
                    }

                    state.restore();
                    previewManager.refresh();
                };

                var noCleanup = button.textOp(chunks, fixupInputArea);

                if (!noCleanup) {
                    fixupInputArea();
                }

            }

            if (button.execute) {
                button.execute(undoManager);
            }
        }
// Perform the button's action.

Perform the button's action.
Perform the button ' s action .
function doClick(button) {
            inputBox.focus();
            if (button.textOp) {
                if (undoManager) {
                    undoManager.setCommandMode();
                }
                var state = new TextareaState(panels);
                if (!state) {
                    return;
                }
                var chunks = state.getChunks();
                var fixupInputArea = function () {
                    inputBox.focus();
                    if (chunks) {
                        state.setChunks(chunks);
                    }
                    state.restore();
                    previewManager.refresh();
                };
                var noCleanup = button.textOp(chunks, fixupInputArea);
                if (!noCleanup) {
                    fixupInputArea();
                }
            }
            if (button.execute) {
                button.execute(undoManager);
            }
        }
function doClick ( button ) { inputBox . focus ( ) ; if ( button . textOp ) { if ( undoManager ) { undoManager . setCommandMode ( ) ; } var state = new TextareaState ( panels ) ; if ( ! state ) { return ; } var chunks = state . getChunks ( ) ; var fixupInputArea = function ( ) { inputBox . focus ( ) ; if ( chunks ) { state . setChunks ( chunks ) ; } state . restore ( ) ; previewManager . refresh ( ) ; } ; var noCleanup = button . textOp ( chunks , fixupInputArea ) ; if ( ! noCleanup ) { fixupInputArea ( ) ; } } if ( button . execute ) { button . execute ( undoManager ) ; } }
Perform the button's action.
Perform the button ' s action .
// Some commands launch a "modal" prompt dialog.  Javascript
 // can't really make a modal dialog box and the WMD code
 // will continue to execute while the dialog is displayed.
 // This prevents the dialog pattern I'm used to and means
 // I can't do something like this:
 //
 // var link = CreateLinkDialog();
 // makeMarkdownLink(link);
 //
 // Instead of this straightforward method of handling a
 // dialog I have to pass any code which would execute
 // after the dialog is dismissed (e.g. link creation)
 // in a function parameter.
 //
 // Yes this is awkward and I think it sucks, but there's
 // no real workaround.  Only the image and link code
 // create dialogs and require the function pointers.
