High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
JavaScript campaigncampaign-managementemail-marketingemail-subscriptionlistmonkmailing-listnewsletternewsletter-managementnewsletter-softwareself-hostedsms-gatewaysmtptransactional-emails
Add Ctrl+S campaign save shortcut and add Ctrl+S and F9 to richtext editor.
Kailash Nadh343d405b0f4a
diff --git a/frontend/src/assets/style.scss b/frontend/src/assets/style.scssindex ade18198..dcaaf44a 100644--- a/frontend/src/assets/style.scss+++ b/frontend/src/assets/style.scss@@ -296,7 +296,7 @@ body.is-noscroll {}/* WYSIWYG / HTML code editor */-.html-editor, .markdown-editor {+.html-editor, .plain-editor textarea, .markdown-editor {position: relative;width: 100%;min-height: 250px;@@ -511,6 +511,23 @@ body.is-noscroll {&:focus:not(:active), &.is-focused:not(:active) {box-shadow: 0 0 0 0.2em rgba($primary, 0.25);}++ .has-kbd {+ display: inline-flex;+ align-items: center;+ gap: 0.5rem;+ }++ .kbd {+ font-size: 0.575rem;+ font-family: monospace;+ color: #cbdefa;+ border: 1px solid #5381c5;+ border-radius: 3px;+ padding: 1px 5px;+ display: inline-block;+ border-width: 1px 2px 2px 1px;+ }}&.is-light.is-outlined {diff --git a/frontend/src/components/Editor.vue b/frontend/src/components/Editor.vueindex 696e2413..0b87f4f6 100644--- a/frontend/src/components/Editor.vue+++ b/frontend/src/components/Editor.vue@@ -62,8 +62,9 @@</div></div><div class="column is- has-text-right">- <b-button @click="onTogglePreview" type="is-primary" icon-left="file-find-outline" data-cy="btn-preview">- {{ $t('campaigns.preview') }} (F9)+ <b-button @click="onTogglePreview" type="is-primary" icon-left="file-find-outline" data-cy="btn-preview"+ aria-keyshortcuts="F9">+ <span class="has-kbd">{{ $t('campaigns.preview') }} <span class="kbd">F9</span></span></b-button></div></div>@@ -254,11 +255,18 @@ export default {this.isPreviewing = !this.isPreviewing;},- onPreviewShortcut(e) {+ onKeyboardShortcut(e) {+ // On F9, toggle the preview.if (e.key === 'F9') {this.onTogglePreview();e.preventDefault();}++ // On Ctrl+S, trigger save.+ if (e.ctrlKey && e.key === 's') {+ this.$events.$emit('campaign.update');+ e.preventDefault();+ }},onVisualEditorChange({ body, source }) {@@ -347,11 +355,16 @@ export default {this.contentTypeSel = this.value.contentType;this.templateId = this.value.templateId;- window.addEventListener('keydown', this.onPreviewShortcut);+ window.addEventListener('keydown', this.onKeyboardShortcut);++ this.$events.$on('campaign.preview', () => {+ this.isPreviewing = true;+ });},beforeDestroy() {- window.removeEventListener('keydown', this.onPreviewShortcut);+ window.removeEventListener('keydown', this.onKeyboardShortcut);+ this.$events.$off('campaign.preview');},computed: {diff --git a/frontend/src/components/RichtextEditor.vue b/frontend/src/components/RichtextEditor.vueindex 5d92cb69..060a9322 100644--- a/frontend/src/components/RichtextEditor.vue+++ b/frontend/src/components/RichtextEditor.vue@@ -141,6 +141,13 @@ export default {urlconverter_callback: this.onEditorURLConvert,setup: (editor) => {+ editor.addShortcut('ctrl+s', 'Save content', () => {+ this.$events.$emit('campaign.update', {});+ });+ editor.addShortcut('f9', 'Preview', () => {+ this.$events.$emit('campaign.preview', {});+ });+editor.on('init', () => {editor.focus();this.onEditorDialogOpen(editor);diff --git a/frontend/src/main.js b/frontend/src/main.jsindex e75d00fb..46d11e67 100644--- a/frontend/src/main.js+++ b/frontend/src/main.js@@ -41,6 +41,7 @@ async function initConfig(app) {Vue.prototype.$utils = new Utils(i18n);Vue.prototype.$api = api;+ Vue.prototype.$events = app;// $can('permission:name') is used in the UI to check whether the logged in user// has a certain permission to toggle visibility of UI objects and UI functionality.diff --git a/frontend/src/views/Campaign.vue b/frontend/src/views/Campaign.vueindex 99824a5d..eae4e1a8 100644--- a/frontend/src/views/Campaign.vue+++ b/frontend/src/views/Campaign.vue@@ -27,8 +27,8 @@<b-field grouped v-if="isEditing && canEdit"><b-field expanded><b-button expanded @click="() => onSubmit('update')" :loading="loading.campaigns" type="is-primary"- icon-left="content-save-outline" data-cy="btn-save">- {{ $t('globals.buttons.saveChanges') }}+ icon-left="content-save-outline" data-cy="btn-save" aria-keyshortcuts="ctrl+s">+ <span class="has-kbd">{{ $t('globals.buttons.saveChanges') }} <span class="kbd">Ctrl+S</span></span></b-button></b-field><b-field expanded v-if="canStart">@@ -738,6 +738,14 @@ export default Vue.extend({this.$nextTick(() => {this.$refs.focus.focus();});++ this.$events.$on('campaign.update', () => {+ this.onSubmit('update');+ });+ },++ beforeDestroy() {+ this.$events.$off('campaign.update');},});</script>