From 75f4df0fc80c81d66ea213f710f1b539eb9cbf25 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Tue, 21 Nov 2017 13:42:13 -0600 Subject: [PATCH] Switch editor after timeout, handle noteReady flag --- .../app/frontend/controllers/editor.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/frontend/controllers/editor.js b/app/assets/javascripts/app/frontend/controllers/editor.js index 009da5dd7..b976d90fb 100644 --- a/app/assets/javascripts/app/frontend/controllers/editor.js +++ b/app/assets/javascripts/app/frontend/controllers/editor.js @@ -51,20 +51,32 @@ angular.module('app.frontend') this.loadTagsString(); let associatedEditor = this.editorForNote(note); + if(associatedEditor) { + // setting note to not ready will remove the editor from view in a flash, + // so we only want to do this if switching between external editors + this.noteReady = false; + } else { + this.noteReady = true; + } + if(this.editorComponent && this.editorComponent != associatedEditor) { // Deactivate old editor componentManager.deactivateComponent(this.editorComponent); + this.editorComponent = null; } // Activate new editor if it's different from the one currently activated if(associatedEditor && associatedEditor != this.editorComponent) { - this.enableComponent(associatedEditor); + // switch after timeout, so that note data isnt posted to current editor + $timeout(() => { + this.enableComponent(associatedEditor); + this.editorComponent = associatedEditor; + this.noteReady = true; + }) + } else { + this.noteReady = true; } - this.editorComponent = associatedEditor; - - this.noteReady = true; - if(note.safeText().length == 0 && note.dummy) { this.focusTitle(100); }