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() {
|
||||
|
||||
Reference in New Issue
Block a user