From 3681d927b5b41beb0c5878e79312fbf53603e644 Mon Sep 17 00:00:00 2001 From: Miguel Castillo Date: Mon, 21 Jul 2014 22:05:26 -0400 Subject: [PATCH 1/2] Fonts api with themes integrated --- src/styles/brackets_codemirror_override.less | 9 + src/themes/FontCommandsManager.js | 37 --- src/view/ThemeManager.js | 21 -- src/view/ThemeSettings.js | 47 ++-- src/view/ThemeView.js | 51 +--- src/view/ViewCommandHandlers.js | 270 +++++++++++++++++-- 6 files changed, 282 insertions(+), 153 deletions(-) delete mode 100644 src/themes/FontCommandsManager.js diff --git a/src/styles/brackets_codemirror_override.less b/src/styles/brackets_codemirror_override.less index ab6a4ae80..57be5d351 100644 --- a/src/styles/brackets_codemirror_override.less +++ b/src/styles/brackets_codemirror_override.less @@ -75,6 +75,15 @@ border-bottom: 2px solid #78B2F2; } +/** + * These classes are set to inline-block because they are spans and they need block dimension properties when + * when calculation height and width. + */ +.CodeMirror-searching, +.CodeMirror-matchingtag, +.CodeMirror-matchingbracket { + display: inline-block; +} span.cm-keyword {color: @accent-keyword;} span.cm-atom {color: @accent-atom;} diff --git a/src/themes/FontCommandsManager.js b/src/themes/FontCommandsManager.js deleted file mode 100644 index a891c7f7b..000000000 --- a/src/themes/FontCommandsManager.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Brackets Themes Copyright (c) 2014 Miguel Castillo. - * @author Brad Gearon - * - * Licensed under MIT - */ - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global $, define, require */ - -define(function (require, exports, module) { - "use strict"; - - var ThemeSettings = require("view/ThemeSettings"), - ViewCommandHandlers = require("view/ViewCommandHandlers"), - PreferencesManager = require("preferences/PreferencesManager"), - prefs = PreferencesManager.getExtensionPrefs("themes"); - - function updateThemeFontSize(evt, adjustment, fontSize /*, lineHeight*/) { - prefs.set("fontSize", fontSize); - } - - function updateBracketsFontSize() { - var fontSize = prefs.get("fontSize"), - fontSizeNumeric = Number(fontSize.replace(/px|em/, "")), - fontSizeOffset = fontSizeNumeric - ThemeSettings._defaults.fontSize; - - if (!isNaN(fontSizeOffset)) { - PreferencesManager.setViewState("fontSizeAdjustment", fontSizeOffset); - PreferencesManager.setViewState("fontSizeStyle", fontSize); - } - } - - $(ViewCommandHandlers).on("fontSizeChange", updateThemeFontSize); - prefs.on("change", "fontSize", updateBracketsFontSize); - updateBracketsFontSize(); -}); diff --git a/src/view/ThemeManager.js b/src/view/ThemeManager.js index c67c28235..bf8e276d5 100644 --- a/src/view/ThemeManager.js +++ b/src/view/ThemeManager.js @@ -27,9 +27,6 @@ define(function (require, exports, module) { "use strict"; - // FontsCommandsManager will be going away soon when we add font size management in Brackets. - require("themes/FontCommandsManager"); - var _ = require("thirdparty/lodash"), FileSystem = require("filesystem/FileSystem"), FileUtils = require("file/FileUtils"), @@ -345,21 +342,6 @@ define(function (require, exports, module) { ThemeView.updateScrollbars(getCurrentTheme()); }); - prefs.on("change", "fontSize", function () { - refresh(); - ThemeView.updateFontSize(); - }); - - prefs.on("change", "lineHeight", function () { - refresh(); - ThemeView.updateLineHeight(); - }); - - prefs.on("change", "fontFamily", function () { - refresh(); - ThemeView.updateFontFamily(); - }); - // Monitor file changes. If the file that has changed is actually the currently loaded // theme, then we just reload the theme. This allows to live edit the theme FileSystem.on("change", function (evt, file) { @@ -377,9 +359,6 @@ define(function (require, exports, module) { }); - ThemeView.updateFonts(); - ThemeView.updateScrollbars(); - exports.refresh = refresh; exports.loadFile = loadFile; exports.loadPackage = loadPackage; diff --git a/src/view/ThemeSettings.js b/src/view/ThemeSettings.js index 98d17b6ef..0aaec0630 100644 --- a/src/view/ThemeSettings.js +++ b/src/view/ThemeSettings.js @@ -27,12 +27,13 @@ define(function (require, exports, module) { "use strict"; - var _ = require("thirdparty/lodash"), - Dialogs = require("widgets/Dialogs"), - Strings = require("strings"), - PreferencesManager = require("preferences/PreferencesManager"), - settingsTemplate = require("text!htmlContent/themes-settings.html"), - prefs = PreferencesManager.getExtensionPrefs("themes"); + var _ = require("thirdparty/lodash"), + Dialogs = require("widgets/Dialogs"), + Strings = require("strings"), + ViewCommandHandlers = require("view/ViewCommandHandlers"), + settingsTemplate = require("text!htmlContent/themes-settings.html"), + PreferencesManager = require("preferences/PreferencesManager"), + prefs = PreferencesManager.getExtensionPrefs("themes"); /** * @type {Object} @@ -44,9 +45,6 @@ define(function (require, exports, module) { * Object with all default values that can be configure via the settings UI */ var defaults = { - "fontSize": 12, - "lineHeight": 1.25, - "fontFamily": "'SourceCodePro-Medium', MS ゴシック, 'MS Gothic', monospace", "customScrollbars": true, "theme": "thor-light-theme" }; @@ -64,9 +62,16 @@ define(function (require, exports, module) { * @return {Object} a collection with all the settings */ function getValues() { - return _.transform(defaults, function (result, value, key) { + var result = {}; + + Object.keys(defaults).forEach(function (key) { result[key] = prefs.get(key); }); + + result.fontFamily = ViewCommandHandlers.getFontFamily(); + result.fontSize = ViewCommandHandlers.getFontSize(); + result.lineHeight = ViewCommandHandlers.getLineHeight(); + return result; } /** @@ -109,9 +114,21 @@ define(function (require, exports, module) { }); Dialogs.showModalDialogUsingTemplate($template).done(function (id) { + var setterFn; + if (id === "save") { + // Go through each new setting and apply it Object.keys(newSettings).forEach(function (setting) { - prefs.set(setting, newSettings[setting]); + if (prefs.hasOwnProperty(setting)) { + prefs.set(setting, newSettings[setting]); + } else { + // Figure out if the setting is in the ViewCommandHandlers, which means it is + // a font setting + setterFn = "set" + setting[0].toLocaleUpperCase() + setting.substr(1); + if (typeof ViewCommandHandlers[setterFn] === 'function') { + ViewCommandHandlers[setterFn](newSettings[setting]); + } + } }); } else if (id === "cancel") { // Make sure we revert any changes to theme selection @@ -133,21 +150,13 @@ define(function (require, exports, module) { */ function restore() { prefs.set("theme", defaults.theme); - prefs.set("fontSize", defaults.fontSize + "px"); - prefs.set("lineHeight", defaults.lineHeight); - prefs.set("fontFamily", defaults.fontFamily); prefs.set("customScrollbars", defaults.customScrollbars); } - prefs.definePreference("theme", "string", defaults.theme); - prefs.definePreference("fontSize", "string", defaults.fontSize + "px"); - prefs.definePreference("lineHeight", "number", defaults.lineHeight); - prefs.definePreference("fontFamily", "string", defaults.fontFamily); prefs.definePreference("customScrollbars", "boolean", defaults.customScrollbars); exports._setThemes = setThemes; - exports._defaults = defaults; exports.restore = restore; exports.showDialog = showDialog; }); diff --git a/src/view/ThemeView.js b/src/view/ThemeView.js index 958c2d838..e5d90c66f 100644 --- a/src/view/ThemeView.js +++ b/src/view/ThemeView.js @@ -34,48 +34,7 @@ define(function (require, exports, module) { PreferencesManager = require("preferences/PreferencesManager"), prefs = PreferencesManager.getExtensionPrefs("themes"); - - var templates = { - $lineHeight: $("").attr("id", propertyID); + var styleStr = StringUtils.format("{0}: {1}{2}", name, value, important ? " !important" : ""); + $style.html(cssRule + "{ " + styleStr + " }"); + + // Let's make sure we remove the already existing item from the DOM. + _removeDynamicProperty(propertyID); + $("head").append($style); + } /** * @private * Removes the styles used to update the font size */ function _removeDynamicFontSize() { - $("#" + DYNAMIC_FONT_STYLE_ID).remove(); + _removeDynamicProperty(DYNAMIC_FONT_STYLE_ID); } /** * @private * Add the styles used to update the font size - * @param {string} fontSizeStyle A string with the font size and the size unit + * @param {string} fontSize A string with the font size and the size unit */ - function _addDynamicFontSize(fontSizeStyle) { - var style = $("").attr("id", DYNAMIC_FONT_STYLE_ID); - style.html(".CodeMirror { font-size: " + fontSizeStyle + " !important; }"); - $("head").append(style); + function _addDynamicFontSize(fontSize) { + _addDynamicProperty(DYNAMIC_FONT_STYLE_ID, "font-size", fontSize, true); + } + + /** + * @private + * Removes the styles used to update the font family + */ + function _removeDynamicFontFamily() { + _removeDynamicProperty(DYNAMIC_FONT_FAMILY_ID); + } + + /** + * @private + * Add the styles used to update the font family + * @param {string} fontFamily A string with the font family + */ + function _addDynamicFontFamily(fontFamily) { + _addDynamicProperty(DYNAMIC_FONT_FAMILY_ID, "font-family", fontFamily); + } + + /** + * @private + * Removes the styles used to update the font family + */ + function _removeDynamicLineHeight() { + _removeDynamicProperty(DYNAMIC_LINE_HEIGHT_ID); + } + + /** + * @private + * Add the styles used to update the line height + * @param {string} lineHeight A string with the line height with size unit + */ + function _addDynamicLineHeight(lineHeight) { + _addDynamicProperty(DYNAMIC_LINE_HEIGHT_ID, "line-height", lineHeight, true, ".CodeMirror-lines > div"); } /** * @private * Sets the font size and restores the scroll position as best as possible. - * @param {string=} fontSizeStyle A string with the font size and the size unit + * @param {string=} fontSize A string with the font size and the size unit */ - function _setSizeAndRestoreScroll(fontSizeStyle) { + function _updateScroll(fontSize) { var editor = EditorManager.getCurrentFullEditor(), oldWidth = editor._codeMirror.defaultCharWidth(), - oldFontSize = $(".CodeMirror").css("font-size"), - newFontSize = "", + oldFontSize = prefs.get("fontSize"), + newFontSize = fontSize, delta = 0, adjustment = 0, scrollPos = editor.getScrollPos(), line = editor._codeMirror.lineAtHeight(scrollPos.y, "local"); - _removeDynamicFontSize(); - if (fontSizeStyle) { - _addDynamicFontSize(fontSizeStyle); - } - editor.refreshAll(); - delta = /em$/.test(oldFontSize) ? 10 : 1; - newFontSize = $(".CodeMirror").css("font-size"); adjustment = parseInt((parseFloat(newFontSize) - parseFloat(oldFontSize)) * delta, 10); + // Only adjust the scroll position if there was any adjustments to the font size. + // Otherwise there will be unintended scrolling. + // if (adjustment) { - $(exports).triggerHandler("fontSizeChange", [adjustment, newFontSize]); + editor.refreshAll(); } // Calculate the new scroll based on the old font sizes and scroll position @@ -141,7 +226,7 @@ define(function (require, exports, module) { * @return {boolean} true if adjustment occurred, false if it did not occur */ function _adjustFontSize(adjustment) { - var fsStyle = $(".CodeMirror").css("font-size"), + var fsStyle = prefs.get("fontSize"), validFont = /^[\d\.]+(px|em)$/; // Make sure that the font size is expressed in terms we can handle (px or em). If not, simply bail. @@ -162,9 +247,7 @@ define(function (require, exports, module) { return false; } - _setSizeAndRestoreScroll(fsStr); - PreferencesManager.setViewState("fontSizeStyle", fsStr); - + setFontSize(fsStr); return true; } @@ -180,10 +263,18 @@ define(function (require, exports, module) { /** Restores the font size to the original size */ function _handleRestoreFontSize() { - _setSizeAndRestoreScroll(); - PreferencesManager.setViewState("fontSizeStyle"); + setFontSize(DEFAULT_FONT_SIZE + "px"); } + /** + * Initializes the different settings that need to loaded + */ + function init() { + _addDynamicFontFamily(prefs.get("fontFamily")); + _addDynamicFontSize(prefs.get("fontSize")); + _addDynamicLineHeight(prefs.get("lineHeight")); + _updateUI(); + } /** * @private @@ -208,10 +299,10 @@ define(function (require, exports, module) { /** * Restores the font size using the saved style and migrates the old fontSizeAdjustment - * view state to the new fontSizeStyle, when required + * view state to the new fontSize, when required */ function restoreFontSize() { - var fsStyle = PreferencesManager.getViewState("fontSizeStyle"), + var fsStyle = prefs.get("fontSize"), fsAdjustment = PreferencesManager.getViewState("fontSizeAdjustment"); if (fsAdjustment) { @@ -221,7 +312,7 @@ define(function (require, exports, module) { if (!fsStyle) { // Migrate the old view state to the new one. fsStyle = (DEFAULT_FONT_SIZE + fsAdjustment) + "px"; - PreferencesManager.setViewState("fontSizeStyle", fsStyle); + prefs.set("fontSize", fsStyle); } } @@ -231,6 +322,14 @@ define(function (require, exports, module) { } } + /** + * Restores the font size, font family, and line height back to factory settings. + */ + function restoreFonts() { + setFontFamily(DEFAULT_FONT_FAMILY); + setFontSize(DEFAULT_FONT_SIZE + "px"); + setLineHeight(DEFAULT_LINE_HEIGHT); + } /** @@ -324,6 +423,110 @@ define(function (require, exports, module) { ThemeSettings.showDialog(); } + /** + * Font size setter to set the font size for the document editor + * @param {string} fontSize The font size with size unit as 'px' or 'em' + */ + function setFontSize(fontSize) { + var oldValue = prefs.get("fontSize"); + + if (oldValue === fontSize) { + return; + } + + _removeDynamicFontSize(); + if (fontSize) { + _addDynamicFontSize(fontSize); + } + + if (EditorManager.getCurrentFullEditor()) { + _updateScroll(fontSize); + } + + $(exports).triggerHandler("fontSizeChange", [fontSize, oldValue]); + prefs.set("fontSize", fontSize); + } + + /** + * Font size getter to get the current font size for the document editor + * @return {string} Font size with size unit as 'px' or 'em' + */ + function getFontSize() { + return prefs.get("fontSize"); + } + + + /** + * Font family setter to set the font family for the document editor + * @param {string} fontFamily The font family to be set. It can be a string with multiple comma separated fonts + */ + function setFontFamily(fontFamily) { + var editor = EditorManager.getCurrentFullEditor(), + oldValue = prefs.get("fontFamily"); + + if (oldValue === fontFamily) { + return; + } + + _removeDynamicFontFamily(); + if (fontFamily) { + _addDynamicFontFamily(fontFamily); + } + + $(exports).triggerHandler("fontFamilyChange", [fontFamily, oldValue]); + prefs.set("fontFamily", fontFamily); + + if (editor) { + editor.refreshAll(); + } + } + + /** + * Font family getter to get the currently configured font family for the document editor + * @return {string} The font family for the document editor + */ + function getFontFamily() { + return prefs.get("fontFamily"); + } + + + /** + * Line height setter to set the line height of the document editor + * @param {string} lineHeight The line height. The value is in 'em'. + */ + function setLineHeight(lineHeight) { + var editor = EditorManager.getCurrentFullEditor(), + oldValue = prefs.get("lineHeight"); + + // Make sure the incoming value is a number... Strip off any size units + lineHeight = parseFloat(lineHeight); + + if (oldValue === lineHeight) { + return; + } + + _removeDynamicLineHeight(); + if (lineHeight) { + _addDynamicLineHeight(lineHeight); + } + + $(exports).triggerHandler("lineHeightChange", [lineHeight, oldValue]); + prefs.set("lineHeight", lineHeight); + + if (editor) { + editor.refreshAll(); + } + } + + /** + * Line height getter to get the line height for the document editor + * @return {string} The line height with size unit as 'em' for the document editor + */ + function getLineHeight() { + return prefs.get("lineHeight"); + } + + /** * @private * Convert the old "fontSizeAdjustment" preference to the new view state. @@ -347,6 +550,10 @@ define(function (require, exports, module) { CommandManager.register(Strings.CMD_THEMES, Commands.CMD_THEMES_OPEN_SETTINGS, _handleThemeSettings); PreferencesManager.convertPreferences(module, {"fontSizeAdjustment": "user"}, true, _convertToNewViewState); + + prefs.definePreference("fontSize", "string", DEFAULT_FONT_SIZE + "px"); + prefs.definePreference("lineHeight", "number", DEFAULT_LINE_HEIGHT); + prefs.definePreference("fontFamily", "string", DEFAULT_FONT_FAMILY); // Update UI when opening or closing a document $(DocumentManager).on("currentDocumentChange", _updateUI); @@ -355,4 +562,11 @@ define(function (require, exports, module) { AppInit.appReady(_updateUI); exports.restoreFontSize = restoreFontSize; + exports.restoreFonts = restoreFonts; + exports.getFontSize = getFontSize; + exports.setFontSize = setFontSize; + exports.getFontFamily = getFontFamily; + exports.setFontFamily = setFontFamily; + exports.getLineHeight = getLineHeight; + exports.setLineHeight = setLineHeight; }); From da45d27d33184d9eee808134b3db246d2b7d36a0 Mon Sep 17 00:00:00 2001 From: Miguel Castillo Date: Mon, 21 Jul 2014 22:09:29 -0400 Subject: [PATCH 2/2] Fixed jslint complaints --- src/view/ViewCommandHandlers.js | 229 ++++++++++++++++---------------- 1 file changed, 115 insertions(+), 114 deletions(-) diff --git a/src/view/ViewCommandHandlers.js b/src/view/ViewCommandHandlers.js index 552f46e5d..372b8ecac 100644 --- a/src/view/ViewCommandHandlers.js +++ b/src/view/ViewCommandHandlers.js @@ -219,6 +219,110 @@ define(function (require, exports, module) { editor.setScrollPos(scrollPosX, scrollPosY); } + /** + * Font size setter to set the font size for the document editor + * @param {string} fontSize The font size with size unit as 'px' or 'em' + */ + function setFontSize(fontSize) { + var oldValue = prefs.get("fontSize"); + + if (oldValue === fontSize) { + return; + } + + _removeDynamicFontSize(); + if (fontSize) { + _addDynamicFontSize(fontSize); + } + + if (EditorManager.getCurrentFullEditor()) { + _updateScroll(fontSize); + } + + $(exports).triggerHandler("fontSizeChange", [fontSize, oldValue]); + prefs.set("fontSize", fontSize); + } + + /** + * Font size getter to get the current font size for the document editor + * @return {string} Font size with size unit as 'px' or 'em' + */ + function getFontSize() { + return prefs.get("fontSize"); + } + + + /** + * Font family setter to set the font family for the document editor + * @param {string} fontFamily The font family to be set. It can be a string with multiple comma separated fonts + */ + function setFontFamily(fontFamily) { + var editor = EditorManager.getCurrentFullEditor(), + oldValue = prefs.get("fontFamily"); + + if (oldValue === fontFamily) { + return; + } + + _removeDynamicFontFamily(); + if (fontFamily) { + _addDynamicFontFamily(fontFamily); + } + + $(exports).triggerHandler("fontFamilyChange", [fontFamily, oldValue]); + prefs.set("fontFamily", fontFamily); + + if (editor) { + editor.refreshAll(); + } + } + + /** + * Font family getter to get the currently configured font family for the document editor + * @return {string} The font family for the document editor + */ + function getFontFamily() { + return prefs.get("fontFamily"); + } + + + /** + * Line height setter to set the line height of the document editor + * @param {string} lineHeight The line height. The value is in 'em'. + */ + function setLineHeight(lineHeight) { + var editor = EditorManager.getCurrentFullEditor(), + oldValue = prefs.get("lineHeight"); + + // Make sure the incoming value is a number... Strip off any size units + lineHeight = parseFloat(lineHeight); + + if (oldValue === lineHeight) { + return; + } + + _removeDynamicLineHeight(); + if (lineHeight) { + _addDynamicLineHeight(lineHeight); + } + + $(exports).triggerHandler("lineHeightChange", [lineHeight, oldValue]); + prefs.set("lineHeight", lineHeight); + + if (editor) { + editor.refreshAll(); + } + } + + /** + * Line height getter to get the line height for the document editor + * @return {string} The line height with size unit as 'em' for the document editor + */ + function getLineHeight() { + return prefs.get("lineHeight"); + } + + /** * @private * Increases or decreases the editor's font size. @@ -266,16 +370,6 @@ define(function (require, exports, module) { setFontSize(DEFAULT_FONT_SIZE + "px"); } - /** - * Initializes the different settings that need to loaded - */ - function init() { - _addDynamicFontFamily(prefs.get("fontFamily")); - _addDynamicFontSize(prefs.get("fontSize")); - _addDynamicLineHeight(prefs.get("lineHeight")); - _updateUI(); - } - /** * @private * Updates the user interface appropriately based on whether or not a document is @@ -296,6 +390,16 @@ define(function (require, exports, module) { CommandManager.get(Commands.VIEW_RESTORE_FONT_SIZE).setEnabled(false); } } + + /** + * Initializes the different settings that need to loaded + */ + function init() { + _addDynamicFontFamily(prefs.get("fontFamily")); + _addDynamicFontSize(prefs.get("fontSize")); + _addDynamicLineHeight(prefs.get("lineHeight")); + _updateUI(); + } /** * Restores the font size using the saved style and migrates the old fontSizeAdjustment @@ -423,109 +527,6 @@ define(function (require, exports, module) { ThemeSettings.showDialog(); } - /** - * Font size setter to set the font size for the document editor - * @param {string} fontSize The font size with size unit as 'px' or 'em' - */ - function setFontSize(fontSize) { - var oldValue = prefs.get("fontSize"); - - if (oldValue === fontSize) { - return; - } - - _removeDynamicFontSize(); - if (fontSize) { - _addDynamicFontSize(fontSize); - } - - if (EditorManager.getCurrentFullEditor()) { - _updateScroll(fontSize); - } - - $(exports).triggerHandler("fontSizeChange", [fontSize, oldValue]); - prefs.set("fontSize", fontSize); - } - - /** - * Font size getter to get the current font size for the document editor - * @return {string} Font size with size unit as 'px' or 'em' - */ - function getFontSize() { - return prefs.get("fontSize"); - } - - - /** - * Font family setter to set the font family for the document editor - * @param {string} fontFamily The font family to be set. It can be a string with multiple comma separated fonts - */ - function setFontFamily(fontFamily) { - var editor = EditorManager.getCurrentFullEditor(), - oldValue = prefs.get("fontFamily"); - - if (oldValue === fontFamily) { - return; - } - - _removeDynamicFontFamily(); - if (fontFamily) { - _addDynamicFontFamily(fontFamily); - } - - $(exports).triggerHandler("fontFamilyChange", [fontFamily, oldValue]); - prefs.set("fontFamily", fontFamily); - - if (editor) { - editor.refreshAll(); - } - } - - /** - * Font family getter to get the currently configured font family for the document editor - * @return {string} The font family for the document editor - */ - function getFontFamily() { - return prefs.get("fontFamily"); - } - - - /** - * Line height setter to set the line height of the document editor - * @param {string} lineHeight The line height. The value is in 'em'. - */ - function setLineHeight(lineHeight) { - var editor = EditorManager.getCurrentFullEditor(), - oldValue = prefs.get("lineHeight"); - - // Make sure the incoming value is a number... Strip off any size units - lineHeight = parseFloat(lineHeight); - - if (oldValue === lineHeight) { - return; - } - - _removeDynamicLineHeight(); - if (lineHeight) { - _addDynamicLineHeight(lineHeight); - } - - $(exports).triggerHandler("lineHeightChange", [lineHeight, oldValue]); - prefs.set("lineHeight", lineHeight); - - if (editor) { - editor.refreshAll(); - } - } - - /** - * Line height getter to get the line height for the document editor - * @return {string} The line height with size unit as 'em' for the document editor - */ - function getLineHeight() { - return prefs.get("lineHeight"); - } - /** * @private @@ -553,7 +554,7 @@ define(function (require, exports, module) { prefs.definePreference("fontSize", "string", DEFAULT_FONT_SIZE + "px"); prefs.definePreference("lineHeight", "number", DEFAULT_LINE_HEIGHT); - prefs.definePreference("fontFamily", "string", DEFAULT_FONT_FAMILY); + prefs.definePreference("fontFamily", "string", DEFAULT_FONT_FAMILY); // Update UI when opening or closing a document $(DocumentManager).on("currentDocumentChange", _updateUI);