Merge branch 'release/10.7.1'
This commit is contained in:
@@ -87,27 +87,37 @@ export class IOService {
|
|||||||
this.activeModifiers.delete(modifier);
|
this.activeModifiers.delete(modifier);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleKeyDown = (event: KeyboardEvent): void => {
|
public handleComponentKeyDown = (
|
||||||
for (const modifier of this.modifiersForEvent(event)) {
|
modifier: KeyboardModifier | undefined
|
||||||
this.addActiveModifier(modifier);
|
): void => {
|
||||||
}
|
|
||||||
this.notifyObserver(event, KeyboardKeyEvent.Down);
|
|
||||||
};
|
|
||||||
|
|
||||||
handleComponentKeyDown = (modifier: KeyboardModifier | undefined): void => {
|
|
||||||
this.addActiveModifier(modifier);
|
this.addActiveModifier(modifier);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleKeyUp = (event: KeyboardEvent): void => {
|
public handleComponentKeyUp = (
|
||||||
for (const modifier of this.modifiersForEvent(event)) {
|
modifier: KeyboardModifier | undefined
|
||||||
this.removeActiveModifier(modifier);
|
): void => {
|
||||||
}
|
this.removeActiveModifier(modifier);
|
||||||
|
};
|
||||||
|
|
||||||
|
private handleKeyDown = (event: KeyboardEvent): void => {
|
||||||
|
this.updateAllModifiersFromEvent(event);
|
||||||
|
this.notifyObserver(event, KeyboardKeyEvent.Down);
|
||||||
|
};
|
||||||
|
|
||||||
|
private handleKeyUp = (event: KeyboardEvent): void => {
|
||||||
|
this.updateAllModifiersFromEvent(event);
|
||||||
this.notifyObserver(event, KeyboardKeyEvent.Up);
|
this.notifyObserver(event, KeyboardKeyEvent.Up);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleComponentKeyUp = (modifier: KeyboardModifier | undefined): void => {
|
private updateAllModifiersFromEvent(event: KeyboardEvent): void {
|
||||||
this.removeActiveModifier(modifier);
|
for (const modifier of Object.values(KeyboardModifier)) {
|
||||||
};
|
if (event.getModifierState(modifier)) {
|
||||||
|
this.addActiveModifier(modifier);
|
||||||
|
} else {
|
||||||
|
this.removeActiveModifier(modifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handleWindowBlur = (): void => {
|
handleWindowBlur = (): void => {
|
||||||
for (const modifier of this.activeModifiers) {
|
for (const modifier of this.activeModifiers) {
|
||||||
@@ -136,7 +146,7 @@ export class IOService {
|
|||||||
return eventModifiers;
|
return eventModifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
eventMatchesKeyAndModifiers(
|
private eventMatchesKeyAndModifiers(
|
||||||
event: KeyboardEvent,
|
event: KeyboardEvent,
|
||||||
key: KeyboardKey | string,
|
key: KeyboardKey | string,
|
||||||
modifiers: KeyboardModifier[] = []
|
modifiers: KeyboardModifier[] = []
|
||||||
|
|||||||
@@ -114,42 +114,43 @@ export class NotesState {
|
|||||||
|
|
||||||
async selectNote(uuid: UuidString, userTriggered?: boolean): Promise<void> {
|
async selectNote(uuid: UuidString, userTriggered?: boolean): Promise<void> {
|
||||||
const note = this.application.findItem(uuid) as SNNote;
|
const note = this.application.findItem(uuid) as SNNote;
|
||||||
|
if (!note) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const hasMeta = this.io.activeModifiers.has(KeyboardModifier.Meta);
|
const hasMeta = this.io.activeModifiers.has(KeyboardModifier.Meta);
|
||||||
const hasCtrl = this.io.activeModifiers.has(KeyboardModifier.Ctrl);
|
const hasCtrl = this.io.activeModifiers.has(KeyboardModifier.Ctrl);
|
||||||
const hasShift = this.io.activeModifiers.has(KeyboardModifier.Shift);
|
const hasShift = this.io.activeModifiers.has(KeyboardModifier.Shift);
|
||||||
|
|
||||||
if (note) {
|
if (userTriggered && (hasMeta || hasCtrl)) {
|
||||||
if (userTriggered && (hasMeta || hasCtrl)) {
|
if (this.selectedNotes[uuid]) {
|
||||||
if (this.selectedNotes[uuid]) {
|
delete this.selectedNotes[uuid];
|
||||||
delete this.selectedNotes[uuid];
|
} else if (await this.application.authorizeNoteAccess(note)) {
|
||||||
} else if (await this.application.authorizeNoteAccess(note)) {
|
runInAction(() => {
|
||||||
runInAction(() => {
|
this.selectedNotes[uuid] = note;
|
||||||
this.selectedNotes[uuid] = note;
|
this.lastSelectedNote = note;
|
||||||
this.lastSelectedNote = note;
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (userTriggered && hasShift) {
|
|
||||||
await this.selectNotesRange(note);
|
|
||||||
} else {
|
|
||||||
const shouldSelectNote =
|
|
||||||
this.selectedNotesCount > 1 || !this.selectedNotes[uuid];
|
|
||||||
if (
|
|
||||||
shouldSelectNote &&
|
|
||||||
(await this.application.authorizeNoteAccess(note))
|
|
||||||
) {
|
|
||||||
runInAction(() => {
|
|
||||||
this.selectedNotes = {
|
|
||||||
[note.uuid]: note,
|
|
||||||
};
|
|
||||||
this.lastSelectedNote = note;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else if (userTriggered && hasShift) {
|
||||||
|
await this.selectNotesRange(note);
|
||||||
|
} else {
|
||||||
|
const shouldSelectNote =
|
||||||
|
this.selectedNotesCount > 1 || !this.selectedNotes[uuid];
|
||||||
|
if (
|
||||||
|
shouldSelectNote &&
|
||||||
|
(await this.application.authorizeNoteAccess(note))
|
||||||
|
) {
|
||||||
|
runInAction(() => {
|
||||||
|
this.selectedNotes = {
|
||||||
|
[note.uuid]: note,
|
||||||
|
};
|
||||||
|
this.lastSelectedNote = note;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.selectedNotesCount === 1) {
|
if (this.selectedNotesCount === 1) {
|
||||||
await this.openNote(Object.keys(this.selectedNotes)[0]);
|
await this.openNote(Object.keys(this.selectedNotes)[0]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -333,9 +333,14 @@ export class NotesViewState {
|
|||||||
if (this.isFiltering) {
|
if (this.isFiltering) {
|
||||||
title = this.noteFilterText;
|
title = this.noteFilterText;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.appState.openNewNote(title);
|
await this.appState.openNewNote(title);
|
||||||
this.reloadNotes();
|
this.application.performFunctionWithAngularDigestCycleAfterAsyncChange(
|
||||||
this.appState.noteTags.reloadTags();
|
() => {
|
||||||
|
this.reloadNotes();
|
||||||
|
this.appState.noteTags.reloadTags();
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
createPlaceholderNote = () => {
|
createPlaceholderNote = () => {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export class WebApplication extends SNApplication {
|
|||||||
platform: Platform,
|
platform: Platform,
|
||||||
identifier: string,
|
identifier: string,
|
||||||
private $compile: angular.ICompileService,
|
private $compile: angular.ICompileService,
|
||||||
|
private $timeout: angular.ITimeoutService,
|
||||||
scope: angular.IScope,
|
scope: angular.IScope,
|
||||||
defaultSyncServerHost: string,
|
defaultSyncServerHost: string,
|
||||||
public bridge: Bridge,
|
public bridge: Bridge,
|
||||||
@@ -104,6 +105,16 @@ export class WebApplication extends SNApplication {
|
|||||||
this.webServices = services;
|
this.webServices = services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a UI change is made in an async function, Angular might not re-render the change.
|
||||||
|
* Use this function to force re-render the UI after an async function has made UI changes.
|
||||||
|
*/
|
||||||
|
public performFunctionWithAngularDigestCycleAfterAsyncChange(
|
||||||
|
func: () => void
|
||||||
|
) {
|
||||||
|
this.$timeout(func);
|
||||||
|
}
|
||||||
|
|
||||||
public getAppState(): AppState {
|
public getAppState(): AppState {
|
||||||
return this.webServices.appState;
|
return this.webServices.appState;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export class ApplicationGroup extends SNApplicationGroup {
|
|||||||
platform,
|
platform,
|
||||||
descriptor.identifier,
|
descriptor.identifier,
|
||||||
this.$compile,
|
this.$compile,
|
||||||
|
this.$timeout,
|
||||||
scope,
|
scope,
|
||||||
this.defaultSyncServerHost,
|
this.defaultSyncServerHost,
|
||||||
this.bridge,
|
this.bridge,
|
||||||
|
|||||||
Reference in New Issue
Block a user