From 844bb3277da8109dbda436c4e0ef445d17ed8fe9 Mon Sep 17 00:00:00 2001 From: Katharina Irrgang Date: Wed, 21 Jun 2017 13:28:29 +0200 Subject: [PATCH] Revert "always give editor content focus by default (#748)" (#755) This reverts commit 3c2f3da689d06d5c994d81b858dc0c54553b0ef9. --- ghost/admin/app/mixins/editor-base-controller.js | 5 ++++- ghost/admin/app/routes/editor/edit.js | 11 +++++++++++ ghost/admin/app/routes/editor/new.js | 10 ++++++++++ ghost/admin/app/templates/editor/edit.hbs | 5 +++-- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/ghost/admin/app/mixins/editor-base-controller.js b/ghost/admin/app/mixins/editor-base-controller.js index aed20abbc9..ae64ebdd01 100644 --- a/ghost/admin/app/mixins/editor-base-controller.js +++ b/ghost/admin/app/mixins/editor-base-controller.js @@ -3,7 +3,7 @@ import Mixin from 'ember-metal/mixin'; import PostModel from 'ghost-admin/models/post'; import RSVP from 'rsvp'; import boundOneWay from 'ghost-admin/utils/bound-one-way'; -import computed, {mapBy, reads} from 'ember-computed'; +import computed, {alias, mapBy, reads} from 'ember-computed'; import ghostPaths from 'ghost-admin/utils/ghost-paths'; import injectController from 'ember-controller/inject'; import injectService from 'ember-service/inject'; @@ -51,6 +51,9 @@ export default Mixin.create({ editor: null, editorMenuIsOpen: false, + shouldFocusTitle: alias('model.isNew'), + shouldFocusEditor: false, + navIsClosed: reads('application.autoNav'), init() { diff --git a/ghost/admin/app/routes/editor/edit.js b/ghost/admin/app/routes/editor/edit.js index 91f00c0bf6..dc4b88b485 100644 --- a/ghost/admin/app/routes/editor/edit.js +++ b/ghost/admin/app/routes/editor/edit.js @@ -5,6 +5,12 @@ import base from 'ghost-admin/mixins/editor-base-route'; export default AuthenticatedRoute.extend(base, { titleToken: 'Editor', + beforeModel(transition) { + this.set('_transitionedFromNew', transition.data.fromNew); + + this._super(...arguments); + }, + model(params) { /* eslint-disable camelcase */ let query = { @@ -36,6 +42,11 @@ export default AuthenticatedRoute.extend(base, { }); }, + setupController(controller) { + this._super(...arguments); + controller.set('shouldFocusEditor', this.get('_transitionedFromNew')); + }, + actions: { authorizationFailed() { this.get('controller').send('toggleReAuthenticateModal'); diff --git a/ghost/admin/app/routes/editor/new.js b/ghost/admin/app/routes/editor/new.js index 901139dfdd..b13e5699b6 100644 --- a/ghost/admin/app/routes/editor/new.js +++ b/ghost/admin/app/routes/editor/new.js @@ -17,5 +17,15 @@ export default AuthenticatedRoute.extend(base, { controller, model }); + }, + + actions: { + willTransition(transition) { + // decorate the transition object so the editor.edit route + // knows this was the previous active route + transition.data.fromNew = true; + + this._super(...arguments); + } } }); diff --git a/ghost/admin/app/templates/editor/edit.hbs b/ghost/admin/app/templates/editor/edit.hbs index 0c4c930863..9197251e12 100644 --- a/ghost/admin/app/templates/editor/edit.hbs +++ b/ghost/admin/app/templates/editor/edit.hbs @@ -35,8 +35,8 @@ --}} {{#gh-markdown-editor tabindex="2" - placeholder="Now begin writing your story..." - autofocus=true + placeholder="Click here to start..." + autofocus=shouldFocusEditor uploadedImageUrls=editor.uploadedImageUrls mobiledoc=(readonly model.scratch) isFullScreen=editor.isFullScreen @@ -54,6 +54,7 @@ class="gh-editor-title" placeholder="Your Post Title" tabindex="1" + shouldFocus=shouldFocusTitle autoExpand=".gh-markdown-editor-pane" focusOut=(action "saveTitle") update=(action (perform updateTitle))