refactoring of layout finished

This commit is contained in:
zadam
2020-02-27 10:03:14 +01:00
parent 637010577b
commit 368d0c55da
13 changed files with 82 additions and 85 deletions
+10 -5
View File
@@ -17,7 +17,6 @@ class AppContext extends Component {
super(null);
this.layout = layout;
this.tabManager = new TabManager(this);
this.executors = [];
}
@@ -45,16 +44,22 @@ class AppContext extends Component {
this.triggerEvent(eventName);
});
this.tabManager = new TabManager();
this.executors = [
this.tabManager,
new DialogCommandExecutor(this),
new Entrypoints(this)
new DialogCommandExecutor(),
new Entrypoints()
];
this.children = [ rootWidget, ...this.executors ];
this.child(rootWidget);
for (const executor of this.executors) {
this.child(executor);
}
if (utils.isElectron()) {
this.children.push(new ZoomService(this));
this.child(new ZoomService());
import("./spell_check.js").then(spellCheckService => spellCheckService.initSpellCheck());
}
@@ -8,8 +8,8 @@ import appContext from "./app_context.js";
import Component from "../widgets/component.js";
export default class Entrypoints extends Component {
constructor(parent) {
super(parent);
constructor() {
super();
// hot keys are active also inside inputs and content editables
jQuery.hotkeys.options.filterInputAcceptingElements = false;
@@ -9,15 +9,12 @@ import hoistedNoteService from "./hoisted_note.js";
class TabContext extends Component {
/**
* @param {Component} parent
* @param {string|null} tabId
*/
constructor(parent, tabId = null) {
super(parent);
constructor(tabId = null) {
super();
this.tabId = tabId || utils.randomString(4);
this.triggerEvent('newTabOpened', {tabId: this.tabId});
}
async setNote(inputNotePath) {
@@ -6,11 +6,10 @@ import treeCache from "./tree_cache.js";
import treeService from "./tree.js";
import utils from "./utils.js";
import TabContext from "./tab_context.js";
import appContext from "./app_context.js";
export default class TabManager extends Component {
constructor(parent) {
super(parent);
constructor() {
super();
this.activeTabId = null;
@@ -183,8 +182,11 @@ export default class TabManager extends Component {
}
openEmptyTab(tabId) {
const tabContext = new TabContext(appContext, tabId);
this.children.push(tabContext);
const tabContext = new TabContext(tabId);
this.child(tabContext);
this.triggerEvent('newTabOpened', {tabId: this.tabId})
return tabContext;
}
+2 -2
View File
@@ -5,8 +5,8 @@ const MIN_ZOOM = 0.5;
const MAX_ZOOM = 2.0;
export default class ZoomService extends Component {
constructor(parent) {
super(parent);
constructor() {
super();
this.setZoomFactor(options.getFloat('zoomFactor'));
}