mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
Use angular $http
service for spellcheck
This commit is contained in:
parent
f74da0e6cf
commit
a66cb15f48
2 changed files with 8 additions and 15 deletions
|
@ -35,7 +35,7 @@ define [
|
||||||
url = ace.config._moduleUrl(args...) + "?fingerprint=#{window.aceFingerprint}"
|
url = ace.config._moduleUrl(args...) + "?fingerprint=#{window.aceFingerprint}"
|
||||||
return url
|
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)
|
monkeyPatchSearch($rootScope, $compile)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -97,7 +97,7 @@ define [
|
||||||
|
|
||||||
if scope.spellCheck # only enable spellcheck when explicitly required
|
if scope.spellCheck # only enable spellcheck when explicitly required
|
||||||
spellCheckCache = $cacheFactory("spellCheck-#{scope.name}", {capacity: 1000})
|
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)
|
undoManager = new UndoManager(scope, editor, element)
|
||||||
highlightsManager = new HighlightsManager(scope, editor, element)
|
highlightsManager = new HighlightsManager(scope, editor, element)
|
||||||
cursorPositionManager = new CursorPositionManager(scope, editor, element, localStorage)
|
cursorPositionManager = new CursorPositionManager(scope, editor, element, localStorage)
|
||||||
|
|
|
@ -5,7 +5,7 @@ define [
|
||||||
Range = ace.require("ace/range").Range
|
Range = ace.require("ace/range").Range
|
||||||
|
|
||||||
class SpellCheckManager
|
class SpellCheckManager
|
||||||
constructor: (@$scope, @editor, @element, @cache) ->
|
constructor: (@$scope, @editor, @element, @cache, @$http) ->
|
||||||
$(document.body).append @element.find(".spell-check-menu")
|
$(document.body).append @element.find(".spell-check-menu")
|
||||||
|
|
||||||
@updatedLines = []
|
@updatedLines = []
|
||||||
|
@ -235,18 +235,11 @@ define [
|
||||||
apiRequest: (endpoint, data, callback = (error, result) ->)->
|
apiRequest: (endpoint, data, callback = (error, result) ->)->
|
||||||
data.token = window.user.id
|
data.token = window.user.id
|
||||||
data._csrf = window.csrfToken
|
data._csrf = window.csrfToken
|
||||||
options =
|
@$http.post("/spelling" + endpoint, data)
|
||||||
url: "/spelling" + endpoint
|
.then (response) =>
|
||||||
type: "POST"
|
callback(null, response.data)
|
||||||
dataType: "json"
|
.catch (response) =>
|
||||||
headers:
|
callback(new Error('api failure'))
|
||||||
"Content-Type": "application/json"
|
|
||||||
data: JSON.stringify data
|
|
||||||
success: (data, status, xhr) ->
|
|
||||||
callback null, data
|
|
||||||
error: (xhr, status, error) ->
|
|
||||||
callback error
|
|
||||||
return $.ajax options
|
|
||||||
|
|
||||||
blacklistedCommandRegex: ///
|
blacklistedCommandRegex: ///
|
||||||
\\ # initial backslash
|
\\ # initial backslash
|
||||||
|
|
Loading…
Reference in a new issue