diff --git a/src/editor/Editor.js b/src/editor/Editor.js index c38dc5000cc..826806b83ce 100644 --- a/src/editor/Editor.js +++ b/src/editor/Editor.js @@ -338,6 +338,9 @@ define(function (require, exports, module) { CodeMirror.commands.delCharRight(instance); } }, + "Esc": function (instance) { + self.removeAllInlineWidgets(); + }, "Shift-Delete": "cut", "Ctrl-Insert": "copy", "Shift-Insert": "paste" @@ -837,6 +840,18 @@ define(function (require, exports, module) { this._fireWidgetOffsetTopChanged(pos.line); }; + /** + * Removes all inline widgets + */ + Editor.prototype.removeAllInlineWidgets = function () { + // copy the array because _removeInlineWidgetInternal will modifying the original + var widgets = [].concat(this.getInlineWidgets()); + + widgets.forEach(function (widget) { + this.removeInlineWidget(widget); + }, this); + }; + /** * Removes the given inline widget. * @param {number} inlineWidget The widget to remove.