mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Allow font family and line height to be user configurable
This commit is contained in:
parent
41654eb281
commit
dee96920b0
10 changed files with 85 additions and 18 deletions
|
@ -299,6 +299,8 @@ module.exports = ProjectController =
|
||||||
autoPairDelimiters: user.ace.autoPairDelimiters
|
autoPairDelimiters: user.ace.autoPairDelimiters
|
||||||
pdfViewer : user.ace.pdfViewer
|
pdfViewer : user.ace.pdfViewer
|
||||||
syntaxValidation: user.ace.syntaxValidation
|
syntaxValidation: user.ace.syntaxValidation
|
||||||
|
fontFamily: user.ace.fontFamily
|
||||||
|
lineHeight: user.ace.lineHeight
|
||||||
}
|
}
|
||||||
trackChangesState: project.track_changes
|
trackChangesState: project.track_changes
|
||||||
privilegeLevel: privilegeLevel
|
privilegeLevel: privilegeLevel
|
||||||
|
|
|
@ -81,6 +81,11 @@ module.exports = UserController =
|
||||||
user.ace.pdfViewer = req.body.pdfViewer
|
user.ace.pdfViewer = req.body.pdfViewer
|
||||||
if req.body.syntaxValidation?
|
if req.body.syntaxValidation?
|
||||||
user.ace.syntaxValidation = 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)->
|
user.save (err)->
|
||||||
newEmail = req.body.email?.trim().toLowerCase()
|
newEmail = req.body.email?.trim().toLowerCase()
|
||||||
if !newEmail? or newEmail == user.email or req.externalAuthenticationSystemUsed()
|
if !newEmail? or newEmail == user.email or req.externalAuthenticationSystemUsed()
|
||||||
|
|
|
@ -183,6 +183,9 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
|
||||||
# Don't include the query string parameters, otherwise Google
|
# Don't include the query string parameters, otherwise Google
|
||||||
# treats ?nocdn=true as the canonical version
|
# treats ?nocdn=true as the canonical version
|
||||||
res.locals.currentUrl = Url.parse(req.originalUrl).pathname
|
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()
|
next()
|
||||||
|
|
||||||
webRouter.use (req, res, next)->
|
webRouter.use (req, res, next)->
|
||||||
|
@ -321,7 +324,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
|
defaultFontFamily : if isOl then 'lucida' else 'monaco'
|
||||||
editorLineHeight : if isOl then 1.6 else null
|
defaultLineHeight : if isOl then 'normal' else 'compact'
|
||||||
renderAnnouncements : !isOl
|
renderAnnouncements : !isOl
|
||||||
next()
|
next()
|
||||||
|
|
|
@ -23,11 +23,13 @@ UserSchema = new Schema
|
||||||
mode : {type : String, default: 'none'}
|
mode : {type : String, default: 'none'}
|
||||||
theme : {type : String, default: 'textmate'}
|
theme : {type : String, default: 'textmate'}
|
||||||
fontSize : {type : Number, default:'12'}
|
fontSize : {type : Number, default:'12'}
|
||||||
autoComplete: {type : Boolean, default: true}
|
autoComplete : {type : Boolean, default: true}
|
||||||
autoPairDelimiters: {type : Boolean, default: true}
|
autoPairDelimiters : {type : Boolean, default: true}
|
||||||
spellCheckLanguage : {type : String, default: "en"}
|
spellCheckLanguage : {type : String, default: "en"}
|
||||||
pdfViewer : {type : String, default: "pdfjs"}
|
pdfViewer : {type : String, default: "pdfjs"}
|
||||||
syntaxValidation : {type : Boolean}
|
syntaxValidation : {type : Boolean}
|
||||||
|
fontFamily : {type : String}
|
||||||
|
lineHeight : {type : String}
|
||||||
}
|
}
|
||||||
features : {
|
features : {
|
||||||
collaborators: { type:Number, default: Settings.defaultFeatures.collaborators }
|
collaborators: { type:Number, default: Settings.defaultFeatures.collaborators }
|
||||||
|
|
|
@ -69,8 +69,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"
|
font-family="settings.fontFamily || ui.defaultFontFamily"
|
||||||
line-height="ui.editorLineHeight"
|
line-height="settings.lineHeight || ui.defaultLineHeight"
|
||||||
)
|
)
|
||||||
|
|
||||||
!= moduleIncludes('editor:body', locals)
|
!= moduleIncludes('editor:body', locals)
|
||||||
|
|
|
@ -150,6 +150,26 @@ aside#left-menu.full-size(
|
||||||
each size in ['10','11','12','13','14','16','20','24']
|
each size in ['10','11','12','13','14','16','20','24']
|
||||||
option(value=size) #{size}px
|
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
|
.form-controls
|
||||||
label(for="pdfViewer") #{translate("pdf_viewer")}
|
label(for="pdfViewer") #{translate("pdf_viewer")}
|
||||||
select(
|
select(
|
||||||
|
|
|
@ -80,8 +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
|
defaultFontFamily: window.uiConfig.defaultFontFamily
|
||||||
editorLineHeight: window.uiConfig.editorLineHeight
|
defaultLineHeight: window.uiConfig.defaultLineHeight
|
||||||
}
|
}
|
||||||
$scope.user = window.user
|
$scope.user = window.user
|
||||||
|
|
||||||
|
|
|
@ -283,11 +283,26 @@ define [
|
||||||
|
|
||||||
scope.$watch "fontFamily", (value) ->
|
scope.$watch "fontFamily", (value) ->
|
||||||
if 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) ->
|
scope.$watch "lineHeight", (value) ->
|
||||||
if 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) ->
|
scope.$watch "sharejsDoc", (sharejs_doc, old_sharejs_doc) ->
|
||||||
if old_sharejs_doc?
|
if old_sharejs_doc?
|
||||||
|
|
|
@ -14,9 +14,14 @@ define [
|
||||||
|
|
||||||
@editor.on "changeSession", (e) =>
|
@editor.on "changeSession", (e) =>
|
||||||
@reset()
|
@reset()
|
||||||
@session = e.session
|
# @session = e.session
|
||||||
e.session.setUndoManager(@)
|
e.session.setUndoManager(@)
|
||||||
|
|
||||||
|
addSession: (session) ->
|
||||||
|
@session = session
|
||||||
|
|
||||||
|
addSelection: () ->
|
||||||
|
|
||||||
showUndoConflictWarning: () ->
|
showUndoConflictWarning: () ->
|
||||||
@$scope.$apply () =>
|
@$scope.$apply () =>
|
||||||
@$scope.undo.show_remote_warning = true
|
@$scope.undo.show_remote_warning = true
|
||||||
|
@ -31,7 +36,8 @@ define [
|
||||||
@undoStack = []
|
@undoStack = []
|
||||||
@redoStack = []
|
@redoStack = []
|
||||||
|
|
||||||
execute: (options) ->
|
add: (delta, allowMerge, session) ->
|
||||||
|
return
|
||||||
if @firstUpdate
|
if @firstUpdate
|
||||||
# The first update we receive is Ace setting the document, which we should
|
# The first update we receive is Ace setting the document, which we should
|
||||||
# ignore
|
# ignore
|
||||||
|
|
|
@ -8,6 +8,12 @@ define [
|
||||||
if $scope.settings.pdfViewer not in ["pdfjs", "native"]
|
if $scope.settings.pdfViewer not in ["pdfjs", "native"]
|
||||||
$scope.settings.pdfViewer = "pdfjs"
|
$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) ->
|
$scope.fontSizeAsStr = (newVal) ->
|
||||||
if newVal?
|
if newVal?
|
||||||
$scope.settings.fontSize = newVal
|
$scope.settings.fontSize = newVal
|
||||||
|
@ -41,6 +47,14 @@ define [
|
||||||
if syntaxValidation != oldSyntaxValidation
|
if syntaxValidation != oldSyntaxValidation
|
||||||
settings.saveSettings({syntaxValidation: syntaxValidation})
|
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) =>
|
$scope.$watch "project.spellCheckLanguage", (language, oldLanguage) =>
|
||||||
return if @ignoreUpdates
|
return if @ignoreUpdates
|
||||||
if oldLanguage? and language != oldLanguage
|
if oldLanguage? and language != oldLanguage
|
||||||
|
|
Loading…
Reference in a new issue