src/editor/EditorManager.js
function _toggleInlineWidget(providers, errorMsg) {
        var result = new $.Deferred();

        var currentEditor = getCurrentFullEditor();

        if (currentEditor) {
            var inlineWidget = currentEditor.getFocusedInlineWidget();

            if (inlineWidget) {
                // an inline widget's editor has focus, so close it
                PerfUtils.markStart(PerfUtils.INLINE_WIDGET_CLOSE);
                inlineWidget.close().done(function () {
                    PerfUtils.addMeasurement(PerfUtils.INLINE_WIDGET_CLOSE);
                    // return a resolved promise to CommandManager
                    result.resolve(false);
                });
            } else {
                // main editor has focus, so create an inline editor
                _openInlineWidget(currentEditor, providers, errorMsg).done(function () {
                    result.resolve(true);
                }).fail(function () {
                    result.reject();
                });
            }
        } else {
            // Can not open an inline editor without a host editor
            result.reject();
        }

        return result.promise();
    }
function _toggleInlineWidget(providers, errorMsg) {
        var result = new $.Deferred();

        var currentEditor = getCurrentFullEditor();

        if (currentEditor) {
            var inlineWidget = currentEditor.getFocusedInlineWidget();

            if (inlineWidget) {
                // an inline widget's editor has focus, so close it
                PerfUtils.markStart(PerfUtils.INLINE_WIDGET_CLOSE);
                inlineWidget.close().done(function () {
                    PerfUtils.addMeasurement(PerfUtils.INLINE_WIDGET_CLOSE);
                    // return a resolved promise to CommandManager
                    result.resolve(false);
                });
            } else {
                // main editor has focus, so create an inline editor
                _openInlineWidget(currentEditor, providers, errorMsg).done(function () {
                    result.resolve(true);
                }).fail(function () {
                    result.reject();
                });
            }
        } else {
            // Can not open an inline editor without a host editor
            result.reject();
        }

        return result.promise();
    }
function _toggleInlineWidget ( providers , errorMsg ) { var result = new $ . Deferred ( ) ; var currentEditor = getCurrentFullEditor ( ) ; if ( currentEditor ) { var inlineWidget = currentEditor . getFocusedInlineWidget ( ) ; if ( inlineWidget ) { // an inline widget's editor has focus, so close it PerfUtils . markStart ( PerfUtils . INLINE_WIDGET_CLOSE ) ; inlineWidget . close ( ) . done ( function ( ) { PerfUtils . addMeasurement ( PerfUtils . INLINE_WIDGET_CLOSE ) ; // return a resolved promise to CommandManager result . resolve ( false ) ; } ) ; } else { // main editor has focus, so create an inline editor _openInlineWidget ( currentEditor , providers , errorMsg ) . done ( function ( ) { result . resolve ( true ) ; } ) . fail ( function ( ) { result . reject ( ) ; } ) ; } } else { // Can not open an inline editor without a host editor result . reject ( ) ; } return result . promise ( ) ; }
Closes any focused inline widget. Else, asynchronously asks providers to create one.

@param {Array.<{priority:number, provider:function(...)}>} providers
prioritized list of providers
@param {string=} errorMsg Default message to display if no providers return non-null
@return {!Promise} A promise resolved with true if an inline widget is opened or false
when closed. Rejected if there is neither an existing widget to close nor a provider
willing to create a widget (or if no editor is open).
Closes any focused inline widget . Else asynchronously asks providers to create one .