diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index 1cb527fc40..aa1ba9dc5b 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -35,7 +35,7 @@ define [ url = ace.config._moduleUrl(args...) + "?fingerprint=#{window.aceFingerprint}" return url - App.directive "aceEditor", ($timeout, $compile, $rootScope, event_tracking, localStorage, $cacheFactory, labels, graphics, preamble) -> + App.directive "aceEditor", ($timeout, $compile, $rootScope, event_tracking, localStorage, $cacheFactory, labels, graphics, preamble, $http) -> monkeyPatchSearch($rootScope, $compile) return { @@ -97,7 +97,7 @@ define [ if scope.spellCheck # only enable spellcheck when explicitly required spellCheckCache = $cacheFactory("spellCheck-#{scope.name}", {capacity: 1000}) - spellCheckManager = new SpellCheckManager(scope, editor, element, spellCheckCache) + spellCheckManager = new SpellCheckManager(scope, editor, element, spellCheckCache, $http) undoManager = new UndoManager(scope, editor, element) highlightsManager = new HighlightsManager(scope, editor, element) cursorPositionManager = new CursorPositionManager(scope, editor, element, localStorage) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee index bef2edfc41..d6b7a02987 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee @@ -5,7 +5,7 @@ define [ Range = ace.require("ace/range").Range class SpellCheckManager - constructor: (@$scope, @editor, @element, @cache) -> + constructor: (@$scope, @editor, @element, @cache, @$http) -> $(document.body).append @element.find(".spell-check-menu") @updatedLines = [] @@ -235,18 +235,11 @@ define [ apiRequest: (endpoint, data, callback = (error, result) ->)-> data.token = window.user.id data._csrf = window.csrfToken - options = - url: "/spelling" + endpoint - type: "POST" - dataType: "json" - headers: - "Content-Type": "application/json" - data: JSON.stringify data - success: (data, status, xhr) -> - callback null, data - error: (xhr, status, error) -> - callback error - return $.ajax options + @$http.post("/spelling" + endpoint, data) + .then (response) => + callback(null, response.data) + .catch (response) => + callback(new Error('api failure')) blacklistedCommandRegex: /// \\ # initial backslash