Fix editor component stack reload issue
This commit is contained in:
@@ -27,7 +27,6 @@ angular.module('app')
|
|||||||
|
|
||||||
this.spellcheck = true;
|
this.spellcheck = true;
|
||||||
this.componentManager = componentManager;
|
this.componentManager = componentManager;
|
||||||
this.componentStack = [];
|
|
||||||
|
|
||||||
$rootScope.$on("sync:taking-too-long", function(){
|
$rootScope.$on("sync:taking-too-long", function(){
|
||||||
this.syncTakingTooLong = true;
|
this.syncTakingTooLong = true;
|
||||||
@@ -425,16 +424,7 @@ angular.module('app')
|
|||||||
if(component.area === "note-tags") {
|
if(component.area === "note-tags") {
|
||||||
// Autocomplete Tags
|
// Autocomplete Tags
|
||||||
this.tagsComponent = component.active ? component : null;
|
this.tagsComponent = component.active ? component : null;
|
||||||
} else if(component.area == "editor-stack") {
|
} else if(component.area == "editor-editor") {
|
||||||
// Stack
|
|
||||||
if(component.active) {
|
|
||||||
if(!_.find(this.componentStack, component)) {
|
|
||||||
this.componentStack.push(component);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_.pull(this.componentStack, component);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Editor
|
// Editor
|
||||||
if(component.active && this.note && (component.isExplicitlyEnabledForItem(this.note) || component.isDefaultEditor())) {
|
if(component.active && this.note && (component.isExplicitlyEnabledForItem(this.note) || component.isDefaultEditor())) {
|
||||||
this.selectedEditor = component;
|
this.selectedEditor = component;
|
||||||
@@ -493,21 +483,17 @@ angular.module('app')
|
|||||||
}.bind(this)});
|
}.bind(this)});
|
||||||
|
|
||||||
this.reloadComponentContext = function() {
|
this.reloadComponentContext = function() {
|
||||||
|
// componentStack is used by the template to ng-repeat
|
||||||
|
this.componentStack = componentManager.componentsForArea("editor-stack");
|
||||||
|
for(var component of this.componentStack) {
|
||||||
|
if(component.active) {
|
||||||
|
component.hidden = component.isExplicitlyDisabledForItem(this.note);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentManager.contextItemDidChangeInArea("note-tags");
|
componentManager.contextItemDidChangeInArea("note-tags");
|
||||||
componentManager.contextItemDidChangeInArea("editor-stack");
|
componentManager.contextItemDidChangeInArea("editor-stack");
|
||||||
componentManager.contextItemDidChangeInArea("editor-editor");
|
componentManager.contextItemDidChangeInArea("editor-editor");
|
||||||
|
|
||||||
var stack = componentManager.componentsForArea("editor-stack");
|
|
||||||
for(var component of stack) {
|
|
||||||
if(component.active) {
|
|
||||||
var disabledForItem = component.isExplicitlyDisabledForItem(this.note);
|
|
||||||
if(disabledForItem) {
|
|
||||||
component.hidden = true;
|
|
||||||
} else {
|
|
||||||
component.hidden = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toggleStackComponentForCurrentItem = function(component) {
|
this.toggleStackComponentForCurrentItem = function(component) {
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ class EditorMenu {
|
|||||||
this.templateUrl = "directives/editor-menu.html";
|
this.templateUrl = "directives/editor-menu.html";
|
||||||
this.scope = {
|
this.scope = {
|
||||||
callback: "&",
|
callback: "&",
|
||||||
selectedEditor: "="
|
selectedEditor: "=",
|
||||||
|
currentItem: "="
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ class EditorMenu {
|
|||||||
currentDefault.setAppDataItem("defaultEditor", false);
|
currentDefault.setAppDataItem("defaultEditor", false);
|
||||||
currentDefault.setDirty(true);
|
currentDefault.setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
component.setAppDataItem("defaultEditor", true);
|
component.setAppDataItem("defaultEditor", true);
|
||||||
component.setDirty(true);
|
component.setDirty(true);
|
||||||
syncManager.sync("makeEditorDefault");
|
syncManager.sync("makeEditorDefault");
|
||||||
@@ -64,6 +66,10 @@ class EditorMenu {
|
|||||||
$scope.defaultEditor = null;
|
$scope.defaultEditor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.stackComponentEnabled = function(component) {
|
||||||
|
return component.active && !component.isExplicitlyDisabledForItem($scope.currentItem);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,11 @@
|
|||||||
|
|
||||||
%a.no-decoration{"ng-if" => "editors.length == 0", "href" => "https://standardnotes.org/extensions", "target" => "blank"}
|
%a.no-decoration{"ng-if" => "editors.length == 0", "href" => "https://standardnotes.org/extensions", "target" => "blank"}
|
||||||
%menu-row{"title" => "'Download More Editors'"}
|
%menu-row{"title" => "'Download More Editors'"}
|
||||||
|
|
||||||
.section{"ng-if" => "stack.length > 0"}
|
.section{"ng-if" => "stack.length > 0"}
|
||||||
.header
|
.header
|
||||||
%h4.title Editor Stack
|
%h4.title Editor Stack
|
||||||
%menu-row{"ng-repeat" => "component in stack", "ng-click" => "selectComponent($event, component)", "title" => "component.name",
|
%menu-row{"ng-repeat" => "component in stack", "ng-click" => "selectComponent($event, component)", "title" => "component.name",
|
||||||
"circle" => "component.active ? 'success' : 'danger'"}
|
"circle" => "stackComponentEnabled(component) ? 'success' : 'danger'"}
|
||||||
.column{"ng-if" => "component.conflict_of"}
|
.column{"ng-if" => "component.conflict_of"}
|
||||||
%strong.red.medium{"ng-if" => "component.conflict_of"} Conflicted copy
|
%strong.red.medium{"ng-if" => "component.conflict_of"} Conflicted copy
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
.item{"ng-click" => "ctrl.onEditorMenuClick()", "ng-class" => "{'selected' : ctrl.showEditorMenu}", "click-outside" => "ctrl.showEditorMenu = false;", "is-open" => "ctrl.showEditorMenu"}
|
.item{"ng-click" => "ctrl.onEditorMenuClick()", "ng-class" => "{'selected' : ctrl.showEditorMenu}", "click-outside" => "ctrl.showEditorMenu = false;", "is-open" => "ctrl.showEditorMenu"}
|
||||||
.label Editor
|
.label Editor
|
||||||
%editor-menu{"ng-if" => "ctrl.showEditorMenu", "callback" => "ctrl.editorMenuOnSelect", "selected-editor" => "ctrl.selectedEditor"}
|
%editor-menu{"ng-if" => "ctrl.showEditorMenu", "callback" => "ctrl.editorMenuOnSelect", "selected-editor" => "ctrl.selectedEditor", "current-item" => "ctrl.note"}
|
||||||
|
|
||||||
.item{"ng-click" => "ctrl.showExtensions = !ctrl.showExtensions; ctrl.showMenu = false; ctrl.showEditorMenu = false;", "ng-class" => "{'selected' : ctrl.showExtensions}", "click-outside" => "ctrl.showExtensions = false;", "is-open" => "ctrl.showExtensions"}
|
.item{"ng-click" => "ctrl.showExtensions = !ctrl.showExtensions; ctrl.showMenu = false; ctrl.showEditorMenu = false;", "ng-class" => "{'selected' : ctrl.showExtensions}", "click-outside" => "ctrl.showExtensions = false;", "is-open" => "ctrl.showExtensions"}
|
||||||
.label Actions
|
.label Actions
|
||||||
|
|||||||
Reference in New Issue
Block a user