mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
use ace modelist extension to auto-detect mode
This commit is contained in:
parent
1ec133c68d
commit
7258e947a8
3 changed files with 19 additions and 5 deletions
|
@ -35,7 +35,8 @@ div.full-size(
|
|||
resize-on="layout:main:resize,layout:pdf:resize",
|
||||
annotations="pdf.logEntryAnnotations[editor.open_doc_id]",
|
||||
read-only="!permissions.write",
|
||||
on-ctrl-enter="recompileViaKey"
|
||||
file-name="editor.open_doc_name",
|
||||
on-ctrl-enter="recompileViaKey",
|
||||
syntax-validation="settings.syntaxValidation"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ define [
|
|||
@$scope.editor = {
|
||||
sharejs_doc: null
|
||||
open_doc_id: null
|
||||
open_doc_name: null
|
||||
opening: true
|
||||
}
|
||||
|
||||
|
@ -59,6 +60,7 @@ define [
|
|||
return
|
||||
|
||||
@$scope.editor.open_doc_id = doc.id
|
||||
@$scope.editor.open_doc_name = doc.name
|
||||
|
||||
@ide.localStorage "doc.open_id.#{@$scope.project_id}", doc.id
|
||||
@ide.fileTreeManager.selectEntity(doc)
|
||||
|
|
|
@ -2,14 +2,16 @@ define [
|
|||
"base"
|
||||
"ace/ace"
|
||||
"ace/ext-searchbox"
|
||||
"ace/ext-modelist"
|
||||
"ide/editor/directives/aceEditor/undo/UndoManager"
|
||||
"ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager"
|
||||
"ide/editor/directives/aceEditor/spell-check/SpellCheckManager"
|
||||
"ide/editor/directives/aceEditor/highlights/HighlightsManager"
|
||||
"ide/editor/directives/aceEditor/cursor-position/CursorPositionManager"
|
||||
"ide/editor/directives/aceEditor/track-changes/TrackChangesManager"
|
||||
], (App, Ace, SearchBox, UndoManager, AutoCompleteManager, SpellCheckManager, HighlightsManager, CursorPositionManager, TrackChangesManager) ->
|
||||
], (App, Ace, SearchBox, ModeList, UndoManager, AutoCompleteManager, SpellCheckManager, HighlightsManager, CursorPositionManager, TrackChangesManager) ->
|
||||
EditSession = ace.require('ace/edit_session').EditSession
|
||||
ModeList = ace.require('ace/ext/modelist')
|
||||
|
||||
# set the path for ace workers if using a CDN (from editor.jade)
|
||||
if window.aceWorkerPath != ""
|
||||
|
@ -42,7 +44,8 @@ define [
|
|||
text: "="
|
||||
readOnly: "="
|
||||
annotations: "="
|
||||
navigateHighlights: "=",
|
||||
navigateHighlights: "="
|
||||
fileName: "="
|
||||
onCtrlEnter: "="
|
||||
syntaxValidation: "="
|
||||
}
|
||||
|
@ -221,8 +224,16 @@ define [
|
|||
session = editor.getSession()
|
||||
if session?
|
||||
session.destroy()
|
||||
editor.setSession(new EditSession(lines, "ace/mode/latex"))
|
||||
resetSession()
|
||||
|
||||
# see if we can lookup a suitable mode from ace
|
||||
# but fall back to text by default
|
||||
try
|
||||
mode = ModeList.getModeForPath(scope.fileName).mode
|
||||
catch
|
||||
mode = "ace/mode/text"
|
||||
|
||||
editor.setSession(new EditSession(lines, mode))
|
||||
|
||||
session = editor.getSession()
|
||||
|
||||
doc = session.getDocument()
|
||||
|
|
Loading…
Reference in a new issue