From f1a36f6cea96ad92bf2d306a7fe190c6f29346ab Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 24 Jun 2021 20:27:04 +0200 Subject: [PATCH] add keyboard shortcut for the edit button, #2036 --- src/public/app/services/root_command_executor.js | 7 +++++++ src/public/app/widgets/buttons/edit_button.js | 2 -- src/public/app/widgets/type_widgets/type_widget.js | 10 +++------- src/services/keyboard_actions.js | 6 ++++++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/public/app/services/root_command_executor.js b/src/public/app/services/root_command_executor.js index eaf937dff..804db3b6d 100644 --- a/src/public/app/services/root_command_executor.js +++ b/src/public/app/services/root_command_executor.js @@ -35,6 +35,13 @@ export default class RootCommandExecutor extends Component { } } + editReadOnlyNoteCommand() { + const noteContext = appContext.tabManager.getActiveContext(); + noteContext.readOnlyTemporarilyDisabled = true; + + appContext.triggerEvent("readOnlyTemporarilyDisabled", { noteContext }); + } + async cloneNoteIdsToCommand({noteIds}) { const d = await import("../dialogs/clone_to.js"); d.showDialog(noteIds); diff --git a/src/public/app/widgets/buttons/edit_button.js b/src/public/app/widgets/buttons/edit_button.js index b0c173785..4f99f0989 100644 --- a/src/public/app/widgets/buttons/edit_button.js +++ b/src/public/app/widgets/buttons/edit_button.js @@ -24,8 +24,6 @@ export default class EditButton extends ButtonWidget { // can't do this in isEnabled() since isReadOnly is async this.toggleInt(await this.noteContext.isReadOnly()); - console.log("await this.noteContext.isReadOnly()", await this.noteContext.isReadOnly()); - await super.refreshWithNote(note); } } diff --git a/src/public/app/widgets/type_widgets/type_widget.js b/src/public/app/widgets/type_widgets/type_widget.js index af2f0b821..f1f6841c1 100644 --- a/src/public/app/widgets/type_widgets/type_widget.js +++ b/src/public/app/widgets/type_widgets/type_widget.js @@ -41,15 +41,11 @@ export default class TypeWidget extends NoteContextAwareWidget { focus() {} - readOnlyTemporarilyDisabledEvent({noteContext}) { + async readOnlyTemporarilyDisabledEvent({noteContext}) { if (this.isNoteContext(noteContext.ntxId)) { - this.refresh(); - } - } + await this.refresh(); - readOnlyTemporarilyDisabledEvent({noteContext}) { - if (this.isNoteContext(noteContext.ntxId)) { - this.refresh(); + this.focus(); } } } diff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.js index b4e4bfa85..47c43acba 100644 --- a/src/services/keyboard_actions.js +++ b/src/services/keyboard_actions.js @@ -313,6 +313,12 @@ const DEFAULT_KEYBOARD_ACTIONS = [ description: "Opens the dialog to include a note", scope: "text-detail" }, + { + actionName: "editReadOnlyNote", + defaultShortcuts: [], + description: "Edit a read-only note", + scope: "window" + }, { separator: "Attributes (labels & relations)"