From 1aadd7d3690d7ac5cff4bdf0f62366881bc0fd21 Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 4 May 2018 14:05:20 +0100 Subject: [PATCH] Configure line height and font family separately for v2 --- .../app/coffee/infrastructure/ExpressLocals.coffee | 2 ++ services/web/app/views/project/editor/editor.pug | 2 ++ services/web/public/coffee/ide.coffee | 2 ++ .../coffee/ide/editor/directives/aceEditor.coffee | 13 ++++++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index 37cce62ddd..11fc1d157e 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/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() diff --git a/services/web/app/views/project/editor/editor.pug b/services/web/app/views/project/editor/editor.pug index fed1889d79..08fdfa898e 100644 --- a/services/web/app/views/project/editor/editor.pug +++ b/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) diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index 078202655f..053db2396f 100644 --- a/services/web/public/coffee/ide.coffee +++ b/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 diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index 97fca8a359..b79681ddcb 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/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)