From c3bb99307533f7daa84a22e35470a4581bb4801a Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Sat, 20 Jan 2018 19:36:45 -0600 Subject: [PATCH] Spellcheck toggle option --- .../javascripts/app/controllers/editor.js | 17 ++++++++++------- .../javascripts/app/services/sysExtManager.js | 1 - app/assets/templates/editor.html.haml | 4 +++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/controllers/editor.js b/app/assets/javascripts/app/controllers/editor.js index 30690f118..a4aa8d740 100644 --- a/app/assets/javascripts/app/controllers/editor.js +++ b/app/assets/javascripts/app/controllers/editor.js @@ -25,6 +25,7 @@ angular.module('app') }) .controller('EditorCtrl', function ($sce, $timeout, authManager, $rootScope, actionsManager, syncManager, modelManager, themeManager, componentManager, storageManager) { + this.spellcheck = true; this.componentManager = componentManager; this.componentStack = []; @@ -247,13 +248,6 @@ angular.module('app') this.editingName = false; } - this.toggleFullScreen = function() { - this.fullscreen = !this.fullscreen; - if(this.fullscreen) { - this.focusEditor(0); - } - } - this.selectedMenuItem = function($event, hide) { if(hide) { this.showMenu = false; @@ -365,6 +359,7 @@ angular.module('app') this.loadPreferences = function() { this.monospaceFont = authManager.getUserPrefValue("monospaceFont", "monospace"); + this.spellcheck = authManager.getUserPrefValue("spellcheck", true); if(!document.getElementById("editor-content")) { // Elements have not yet loaded due to ng-if around wrapper @@ -406,6 +401,14 @@ angular.module('app') this[key] = !this[key]; authManager.setUserPrefValue(key, this[key], true); this.reloadFont(); + + if(key == "spellcheck") { + // Allows textarea to reload + this.noteReady = false; + $timeout(() => { + this.noteReady = true; + }, 0) + } } diff --git a/app/assets/javascripts/app/services/sysExtManager.js b/app/assets/javascripts/app/services/sysExtManager.js index b08738055..1ff562653 100644 --- a/app/assets/javascripts/app/services/sysExtManager.js +++ b/app/assets/javascripts/app/services/sysExtManager.js @@ -15,7 +15,6 @@ class SysExtManager { this.singletonManager.registerSingleton({content_type: "SN|Component", package_info: {identifier: extensionsIdentifier}}, (resolvedSingleton) => { // Resolved Singleton - console.log("Resolved extensions-manager", resolvedSingleton); var needsSync = false; if(isDesktopApplication()) { if(!resolvedSingleton.local_url) { diff --git a/app/assets/templates/editor.html.haml b/app/assets/templates/editor.html.haml index c7ea3d828..d946b4e07 100644 --- a/app/assets/templates/editor.html.haml +++ b/app/assets/templates/editor.html.haml @@ -30,6 +30,7 @@ .header %h4.title Display %menu-row{"title" => "'Monospace Font'", "circle" => "ctrl.monospaceFont ? 'success' : 'default'", "ng-click" => "ctrl.selectedMenuItem($event, true); ctrl.toggleKey('monospaceFont')"} + %menu-row{"title" => "'Spellcheck'", "circle" => "ctrl.spellcheck ? 'success' : 'default'", "ng-click" => "ctrl.selectedMenuItem($event, true); ctrl.toggleKey('spellcheck')"} .item{"ng-click" => "ctrl.onEditorMenuClick()", "ng-class" => "{'selected' : ctrl.showEditorMenu}", "click-outside" => "ctrl.showEditorMenu = false;", "is-open" => "ctrl.showEditorMenu"} .label Editor @@ -43,7 +44,8 @@ %panel-resizer.left{"panel-id" => "'editor-content'", "on-resize-finish" => "ctrl.onPanelResizeFinish","control" => "ctrl.resizeControl", "min-width" => 300, "property" => "'left'", "hoverable" => "true"} %component-view.component-view{"ng-if" => "ctrl.selectedEditor", "component" => "ctrl.selectedEditor"} %textarea.editable#note-text-editor{"ng-if" => "!ctrl.selectedEditor", "ng-model" => "ctrl.note.text", - "ng-change" => "ctrl.contentChanged()", "ng-trim" => "false", "ng-click" => "ctrl.clickedTextArea()", "ng-focus" => "ctrl.onContentFocus()", "dir" => "auto"} + "ng-change" => "ctrl.contentChanged()", "ng-trim" => "false", "ng-click" => "ctrl.clickedTextArea()", + "ng-focus" => "ctrl.onContentFocus()", "dir" => "auto", "ng-attr-spellcheck" => "{{ctrl.spellcheck}}"} {{ctrl.onSystemEditorLoad()}} %panel-resizer{"panel-id" => "'editor-content'", "on-resize-finish" => "ctrl.onPanelResizeFinish","control" => "ctrl.resizeControl", "min-width" => 300, "hoverable" => "true"}