mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
Refactored use of ShortcutsRoute mixin on editor screen
no issue - mixins are deprecated in Ember so we want to remove their usage - pre-requisite for easier automation for switching to native class syntax - removed ShortcutsRoute mixin in favor of using the `{{on-key}}` modifier and standard controller action
This commit is contained in:
parent
c868dd6224
commit
d09db70f43
@ -247,6 +247,16 @@ export default Controller.extend({
|
||||
this.toggleProperty('showEmailPreviewModal');
|
||||
},
|
||||
|
||||
openPostPreview(keyboardEvent) {
|
||||
keyboardEvent?.preventDefault();
|
||||
|
||||
if (this.post.isDraft) {
|
||||
this.send('openPostPreviewModal');
|
||||
} else {
|
||||
window.open(this.post.previewUrl, '_blank', 'noopener');
|
||||
}
|
||||
},
|
||||
|
||||
openPostPreviewModal() {
|
||||
this.modals.open('modals/post-preview', {
|
||||
post: this.post,
|
||||
|
@ -1,22 +1,16 @@
|
||||
import $ from 'jquery';
|
||||
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
||||
import ShortcutsRoute from 'ghost-admin/mixins/shortcuts-route';
|
||||
import ctrlOrCmd from 'ghost-admin/utils/ctrl-or-cmd';
|
||||
import {htmlSafe} from '@ember/template';
|
||||
import {run} from '@ember/runloop';
|
||||
import {inject as service} from '@ember/service';
|
||||
|
||||
let generalShortcuts = {};
|
||||
generalShortcuts[`${ctrlOrCmd}+p`] = 'preview';
|
||||
|
||||
export default AuthenticatedRoute.extend(ShortcutsRoute, {
|
||||
export default AuthenticatedRoute.extend({
|
||||
feature: service(),
|
||||
notifications: service(),
|
||||
userAgent: service(),
|
||||
ui: service(),
|
||||
|
||||
classNames: ['editor'],
|
||||
shortcuts: generalShortcuts,
|
||||
|
||||
activate() {
|
||||
this._super(...arguments);
|
||||
@ -47,14 +41,6 @@ export default AuthenticatedRoute.extend(ShortcutsRoute, {
|
||||
});
|
||||
},
|
||||
|
||||
preview() {
|
||||
if (this.controller.post.isDraft) {
|
||||
this.controller.send('openPostPreviewModal');
|
||||
} else {
|
||||
window.open(this.controller.post.previewUrl, '_blank', 'noopener');
|
||||
}
|
||||
},
|
||||
|
||||
authorizationFailed() {
|
||||
this.controller.send('toggleReAuthenticateModal');
|
||||
},
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{#if this.post}}
|
||||
<div class="flex flex-row">
|
||||
<div class="flex flex-row" {{on-key "cmd+p" (action "openPostPreview")}}>
|
||||
<GhEditor
|
||||
@tagName="section"
|
||||
@class="gh-editor gh-view relative"
|
||||
|
Loading…
Reference in New Issue
Block a user