Fixes issue where selecting an editor for a note on one platform doesn't update the live session on another platform

This commit is contained in:
Mo Bitar
2018-05-03 18:57:42 -05:00
parent a743cdc5c6
commit 45132f21d1
2 changed files with 21 additions and 2 deletions

View File

@@ -89,6 +89,25 @@ angular.module('app')
}
}
// Observe editor changes to see if the current note should update its editor
modelManager.addItemSyncObserver("component-manager", "SN|Component", (allItems, validItems, deletedItems, source) => {
if(!this.note) { return; }
var editors = allItems.filter(function(item) {
return item.isEditor();
});
// If no editors have changed
if(editors.length == 0) {
return;
}
// Look through editors again and find the most proper one
var editor = this.editorForNote(this.note);
this.selectedEditor = editor;
});
this.editorForNote = function(note) {
let editors = componentManager.componentsForArea("editor-editor");
for(var editor of editors) {