added "re-render note" menu item & shortcut, closes #1766

This commit is contained in:
zadam 2021-03-19 22:34:56 +01:00
parent 6a70e0ab97
commit 7e2186721f
5 changed files with 27 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -63,6 +63,7 @@ const TPL = `
<span class="caret"></span>
</button>
<div class="dropdown-menu dropdown-menu-right">
<a data-trigger-command="renderActiveNote" class="dropdown-item render-note-button">Re-render note</a>
<div class="dropdown-item protect-button">
Protect the note
@ -96,6 +97,7 @@ export default class NoteActionsWidget extends TabAwareWidget {
this.overflowing();
this.$showSourceButton = this.$widget.find('.show-source-button');
this.$renderNoteButton = this.$widget.find('.render-note-button');
this.$exportNoteButton = this.$widget.find('.export-note-button');
this.$exportNoteButton.on("click", () => {
@ -120,16 +122,22 @@ export default class NoteActionsWidget extends TabAwareWidget {
}
refreshWithNote(note) {
if (['text', 'relation-map', 'search', 'code'].includes(note.type)) {
this.$showSourceButton.removeAttr('disabled');
} else {
this.$showSourceButton.attr('disabled', 'disabled');
}
this.toggleDisabled(this.$showSourceButton, ['text', 'relation-map', 'search', 'code'].includes(note.type));
this.$renderNoteButton.toggle(note.type === 'render');
this.$protectButton.toggle(!note.isProtected);
this.$unprotectButton.toggle(!!note.isProtected);
}
toggleDisabled($el, enable) {
if (enable) {
$el.removeAttr('disabled');
} else {
$el.attr('disabled', 'disabled');
}
}
entitiesReloadedEvent({loadResults}) {
if (loadResults.isNoteReloaded(this.noteId)) {
this.refresh();

View File

@ -328,4 +328,10 @@ export default class NoteDetailWidget extends TabAwareWidget {
async saveNoteDetailNowCommand() {
await this.spacedUpdate.updateNowIfNecessary();
}
renderActiveNoteEvent() {
if (this.tabContext.isActive()) {
this.refresh();
}
}
}

View File

@ -352,6 +352,12 @@ const DEFAULT_KEYBOARD_ACTIONS = [
defaultShortcuts: [],
scope: "window"
},
{
actionName: "renderActiveNote",
defaultShortcuts: [],
description: "Render (re-render) active note",
scope: "window"
},
{
actionName: "runActiveNote",
defaultShortcuts: ["CommandOrControl+Enter"],