Shane Kilkelly 9 лет назад
Родитель
Сommit
f057f788e3

+ 1 - 1
services/web/public/coffee/ide/editor/directives/aceEditor.coffee

@@ -103,7 +103,7 @@ define [
 				cursorPositionManager = new CursorPositionManager(scope, editor, element, localStorage)
 				trackChangesManager   = new TrackChangesManager(scope, editor, element)
 				labelsManager = new LabelsManager(scope, editor, element, labels)
-				autoCompleteManager = new AutoCompleteManager(scope, editor, element, labelsManager, graphics)
+				autoCompleteManager = new AutoCompleteManager(scope, editor, element, labelsManager, graphics, preamble)
 
 
 				# Prevert Ctrl|Cmd-S from triggering save dialog

+ 10 - 9
services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee

@@ -17,7 +17,7 @@ define [
 		commandFragment?.match(/\\(\w+)\{/)?[1]
 
 	class AutoCompleteManager
-		constructor: (@$scope, @editor, @element, @labelsManager, @graphics) ->
+		constructor: (@$scope, @editor, @element, @labelsManager, @graphics, @preamble) ->
 			@suggestionManager = new SuggestionManager()
 
 			@monkeyPatchAutocomplete()
@@ -45,6 +45,7 @@ define [
 			SnippetCompleter = new SnippetManager()
 
 			Graphics = @graphics
+			Preamble = @preamble
 			GraphicsCompleter =
 				getCompletions: (editor, session, pos, prefix, callback) ->
 					upToCursorRange = new Range(pos.row, 0, pos.row, pos.column)
@@ -58,17 +59,17 @@ define [
 							needsClosingBrace = !lineBeyondCursor.match(/^[^{]*}/)
 							commandName = match[1]
 							currentArg = match[3]
+							graphicsPaths = Preamble.getGraphicsPaths()
 							result = []
-							# result.push {
-							# 	caption: "\\#{commandName}{}",
-							# 	snippet: "\\#{commandName}{}",
-							# 	meta: "graphic",
-							# 	score: 60
-							# }
 							for graphic in Graphics.getGraphicsFiles()
+								path = graphic.path
+								for graphicsPath in graphicsPaths
+									if path.indexOf(graphicsPath) == 0
+										path = path.slice(graphicsPath.length)
+										break
 								result.push {
-									caption: "\\#{commandName}{#{graphic.path}#{if needsClosingBrace then '}' else ''}",
-									value: "\\#{commandName}{#{graphic.path}#{if needsClosingBrace then '}' else ''}",
+									caption: "\\#{commandName}{#{path}#{if needsClosingBrace then '}' else ''}",
+									value: "\\#{commandName}{#{path}#{if needsClosingBrace then '}' else ''}",
 									meta: "graphic",
 									score: 50
 								}

+ 0 - 2
services/web/public/coffee/ide/file-tree/FileTreeManager.coffee

@@ -202,8 +202,6 @@ define [
 					childPath = path + "/" + entity.name
 				else
 					childPath = entity.name
-				# FIXME: this is a hack
-				entity.path = childPath
 				callback(entity, folder, childPath)
 				if entity.children?
 					@_forEachEntityInFolder(entity, childPath, callback)

+ 5 - 3
services/web/public/coffee/ide/graphics/services/graphics.coffee

@@ -7,9 +7,11 @@ define [
 		Graphics =
 			getGraphicsFiles: () ->
 				graphicsFiles = []
-				ide.fileTreeManager.forEachEntity (f) ->
-					if f?.name?.match?(/.*\.(png|jpg|jpeg)/)
-						graphicsFiles.push f
+				ide.fileTreeManager.forEachEntity (entity, folder, path) ->
+					if entity.type == 'file' && entity?.name?.match?(/.*\.(png|jpg|jpeg|pdf|eps)/)
+						cloned = _.clone(entity)
+						cloned.path = path
+						graphicsFiles.push cloned
 				return graphicsFiles
 
 		return Graphics

+ 0 - 2
services/web/public/coffee/ide/preamble/services/preamble.coffee

@@ -19,6 +19,4 @@ define [
 					paths.push(match[1])
 				return paths
 
-		window.Preamble = Preamble
-
 		return Preamble

+ 5 - 0
services/web/public/stylesheets/app/editor.less

@@ -504,3 +504,8 @@
 	height: auto;
 	border-bottom: 1px solid @modal-header-border-color;
 }
+
+// Widen autocomplete popup
+.ace_autocomplete {
+	width: 380px !important;
+}