Editor component management simplification

This commit is contained in:
Mo Bitar
2020-04-15 13:11:10 -05:00
parent 0d44a2ff64
commit 1280c2ec52
7 changed files with 206 additions and 96 deletions

View File

@@ -8,7 +8,7 @@ import { ComponentMutator } from '@/../../../../snjs/dist/@types/models';
interface EditorMenuScope {
callback: (component: SNComponent) => void
selectedEditor: SNComponent
selectedEditorUuid: string
currentItem: SNItem
application: WebApplication
}
@@ -16,7 +16,7 @@ interface EditorMenuScope {
class EditorMenuCtrl extends PureViewCtrl implements EditorMenuScope {
callback!: () => (component: SNComponent) => void
selectedEditor!: SNComponent
selectedEditorUuid!: string
currentItem!: SNItem
application!: WebApplication
@@ -30,6 +30,17 @@ class EditorMenuCtrl extends PureViewCtrl implements EditorMenuScope {
};
}
public isEditorSelected(editor: SNComponent) {
if(!this.selectedEditorUuid) {
return false;
}
return this.selectedEditorUuid === editor.uuid;
}
public isEditorDefault(editor: SNComponent) {
return this.state.defaultEditor?.uuid === editor.uuid;
}
$onInit() {
super.$onInit();
const editors = this.application.componentManager!.componentsForArea(ComponentArea.Editor)
@@ -108,7 +119,7 @@ export class EditorMenu extends WebDirective {
this.bindToController = true;
this.scope = {
callback: '&',
selectedEditor: '=',
selectedEditorUuid: '=',
currentItem: '=',
application: '='
};