Configure line height and font family separately for v2

This commit is contained in:
James Allen 2018-05-04 14:05:20 +01:00
parent 7e250be66d
commit 1aadd7d369
4 changed files with 16 additions and 3 deletions

View file

@ -321,5 +321,7 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
chatMessageBorderLightness : if isOl then "40%" else "70%" chatMessageBorderLightness : if isOl then "40%" else "70%"
chatMessageBgSaturation : if isOl then "85%" else "60%" chatMessageBgSaturation : if isOl then "85%" else "60%"
chatMessageBgLightness : if isOl then "40%" else "97%" 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 renderAnnouncements : !isOl
next() next()

View file

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

View file

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

View file

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