Skip to content

Commit 7e21867

Browse files
committed
added "re-render note" menu item & shortcut, closes zadam#1766
1 parent 6a70e0a commit 7e21867

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

libraries/ckeditor/ckeditor.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libraries/ckeditor/ckeditor.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/public/app/widgets/note_actions.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const TPL = `
6363
<span class="caret"></span>
6464
</button>
6565
<div class="dropdown-menu dropdown-menu-right">
66+
<a data-trigger-command="renderActiveNote" class="dropdown-item render-note-button">Re-render note</a>
6667
<div class="dropdown-item protect-button">
6768
Protect the note
6869
@@ -96,6 +97,7 @@ export default class NoteActionsWidget extends TabAwareWidget {
9697
this.overflowing();
9798

9899
this.$showSourceButton = this.$widget.find('.show-source-button');
100+
this.$renderNoteButton = this.$widget.find('.render-note-button');
99101

100102
this.$exportNoteButton = this.$widget.find('.export-note-button');
101103
this.$exportNoteButton.on("click", () => {
@@ -120,16 +122,22 @@ export default class NoteActionsWidget extends TabAwareWidget {
120122
}
121123

122124
refreshWithNote(note) {
123-
if (['text', 'relation-map', 'search', 'code'].includes(note.type)) {
124-
this.$showSourceButton.removeAttr('disabled');
125-
} else {
126-
this.$showSourceButton.attr('disabled', 'disabled');
127-
}
125+
this.toggleDisabled(this.$showSourceButton, ['text', 'relation-map', 'search', 'code'].includes(note.type));
126+
127+
this.$renderNoteButton.toggle(note.type === 'render');
128128

129129
this.$protectButton.toggle(!note.isProtected);
130130
this.$unprotectButton.toggle(!!note.isProtected);
131131
}
132132

133+
toggleDisabled($el, enable) {
134+
if (enable) {
135+
$el.removeAttr('disabled');
136+
} else {
137+
$el.attr('disabled', 'disabled');
138+
}
139+
}
140+
133141
entitiesReloadedEvent({loadResults}) {
134142
if (loadResults.isNoteReloaded(this.noteId)) {
135143
this.refresh();

src/public/app/widgets/note_detail.js

+6
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,10 @@ export default class NoteDetailWidget extends TabAwareWidget {
328328
async saveNoteDetailNowCommand() {
329329
await this.spacedUpdate.updateNowIfNecessary();
330330
}
331+
332+
renderActiveNoteEvent() {
333+
if (this.tabContext.isActive()) {
334+
this.refresh();
335+
}
336+
}
331337
}

src/services/keyboard_actions.js

+6
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,12 @@ const DEFAULT_KEYBOARD_ACTIONS = [
352352
defaultShortcuts: [],
353353
scope: "window"
354354
},
355+
{
356+
actionName: "renderActiveNote",
357+
defaultShortcuts: [],
358+
description: "Render (re-render) active note",
359+
scope: "window"
360+
},
355361
{
356362
actionName: "runActiveNote",
357363
defaultShortcuts: ["CommandOrControl+Enter"],

0 commit comments

Comments
 (0)