Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New->Edit transition refactor #8287

Closed
1 task
disordinary opened this issue Apr 6, 2017 · 2 comments · Fixed by TryGhost/Admin#949
Closed
1 task

New->Edit transition refactor #8287

disordinary opened this issue Apr 6, 2017 · 2 comments · Fixed by TryGhost/Admin#949
Assignees
Labels
affects:admin Anything relating to Ghost Admin

Comments

@disordinary
Copy link
Contributor

disordinary commented Apr 6, 2017

General overview of required changes outlined in #8287 (comment)

Issues that should be fixed when this lands:


Currently ghost-admin doesn't create a post until the user makes a change in the editor. This causes the editor to reload which in turn resets the cursor position among other things.

We unsuccessfully try and mask this by moving the cursor to the end of the content.

This:

  1. Causes a visible jump in the cursor.
  2. It doesn't actually successfully jump to the end so the user ends up with mangled words.
  3. If a user opens the / menu it just flickers visible as the page is reloaded.
  4. There's a few bugs which only appear on the new page and not the edit page for some reason:
    1. The title placeholder text appears over the body rather than the title
    2. The '+' menu doesn't appear on the first blank paragraph.
@disordinary disordinary changed the title New post transitioning to edit mode New post transitioning to "edit" mode Apr 6, 2017
@kevinansfield
Copy link
Contributor

kevinansfield commented Apr 6, 2017

I've been thinking about this for a while and we went through my plans to eliminate it on Slack a while back https://ghost.slack.com/archives/C09JM0TCK/p1489655198744663

The outline of the refactor discussed there:

  • add an explicit editor route/controller/template triad
  • remove the editor base route/controller mixins and move their logic into the top-level editor route/controller
  • remove the new/edit controllers and move the editor/edit.hbs template to editor.hbs
  • the new/edit routes will now be very basic, they'll create or fetch the post model and update the parent editor route's controller
  • the editor rendering is now controlled by the top-level route so switching from new->edit child routes won't force a re-render, the editor controller's model won't be replaced as the reference will stay the same so components won't be re-rendered either
  • we'd no longer be able to use Ember's standard loading route to display a spinner whilst the post is fetched in the edit route but we should be able to work around that by using the edit route's model hook to update properties in the editor controller (during the new->edit transition that hook won't be called because we can pass the existing model in)

With those changes in place the code surrounding editor becomes a lot simpler, the editor component wouldn't be re-rendered and I think the editor can continue to use the same scratch reference so it will behave the same way it currently does for autosaves.

@disordinary
Copy link
Contributor Author

That sounds good, I should have work arounds for most of the bugs but there is no solution to the actual physical reloading of the editor with the current setup.

Other options which may be simpler are:

  1. Reload on title OR editor change.
  2. Reload when the user navigates from the title to the editor and the title has changed OR the editor has changed.
  3. Don't reload at all until the user explicitly saves the document.

@ErisDS ErisDS added affects:admin Anything relating to Ghost Admin affects:editor Work relating to the Koenig Editor labels Apr 11, 2017
@kevinansfield kevinansfield removed the affects:editor Work relating to the Koenig Editor label May 13, 2017
@ErisDS ErisDS removed the post 1.0.0 label Aug 10, 2017
@kevinansfield kevinansfield changed the title New post transitioning to "edit" mode New->Edit transition refactor Sep 8, 2017
kevinansfield added a commit to kevinansfield/Ghost-Admin that referenced this issue Jan 16, 2018
closes TryGhost/Ghost#8287
closes TryGhost/Ghost#8750
- moved all editor model functionality into the new `editor` route+controller
- moved editor template from `editor/edit.hbs` to `editor.hbs`
- refactored `editor` controller and the `editor.new`/`editor.edit` routes to work with a persistent editor rather than a teardown/re-render when transitioning from new->edit
- fixed issue in `{{gh-markdown-editor}}` for `autofocus` behaviour when the component isn't re-rendered
- fixed issue in `{{gh-simplemde}}` that was causing multiple updates to the `value` property when a new value is passed in to the component
- added `{{gh-scheduled-post-countdown}}` component to lower the noise in the editor controller
- removed editor route/controller mixins
- removed the `editor.edit` and `editor.new` controllers
kevinansfield added a commit to kevinansfield/Ghost-Admin that referenced this issue Jan 16, 2018
closes TryGhost/Ghost#8287
closes TryGhost/Ghost#8750
- moved all editor model functionality into the new `editor` route+controller
- moved editor template from `editor/edit.hbs` to `editor.hbs`
- refactored `editor` controller and the `editor.new`/`editor.edit` routes to work with a persistent editor rather than a teardown/re-render when transitioning from new->edit
- fixed issue in `{{gh-markdown-editor}}` for `autofocus` behaviour when the component isn't re-rendered
- fixed issue in `{{gh-simplemde}}` that was causing multiple updates to the `value` property when a new value is passed in to the component
- added `{{gh-scheduled-post-countdown}}` component to lower the noise in the editor controller
- removed editor route/controller mixins
- removed the `editor.edit` and `editor.new` controllers
kevinansfield added a commit to TryGhost/Admin that referenced this issue Jan 17, 2018
closes TryGhost/Ghost#8287
closes TryGhost/Ghost#8750
- moved all editor model functionality into the new `editor` route+controller
- moved editor template from `editor/edit.hbs` to `editor.hbs`
- refactored `editor` controller and the `editor.new`/`editor.edit` routes to work with a persistent editor rather than a teardown/re-render when transitioning from new->edit
- fixed issue in `{{gh-markdown-editor}}` for `autofocus` behaviour when the component isn't re-rendered
- fixed issue in `{{gh-simplemde}}` that was causing multiple updates to the `value` property when a new value is passed in to the component
- added `{{gh-scheduled-post-countdown}}` component to lower the noise in the editor controller
- removed editor route/controller mixins
- removed the `editor.edit` and `editor.new` controllers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects:admin Anything relating to Ghost Admin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants