Allow font family and line height to be user configurable

This commit is contained in:
James Allen 2018-05-10 18:03:54 +01:00
parent 41654eb281
commit dee96920b0
10 changed files with 85 additions and 18 deletions

View file

@ -299,6 +299,8 @@ module.exports = ProjectController =
autoPairDelimiters: user.ace.autoPairDelimiters
pdfViewer : user.ace.pdfViewer
syntaxValidation: user.ace.syntaxValidation
fontFamily: user.ace.fontFamily
lineHeight: user.ace.lineHeight
}
trackChangesState: project.track_changes
privilegeLevel: privilegeLevel

View file

@ -81,6 +81,11 @@ module.exports = UserController =
user.ace.pdfViewer = req.body.pdfViewer
if req.body.syntaxValidation?
user.ace.syntaxValidation = req.body.syntaxValidation
if req.body.fontFamily?
user.ace.fontFamily = req.body.fontFamily
if req.body.lineHeight?
user.ace.lineHeight = req.body.lineHeight
user.save (err)->
newEmail = req.body.email?.trim().toLowerCase()
if !newEmail? or newEmail == user.email or req.externalAuthenticationSystemUsed()

View file

@ -183,6 +183,9 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
# Don't include the query string parameters, otherwise Google
# treats ?nocdn=true as the canonical version
res.locals.currentUrl = Url.parse(req.originalUrl).pathname
res.locals.capitalize = (string) ->
return "" if string.length == 0
return string.charAt(0).toUpperCase() + string.slice(1)
next()
webRouter.use (req, res, next)->
@ -321,7 +324,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
defaultFontFamily : if isOl then 'lucida' else 'monaco'
defaultLineHeight : if isOl then 'normal' else 'compact'
renderAnnouncements : !isOl
next()

View file

@ -20,14 +20,16 @@ UserSchema = new Schema
loginCount : {type : Number, default: 0}
holdingAccount : {type : Boolean, default: false}
ace : {
mode : {type : String, default: 'none'}
theme : {type : String, default: 'textmate'}
fontSize : {type : Number, default:'12'}
autoComplete: {type : Boolean, default: true}
autoPairDelimiters: {type : Boolean, default: true}
spellCheckLanguage : {type : String, default: "en"}
pdfViewer : {type : String, default: "pdfjs"}
syntaxValidation : {type : Boolean}
mode : {type : String, default: 'none'}
theme : {type : String, default: 'textmate'}
fontSize : {type : Number, default:'12'}
autoComplete : {type : Boolean, default: true}
autoPairDelimiters : {type : Boolean, default: true}
spellCheckLanguage : {type : String, default: "en"}
pdfViewer : {type : String, default: "pdfjs"}
syntaxValidation : {type : Boolean}
fontFamily : {type : String}
lineHeight : {type : String}
}
features : {
collaborators: { type:Number, default: Settings.defaultFeatures.collaborators }

View file

@ -69,8 +69,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"
font-family="settings.fontFamily || ui.defaultFontFamily"
line-height="settings.lineHeight || ui.defaultLineHeight"
)
!= moduleIncludes('editor:body', locals)

View file

@ -150,6 +150,26 @@ aside#left-menu.full-size(
each size in ['10','11','12','13','14','16','20','24']
option(value=size) #{size}px
.form-controls
label(for="fontFamily") #{translate("font_family")}
select(
name="fontFamily"
ng-model="settings.fontFamily"
)
option(value="", disabled) Default
each fontFamily in ['monaco', 'lucida']
option(value=fontFamily) #{capitalize(fontFamily)}
.form-controls
label(for="lineHeight") #{translate("line_height")}
select(
name="lineHeight"
ng-model="settings.lineHeight"
)
option(value="", disabled) Default
each lineHeight in ['compact', 'normal', 'wide']
option(value=lineHeight) #{translate(lineHeight)}
.form-controls
label(for="pdfViewer") #{translate("pdf_viewer")}
select(

View file

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

View file

@ -283,11 +283,26 @@ define [
scope.$watch "fontFamily", (value) ->
if value?
editor.setOption('fontFamily', value)
switch value
when 'monaco'
editor.setOption('fontFamily', '"Monaco", "Menlo", "Ubuntu Mono", "Consolas", "source-code-pro", monospace')
when 'lucida'
editor.setOption('fontFamily', '"Lucida Console", monospace')
else
editor.setOption('fontFamily', null)
scope.$watch "lineHeight", (value) ->
if value?
editor.container.style.lineHeight = value
switch value
when 'compact'
editor.container.style.lineHeight = 1.33
when 'normal'
editor.container.style.lineHeight = 1.6
when 'wide'
editor.container.style.lineHeight = 2
else
editor.container.style.lineHeight = 1.6
editor.renderer.updateFontSize()
scope.$watch "sharejsDoc", (sharejs_doc, old_sharejs_doc) ->
if old_sharejs_doc?

View file

@ -14,9 +14,14 @@ define [
@editor.on "changeSession", (e) =>
@reset()
@session = e.session
# @session = e.session
e.session.setUndoManager(@)
addSession: (session) ->
@session = session
addSelection: () ->
showUndoConflictWarning: () ->
@$scope.$apply () =>
@$scope.undo.show_remote_warning = true
@ -31,7 +36,8 @@ define [
@undoStack = []
@redoStack = []
execute: (options) ->
add: (delta, allowMerge, session) ->
return
if @firstUpdate
# The first update we receive is Ace setting the document, which we should
# ignore

View file

@ -8,6 +8,12 @@ define [
if $scope.settings.pdfViewer not in ["pdfjs", "native"]
$scope.settings.pdfViewer = "pdfjs"
if $scope.settings.fontFamily? and $scope.settings.fontFamily not in ["monaco", "lucida"]
delete $scope.settings.fontFamily
if $scope.settings.lineHeight? and $scope.settings.lineHeight not in ["compact", "normal", "wide"]
delete $scope.settings.lineHeight
$scope.fontSizeAsStr = (newVal) ->
if newVal?
$scope.settings.fontSize = newVal
@ -41,6 +47,14 @@ define [
if syntaxValidation != oldSyntaxValidation
settings.saveSettings({syntaxValidation: syntaxValidation})
$scope.$watch "settings.fontFamily", (fontFamily, oldFontFamily) =>
if fontFamily != oldFontFamily
settings.saveSettings({fontFamily: fontFamily})
$scope.$watch "settings.lineHeight", (lineHeight, oldLineHeight) =>
if lineHeight != oldLineHeight
settings.saveSettings({lineHeight: lineHeight})
$scope.$watch "project.spellCheckLanguage", (language, oldLanguage) =>
return if @ignoreUpdates
if oldLanguage? and language != oldLanguage