Ghost/ghost/admin/lib/koenig-editor/addon
Kevin Ansfield 2625199fb2 Removed duplication of "delete if empty" card logic
no issue

The logic for "delete if empty" was duplicated in two places:

1. when `createComponentCard` is used to register a card, this option method was used when cleaning up a post when first rendering (cards in empty state can be saved before the editor auto-removes them but we don't want to show them again)
2. inside of card's own delete-if-empty handling on certain actions such as deselection or leaving edit mode

- added an `ifEmpty` property to each card component
  - used by the editor's first-render cleanup routing if the property is present
  - can be re-used internally for the card's own deselect/exit-edit-mode behaviour
- updated the cleanup routine in `<KoenigEditor>`
  - added a `allComponentCardsRegistered` property that will return `true` when the `.component` property is set on every card (the property is set during card component initialisation so we're at the mercy of Ember's render process so not all card components will be immediately registered)
  - swapped `_cleanup` for `_cleanupTask` that will wait for `allComponentCardsRegistered` to be `true` before performing cleanup, ensuring that we always have access to the card component's `isEmpty` property even when Ember renders cards across multiple render batches
  - checks for `isEmpty` being a boolean and will delete the card if it's value is `true`
- updated all cards that had delete-if-empty behaviour
  - added `isEmpty` properties
  - removed duplicated logic in the `createComponentCard` calls
2021-11-10 14:46:00 +00:00
..
components Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
helpers Hid email specific cards from card menus when editing pages 2021-09-10 09:24:38 +01:00
lib Resolved "already declared in upper scope" linting warnings 2020-10-05 09:56:21 +01:00
options Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
services Removed prototype button atom 2021-07-23 09:21:03 +01:00
utils Prototyped component based atoms in the editor 2021-07-22 18:54:46 +01:00