Component stack fixes
This commit is contained in:
@@ -14,7 +14,6 @@ export class ComponentGroup {
|
|||||||
private application: WebApplication
|
private application: WebApplication
|
||||||
changeObservers: any[] = []
|
changeObservers: any[] = []
|
||||||
activeComponents: UuidString[] = []
|
activeComponents: UuidString[] = []
|
||||||
|
|
||||||
|
|
||||||
constructor(application: WebApplication) {
|
constructor(application: WebApplication) {
|
||||||
this.application = application;
|
this.application = application;
|
||||||
@@ -86,6 +85,7 @@ export class ComponentGroup {
|
|||||||
*/
|
*/
|
||||||
public addChangeObserver(callback: () => void) {
|
public addChangeObserver(callback: () => void) {
|
||||||
this.changeObservers.push(callback);
|
this.changeObservers.push(callback);
|
||||||
|
callback();
|
||||||
return () => {
|
return () => {
|
||||||
removeFromArray(this.changeObservers, callback);
|
removeFromArray(this.changeObservers, callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export class Editor {
|
|||||||
if (matchingNote) {
|
if (matchingNote) {
|
||||||
this.isTemplateNote = false;
|
this.isTemplateNote = false;
|
||||||
this.note = matchingNote;
|
this.note = matchingNote;
|
||||||
this._onNoteValueChange!(matchingNote, source);
|
this._onNoteValueChange && this._onNoteValueChange!(matchingNote, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -242,15 +242,15 @@
|
|||||||
)
|
)
|
||||||
.sk-app-bar-item-column
|
.sk-app-bar-item-column
|
||||||
.sk-circle.small(
|
.sk-circle.small(
|
||||||
ng-class="{'info' : !component.hidden && component.active, 'neutral' : component.hidden || !component.active}"
|
ng-class="{'info' : !self.stackComponentHidden(component) && component.active, 'neutral' : self.stackComponentHidden(component) || !component.active}"
|
||||||
)
|
)
|
||||||
.sk-app-bar-item-column
|
.sk-app-bar-item-column
|
||||||
.sk-label {{component.name}}
|
.sk-label {{component.name}}
|
||||||
.sn-component
|
.sn-component
|
||||||
component-view.component-view.component-stack-item(
|
component-view.component-view.component-stack-item(
|
||||||
ng-repeat='component in self.activeStackComponents track by component.uuid',
|
ng-repeat='component in self.state.activeStackComponents track by component.uuid',
|
||||||
component-uuid='component.uuid',
|
component-uuid='component.uuid',
|
||||||
manual-dealloc='true',
|
manual-dealloc='true',
|
||||||
ng-show='!component.hidden',
|
ng-show='!self.stackComponentHidden(component)',
|
||||||
application='self.application'
|
application='self.application'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -263,10 +263,6 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
return this.getState().activeTagsComponent;
|
return this.getState().activeTagsComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
get activeStackComponents() {
|
|
||||||
return this.getState().activeStackComponents;
|
|
||||||
}
|
|
||||||
|
|
||||||
get componentGroup() {
|
get componentGroup() {
|
||||||
return this.application.componentGroup;
|
return this.application.componentGroup;
|
||||||
}
|
}
|
||||||
@@ -367,7 +363,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/** Reload componentStack in case new ones were added or removed */
|
/** Reload componentStack in case new ones were added or removed */
|
||||||
this.reloadComponentStackArray();
|
this.reloadComponentStack();
|
||||||
/** Observe editor changes to see if the current note should update its editor */
|
/** Observe editor changes to see if the current note should update its editor */
|
||||||
const editors = components.filter((component) => {
|
const editors = components.filter((component) => {
|
||||||
return component.isEditor();
|
return component.isEditor();
|
||||||
@@ -1008,17 +1004,12 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
ComponentArea.EditorStack,
|
ComponentArea.EditorStack,
|
||||||
ComponentArea.Editor
|
ComponentArea.Editor
|
||||||
],
|
],
|
||||||
activationHandler: (component) => {
|
|
||||||
if (component.area === ComponentArea.EditorStack) {
|
|
||||||
this.reloadComponentContext();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
contextRequestHandler: (component) => {
|
contextRequestHandler: (component) => {
|
||||||
const currentEditor = this.activeEditorComponent;
|
const currentEditor = this.activeEditorComponent;
|
||||||
if (
|
if (
|
||||||
component === currentEditor ||
|
component.uuid === currentEditor?.uuid ||
|
||||||
component === this.activeTagsComponent ||
|
component.uuid === this.activeTagsComponent?.uuid ||
|
||||||
this.activeStackComponents.includes(component)
|
Uuids(this.getState().activeStackComponents).includes(component.uuid)
|
||||||
) {
|
) {
|
||||||
return this.note;
|
return this.note;
|
||||||
}
|
}
|
||||||
@@ -1076,19 +1067,27 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadComponentStackArray() {
|
async reloadComponentStack() {
|
||||||
const components = this.application.componentManager!
|
const components = this.application.componentManager!
|
||||||
.componentsForArea(ComponentArea.EditorStack)
|
.componentsForArea(ComponentArea.EditorStack)
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
||||||
});
|
});
|
||||||
this.setEditorState({
|
await this.setEditorState({
|
||||||
allStackComponents: components
|
allStackComponents: components
|
||||||
});
|
});
|
||||||
|
this.reloadComponentContext();
|
||||||
|
/** component.active is a persisted state. So if we download a stack component
|
||||||
|
* whose .active is true, it doesn't mean it was explicitely activated by us. So
|
||||||
|
* we need to do that here. */
|
||||||
|
for(const component of components) {
|
||||||
|
if(component.active) {
|
||||||
|
this.componentGroup.activateComponent(component);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadComponentContext() {
|
reloadComponentContext() {
|
||||||
this.reloadComponentStackArray();
|
|
||||||
if (this.note) {
|
if (this.note) {
|
||||||
for (const component of this.getState().allStackComponents!) {
|
for (const component of this.getState().allStackComponents!) {
|
||||||
if (component.active) {
|
if (component.active) {
|
||||||
@@ -1099,19 +1098,23 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.application.componentManager!.contextItemDidChangeInArea(ComponentArea.NoteTags);
|
this.application.componentManager!.contextItemDidChangeInArea(ComponentArea.NoteTags);
|
||||||
this.application.componentManager!.contextItemDidChangeInArea(ComponentArea.EditorStack);
|
this.application.componentManager!.contextItemDidChangeInArea(ComponentArea.EditorStack);
|
||||||
this.application.componentManager!.contextItemDidChangeInArea(ComponentArea.Editor);
|
this.application.componentManager!.contextItemDidChangeInArea(ComponentArea.Editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
stackComponentHidden(component: SNComponent) {
|
||||||
|
return this.application.componentManager?.isComponentHidden(component);
|
||||||
|
}
|
||||||
|
|
||||||
async toggleStackComponentForCurrentItem(component: SNComponent) {
|
async toggleStackComponentForCurrentItem(component: SNComponent) {
|
||||||
const hidden = this.application.componentManager!.isComponentHidden(component);
|
const hidden = this.application.componentManager!.isComponentHidden(component);
|
||||||
if (hidden || !component.active) {
|
if (hidden || !component.active) {
|
||||||
this.application.componentManager!.setComponentHidden(component, false);
|
this.application.componentManager!.setComponentHidden(component, false);
|
||||||
await this.associateComponentWithCurrentNote(component);
|
await this.associateComponentWithCurrentNote(component);
|
||||||
if (!component.active) {
|
if (!component.active) {
|
||||||
this.application.componentManager!.activateComponent(component.uuid);
|
this.componentGroup!.activateComponent(component);
|
||||||
}
|
}
|
||||||
this.application.componentManager!.contextItemDidChangeInArea(ComponentArea.EditorStack);
|
this.application.componentManager!.contextItemDidChangeInArea(ComponentArea.EditorStack);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ class FooterViewCtrl extends PureViewCtrl {
|
|||||||
this.reloadPasscodeStatus();
|
this.reloadPasscodeStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
onAppEvent(eventName: ApplicationEvent) {
|
onAppEvent(eventName: ApplicationEvent) {
|
||||||
if (eventName === ApplicationEvent.KeyStatusChanged) {
|
if (eventName === ApplicationEvent.KeyStatusChanged) {
|
||||||
@@ -219,11 +218,8 @@ class FooterViewCtrl extends PureViewCtrl {
|
|||||||
}).sort((a, b) => {
|
}).sort((a, b) => {
|
||||||
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
||||||
});
|
});
|
||||||
const differ = filteredThemes.length !== this.themesWithIcons.length;
|
|
||||||
this.themesWithIcons = filteredThemes;
|
this.themesWithIcons = filteredThemes;
|
||||||
if (differ) {
|
this.reloadDockShortcuts();
|
||||||
this.reloadDockShortcuts();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -354,7 +350,6 @@ class FooterViewCtrl extends PureViewCtrl {
|
|||||||
icon: icon
|
icon: icon
|
||||||
} as DockShortcut);
|
} as DockShortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dockShortcuts = shortcuts.sort((a, b) => {
|
this.dockShortcuts = shortcuts.sort((a, b) => {
|
||||||
/** Circles first, then images */
|
/** Circles first, then images */
|
||||||
const aType = a.icon.type;
|
const aType = a.icon.type;
|
||||||
|
|||||||
210
dist/javascripts/app.js
vendored
210
dist/javascripts/app.js
vendored
File diff suppressed because one or more lines are too long
2
dist/javascripts/app.js.map
vendored
2
dist/javascripts/app.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user