mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05: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
3 changed files with 12 additions and 16 deletions
|
@ -247,6 +247,16 @@ export default Controller.extend({
|
||||||
this.toggleProperty('showEmailPreviewModal');
|
this.toggleProperty('showEmailPreviewModal');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
openPostPreview(keyboardEvent) {
|
||||||
|
keyboardEvent?.preventDefault();
|
||||||
|
|
||||||
|
if (this.post.isDraft) {
|
||||||
|
this.send('openPostPreviewModal');
|
||||||
|
} else {
|
||||||
|
window.open(this.post.previewUrl, '_blank', 'noopener');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
openPostPreviewModal() {
|
openPostPreviewModal() {
|
||||||
this.modals.open('modals/post-preview', {
|
this.modals.open('modals/post-preview', {
|
||||||
post: this.post,
|
post: this.post,
|
||||||
|
|
|
@ -1,22 +1,16 @@
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
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 {htmlSafe} from '@ember/template';
|
||||||
import {run} from '@ember/runloop';
|
import {run} from '@ember/runloop';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
|
|
||||||
let generalShortcuts = {};
|
export default AuthenticatedRoute.extend({
|
||||||
generalShortcuts[`${ctrlOrCmd}+p`] = 'preview';
|
|
||||||
|
|
||||||
export default AuthenticatedRoute.extend(ShortcutsRoute, {
|
|
||||||
feature: service(),
|
feature: service(),
|
||||||
notifications: service(),
|
notifications: service(),
|
||||||
userAgent: service(),
|
userAgent: service(),
|
||||||
ui: service(),
|
ui: service(),
|
||||||
|
|
||||||
classNames: ['editor'],
|
classNames: ['editor'],
|
||||||
shortcuts: generalShortcuts,
|
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
this._super(...arguments);
|
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() {
|
authorizationFailed() {
|
||||||
this.controller.send('toggleReAuthenticateModal');
|
this.controller.send('toggleReAuthenticateModal');
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{#if this.post}}
|
{{#if this.post}}
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row" {{on-key "cmd+p" (action "openPostPreview")}}>
|
||||||
<GhEditor
|
<GhEditor
|
||||||
@tagName="section"
|
@tagName="section"
|
||||||
@class="gh-editor gh-view relative"
|
@class="gh-editor gh-view relative"
|
||||||
|
|
Loading…
Add table
Reference in a new issue