mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
8ae28ed309
no issue - changes were made to the default editor to adjust the header nav options when accessed from an analytics page but they weren't copied over to the duplicate editor route/controller we use for the in-development lexical editor
87 lines
2.3 KiB
JavaScript
87 lines
2.3 KiB
JavaScript
import $ from 'jquery';
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
import {inject} from 'ghost-admin/decorators/inject';
|
|
import {run} from '@ember/runloop';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default AuthenticatedRoute.extend({
|
|
feature: service(),
|
|
notifications: service(),
|
|
router: service(),
|
|
ui: service(),
|
|
|
|
classNames: ['editor'],
|
|
|
|
config: inject(),
|
|
|
|
beforeModel() {
|
|
if (!this.config.editor?.url) {
|
|
return this.router.transitionTo('posts');
|
|
}
|
|
},
|
|
|
|
activate() {
|
|
this._super(...arguments);
|
|
this.ui.set('isFullScreen', true);
|
|
},
|
|
|
|
setupController(controller, model, transition) {
|
|
if (transition.from?.name === 'posts.analytics') {
|
|
controller.fromAnalytics = true;
|
|
}
|
|
},
|
|
|
|
resetController(controller) {
|
|
controller.fromAnalytics = false;
|
|
},
|
|
|
|
deactivate() {
|
|
this._super(...arguments);
|
|
this.ui.set('isFullScreen', false);
|
|
},
|
|
|
|
actions: {
|
|
save() {
|
|
this._blurAndScheduleAction(function () {
|
|
this.controller.send('save');
|
|
});
|
|
},
|
|
|
|
authorizationFailed() {
|
|
this.controller.send('toggleReAuthenticateModal');
|
|
},
|
|
|
|
willTransition(transition) {
|
|
// exit early if an upgrade is required because our extended route
|
|
// class will abort the transition and show an error
|
|
if (this.get('upgradeStatus.isRequired')) {
|
|
return this._super(...arguments);
|
|
}
|
|
|
|
this.controller.willTransition(transition);
|
|
}
|
|
},
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: () => {
|
|
return this.get('controller.post.title') || 'Editor';
|
|
},
|
|
bodyClasses: ['gh-body-fullscreen'],
|
|
mainClasses: ['gh-main-white']
|
|
};
|
|
},
|
|
|
|
_blurAndScheduleAction(func) {
|
|
let selectedElement = $(document.activeElement);
|
|
|
|
// TODO: we should trigger a blur for textareas as well as text inputs
|
|
if (selectedElement.is('input[type="text"]')) {
|
|
selectedElement.trigger('focusout');
|
|
}
|
|
|
|
// wait for actions triggered by the focusout to finish before saving
|
|
run.scheduleOnce('actions', this, func);
|
|
}
|
|
});
|