mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 13:52:10 +03:00
Moved cmd+shift+p
shortcut handling into <GhPublishmenu>
refs https://github.com/TryGhost/Team/issues/1169 We want all publish actions to trigger a confirmation modal. Currently that confirmation modal is controlled by `<GhPublishmenu>` which made it difficult to use from the route-induced publish shortcut. - removed old shortcut mixin approach from the editor route - added modern keyboard handler to a hidden element that is rendered any time the publish menu is present
This commit is contained in:
parent
80148c64db
commit
84b8d1be3b
@ -79,4 +79,10 @@
|
|||||||
@close={{this.closeEmailConfirmationModal}}
|
@close={{this.closeEmailConfirmationModal}}
|
||||||
@modifier="action wide"
|
@modifier="action wide"
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{!--
|
||||||
|
Workaround to have an always-shown element to attach key handlers to.
|
||||||
|
TODO: Move onto main element once converted to a glimmer component
|
||||||
|
--}}
|
||||||
|
<div class="hidden" {{on-key "cmd+shift+p" (action "publishFromShortcut")}}></div>
|
@ -3,6 +3,7 @@ import EmailFailedError from 'ghost-admin/errors/email-failed-error';
|
|||||||
import {action} from '@ember/object';
|
import {action} from '@ember/object';
|
||||||
import {computed} from '@ember/object';
|
import {computed} from '@ember/object';
|
||||||
import {or, reads} from '@ember/object/computed';
|
import {or, reads} from '@ember/object/computed';
|
||||||
|
import {schedule} from '@ember/runloop';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
import {task, timeout} from 'ember-concurrency';
|
import {task, timeout} from 'ember-concurrency';
|
||||||
|
|
||||||
@ -280,6 +281,25 @@ export default Component.extend({
|
|||||||
|
|
||||||
updateMemberCount(count) {
|
updateMemberCount(count) {
|
||||||
this.memberCount = count;
|
this.memberCount = count;
|
||||||
|
},
|
||||||
|
|
||||||
|
publishFromShortcut() {
|
||||||
|
// trigger blur for inputs and textareas to trigger any actions
|
||||||
|
// before attempting to save so we're saving after the result
|
||||||
|
if (document.activeElement?.matches('input[type="text"], textarea')) {
|
||||||
|
// trigger focusout so that it bubbles
|
||||||
|
const focusout = new Event('focusout');
|
||||||
|
document.activeElement.dispatchEvent(focusout);
|
||||||
|
|
||||||
|
// make sure blur event is triggered too
|
||||||
|
document.activeElement.blur();
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for actions to be triggered by the focusout/blur before saving
|
||||||
|
schedule('actions', this, function () {
|
||||||
|
this.send('setSaveType', 'published');
|
||||||
|
this.save.perform();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import {run} from '@ember/runloop';
|
|||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
|
|
||||||
let generalShortcuts = {};
|
let generalShortcuts = {};
|
||||||
generalShortcuts[`${ctrlOrCmd}+shift+p`] = 'publish';
|
|
||||||
generalShortcuts[`${ctrlOrCmd}+p`] = 'preview';
|
generalShortcuts[`${ctrlOrCmd}+p`] = 'preview';
|
||||||
|
|
||||||
export default AuthenticatedRoute.extend(ShortcutsRoute, {
|
export default AuthenticatedRoute.extend(ShortcutsRoute, {
|
||||||
@ -48,13 +47,6 @@ export default AuthenticatedRoute.extend(ShortcutsRoute, {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
publish() {
|
|
||||||
this._blurAndScheduleAction(function () {
|
|
||||||
this.controller.send('setSaveType', 'publish');
|
|
||||||
this.controller.send('save');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
preview() {
|
preview() {
|
||||||
if (this.controller.post.isDraft) {
|
if (this.controller.post.isDraft) {
|
||||||
this.controller.send('openPostPreviewModal');
|
this.controller.send('openPostPreviewModal');
|
||||||
|
Loading…
Reference in New Issue
Block a user