Default editors
This commit is contained in:
@@ -58,7 +58,7 @@ angular.module('app.frontend')
|
||||
|
||||
// Activate new editor if it's different from the one currently activated
|
||||
if(associatedEditor && associatedEditor != this.editorComponent) {
|
||||
componentManager.activateComponent(associatedEditor);
|
||||
this.enableComponent(associatedEditor);
|
||||
}
|
||||
|
||||
this.editorComponent = associatedEditor;
|
||||
@@ -85,6 +85,11 @@ angular.module('app.frontend')
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
|
||||
// No editor found for note. Use default editor, if note does not prefer system editor
|
||||
if(!note.getAppDataItem("prefersPlainEditor")) {
|
||||
return editors.filter((e) => {return e.isDefaultEditor()})[0];
|
||||
}
|
||||
}
|
||||
|
||||
this.selectedEditor = function(editorComponent) {
|
||||
@@ -98,7 +103,15 @@ angular.module('app.frontend')
|
||||
}
|
||||
|
||||
if(editorComponent) {
|
||||
this.enableComponentForCurrentItem(editorComponent);
|
||||
this.note.setAppDataItem("prefersPlainEditor", false);
|
||||
this.note.setDirty(true);
|
||||
this.enableComponent(editorComponent);
|
||||
this.associateComponentWithCurrentItem(editorComponent);
|
||||
} else {
|
||||
// Note prefers plain editor
|
||||
this.note.setAppDataItem("prefersPlainEditor", true);
|
||||
this.note.setDirty(true);
|
||||
syncManager.sync();
|
||||
}
|
||||
|
||||
this.editorComponent = editorComponent;
|
||||
@@ -410,12 +423,15 @@ angular.module('app.frontend')
|
||||
componentManager.contextItemDidChangeInArea("editor-editor");
|
||||
}
|
||||
|
||||
this.enableComponentForCurrentItem = function(component) {
|
||||
this.enableComponent = function(component) {
|
||||
componentManager.activateComponent(component);
|
||||
componentManager.associateComponentWithItem(component, this.note);
|
||||
componentManager.setEventFlowForComponent(component, 1);
|
||||
}
|
||||
|
||||
this.associateComponentWithCurrentItem = function(component) {
|
||||
componentManager.associateComponentWithItem(component, this.note);
|
||||
}
|
||||
|
||||
let alertKey = "displayed-component-disable-alert";
|
||||
this.disableComponentForCurrentItem = function(component, showAlert) {
|
||||
componentManager.disassociateComponentWithItem(component, this.note);
|
||||
|
||||
@@ -61,6 +61,14 @@ class Component extends Item {
|
||||
return "SN|Component";
|
||||
}
|
||||
|
||||
isEditor() {
|
||||
return this.area == "editor-editor";
|
||||
}
|
||||
|
||||
isDefaultEditor() {
|
||||
return this.getAppDataItem("defaultEditor") == true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
An associative component depends on being explicitly activated for a given item, compared to a dissaciative component,
|
||||
|
||||
@@ -133,6 +133,23 @@ class GlobalExtensionsMenu {
|
||||
}
|
||||
}
|
||||
|
||||
$scope.makeEditorDefault = function(component) {
|
||||
var currentDefault = componentManager.componentsForArea("editor-editor").filter((e) => {return e.isDefaultEditor()})[0];
|
||||
if(currentDefault) {
|
||||
currentDefault.setAppDataItem("defaultEditor", false);
|
||||
currentDefault.setDirty(true);
|
||||
}
|
||||
component.setAppDataItem("defaultEditor", true);
|
||||
component.setDirty(true);
|
||||
syncManager.sync();
|
||||
}
|
||||
|
||||
$scope.removeEditorDefault = function(component) {
|
||||
component.setAppDataItem("defaultEditor", false);
|
||||
component.setDirty(true);
|
||||
syncManager.sync();
|
||||
}
|
||||
|
||||
// Installation
|
||||
|
||||
$scope.submitInstallLink = function() {
|
||||
|
||||
@@ -14,5 +14,5 @@
|
||||
%li.menu-item{"ng-repeat" => "editor in editors", "ng-click" => "selectEditor($event, editor)"}
|
||||
%strong.red.medium{"ng-if" => "editor.conflict_of"} Conflicted copy
|
||||
%label.menu-item-title
|
||||
%span.inline.tinted.mr-10{"ng-if" => "selectedEditor === editor"} ✓
|
||||
{{editor.name}}
|
||||
%span.inline.tinted{"style" => "margin-left: 8px;", "ng-if" => "selectedEditor === editor"} ✓
|
||||
|
||||
@@ -99,8 +99,13 @@
|
||||
%h3
|
||||
%input.bold{"ng-if" => "component.rename", "ng-model" => "component.tempName", "ng-keyup" => "$event.keyCode == 13 && submitExtensionRename(component);", "mb-autofocus" => "true", "should-focus" => "true"}
|
||||
%span{"ng-if" => "!component.rename"} {{component.name}}
|
||||
%a{"ng-if" => "!componentManager.isComponentActive(component)", "ng-click" => "componentManager.activateComponent(component); $event.stopPropagation();"} Activate
|
||||
%a{"ng-if" => "componentManager.isComponentActive(component)", "ng-click" => "componentManager.deactivateComponent(component); $event.stopPropagation();"} Deactivate
|
||||
|
||||
%div{"ng-if" => "component.isEditor()"}
|
||||
%a{"ng-if" => "!component.isDefaultEditor()", "ng-click" => "makeEditorDefault(component); $event.stopPropagation();"} Make Default
|
||||
%a{"ng-if" => "component.isDefaultEditor()", "ng-click" => "removeEditorDefault(component); $event.stopPropagation();"} Remove Default
|
||||
%div{"ng-if" => "!component.isEditor()"}
|
||||
%a{"ng-if" => "!componentManager.isComponentActive(component)", "ng-click" => "componentManager.activateComponent(component); $event.stopPropagation();"} Activate
|
||||
%a{"ng-if" => "componentManager.isComponentActive(component)", "ng-click" => "componentManager.deactivateComponent(component); $event.stopPropagation();"} Deactivate
|
||||
.mt-3{"ng-if" => "component.showDetails"}
|
||||
.link-group
|
||||
%a{"ng-click" => "renameExtension(component); $event.stopPropagation();"} Rename
|
||||
|
||||
Reference in New Issue
Block a user