Sfoglia il codice sorgente

Configure line height and font family separately for v2

James Allen 8 anni fa
parent
commit
1aadd7d369

+ 2 - 0
services/web/app/coffee/infrastructure/ExpressLocals.coffee

@@ -321,5 +321,7 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
 			chatMessageBorderLightness : if isOl then "40%" else "70%"
 			chatMessageBgSaturation    : if isOl then "85%" else "60%"
 			chatMessageBgLightness     : if isOl then "40%" else "97%"
+			editorFontFamily           : if isOl then '\\"Lucida Console\\", monospace' else null
+			editorLineHeight           : if isOl then 1.6 else null
 			renderAnnouncements        : !isOl
 		next()

+ 2 - 0
services/web/app/views/project/editor/editor.pug

@@ -68,6 +68,8 @@ div.full-size(
 			track-changes= "editor.trackChanges",
 			doc-id="editor.open_doc_id"
 			renderer-data="reviewPanel.rendererData"
+			font-family="ui.editorFontFamily"
+			line-height="ui.editorLineHeight"
 		)
 
 		!= moduleIncludes('editor:body', locals)

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

@@ -80,6 +80,8 @@ define [
 			miniReviewPanelVisible: false
 			chatResizerSizeOpen: window.uiConfig.chatResizerSizeOpen
 			chatResizerSizeClosed: window.uiConfig.chatResizerSizeClosed
+			editorFontFamily: window.uiConfig.editorFontFamily
+			editorLineHeight: window.uiConfig.editorLineHeight
 		}
 		$scope.user = window.user
 

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

@@ -67,6 +67,8 @@ define [
 				trackChangesEnabled: "="
 				docId: "="
 				rendererData: "="
+				lineHeight: "="
+				fontFamily: "="
 			}
 			link: (scope, element, attrs) ->
 				# Don't freak out if we're already in an apply callback
@@ -81,9 +83,6 @@ define [
 				editor = ace.edit(element.find(".ace-editor-body")[0])
 				editor.$blockScrolling = Infinity
 
-				editor.container.style.lineHeight = 1.6
-				editor.setOption('fontFamily', '"Lucida Console", monospace')
-
 				# auto-insertion of braces, brackets, dollars
 				editor.setOption('behavioursEnabled', scope.autoPairDelimiters || false)
 				editor.setOption('wrapBehavioursEnabled', false)
@@ -269,6 +268,14 @@ define [
 						"font-size": value + "px"
 					})
 
+				scope.$watch "fontFamily", (value) ->
+					if value?
+						editor.setOption('fontFamily', value)
+
+				scope.$watch "lineHeight", (value) ->
+					if value?
+						editor.container.style.lineHeight = value
+
 				scope.$watch "sharejsDoc", (sharejs_doc, old_sharejs_doc) ->
 					if old_sharejs_doc?
 						detachFromAce(old_sharejs_doc)