Ghost/ghost/admin/lib/koenig-editor/addon/components
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
..
kg-action-bar.hbs Co-located component template files 2020-05-18 13:14:08 +01:00
kg-action-bar.js Co-located component template files 2020-05-18 13:14:08 +01:00
koenig-alt-input.hbs Fixed image caption design bugs in Koenig 2020-08-27 15:21:11 +02:00
koenig-alt-input.js Co-located component template files 2020-05-18 13:14:08 +01:00
koenig-basic-html-input.hbs 🎨 Enabled use of Grammarly extension in the editor 2021-06-03 13:22:07 +01:00
koenig-basic-html-input.js Fixed errors when pasting non-markup into basic html fields 2021-09-03 10:51:45 +01:00
koenig-caption-input.hbs Fixed image caption design bugs in Koenig 2020-08-27 15:21:11 +02:00
koenig-caption-input.js Co-located component template files 2020-05-18 13:14:08 +01:00
koenig-card-accordion.hbs Updated edit mode design for accordion card 2021-11-10 13:44:03 +05:30
koenig-card-accordion.js Updated edit mode design for accordion card 2021-11-10 13:44:03 +05:30
koenig-card-bookmark.hbs Prevented card toolbar showing for embed/bookmark cards in input state 2020-10-21 18:27:26 +01:00
koenig-card-bookmark.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-card-button.hbs Updated link styles in Button and Email CTA cards 2021-11-10 15:42:35 +01:00
koenig-card-button.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-card-callout.hbs Fixed action toolbar not working in callout-card 2021-11-09 15:29:13 +01:00
koenig-card-callout.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-card-code.hbs Added "Create snippet" toolbar icon when cards are selected 2020-10-21 12:16:04 +01:00
koenig-card-code.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-card-email-cta.hbs Set audience capitalized in Email CTA options 2021-11-10 15:44:21 +01:00
koenig-card-email-cta.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-card-email.hbs Removed unused @style args from email+email-cta cards 2021-11-08 13:53:57 +00:00
koenig-card-email.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-card-embed.hbs Prevented card toolbar showing for embed/bookmark cards in input state 2020-10-21 18:27:26 +01:00
koenig-card-embed.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-card-gallery.hbs 🎨 Added ability to drop an image card onto an empty gallery 2021-09-06 11:57:42 +01:00
koenig-card-gallery.js 🐛 Fixed crash when newly created images are dragged into a gallery 2021-09-06 14:30:13 +01:00
koenig-card-hr.hbs Converted hr card component to glimmer syntax 2021-11-08 13:10:39 +00:00
koenig-card-hr.js Converted hr card component to glimmer syntax 2021-11-08 13:10:39 +00:00
koenig-card-html.hbs Added "Create snippet" toolbar icon when cards are selected 2020-10-21 12:16:04 +01:00
koenig-card-html.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-card-image.hbs Updated feature image design in editor 2021-06-21 12:03:40 +02:00
koenig-card-image.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-card-markdown.hbs Added "Create snippet" toolbar icon when cards are selected 2020-10-21 12:16:04 +01:00
koenig-card-markdown.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-card-nft.hbs Added empty NFT component 2021-11-09 13:56:24 +01:00
koenig-card-nft.js Added empty NFT component 2021-11-09 13:56:24 +01:00
koenig-card-paywall.hbs Converted paywall component to glimmer syntax 2021-11-08 13:08:58 +00:00
koenig-card-paywall.js Converted paywall component to glimmer syntax 2021-11-08 13:08:58 +00:00
koenig-card.hbs Switched back to explicit edit mode for settings panel prototype 2021-11-03 14:52:05 +00:00
koenig-card.js Switched back to explicit edit mode for settings panel prototype 2021-11-03 14:52:05 +00:00
koenig-editor.hbs Hid email specific cards from card menus when editing pages 2021-09-10 09:24:38 +01:00
koenig-editor.js Removed duplication of "delete if empty" card logic 2021-11-10 14:46:00 +00:00
koenig-link-input.hbs Koenig action bar color fixes 2021-03-09 12:45:18 +01:00
koenig-link-input.js Bumped eslint-plugin-ghost and fixed linter errors 2021-07-15 15:27:29 +01:00
koenig-link-toolbar.hbs Co-located component template files 2020-05-18 13:14:08 +01:00
koenig-link-toolbar.js Switch deprecated htmlSafe imports from @ember/string to @ember/template 2021-05-12 12:33:40 +01:00
koenig-menu-content.hbs Hid email specific cards from card menus when editing pages 2021-09-10 09:24:38 +01:00
koenig-menu-content.js Added scroll-into-view behaviour for slash menu selection 2020-10-27 16:15:58 +00:00
koenig-plus-menu.hbs Hid email specific cards from card menus when editing pages 2021-09-10 09:24:38 +01:00
koenig-plus-menu.js Switch deprecated htmlSafe imports from @ember/string to @ember/template 2021-05-12 12:33:40 +01:00
koenig-settings-panel.hbs Added basic drag-to-move handling to card setting panels 2021-11-03 16:51:24 +00:00
koenig-settings-panel.js First prototype for card settings panel 2021-11-02 16:25:54 +00:00
koenig-slash-menu.hbs Implemented first iteration of content snippets 2020-10-15 18:03:35 +01:00
koenig-slash-menu.js Bumped eslint-plugin-ghost and fixed linter errors 2021-07-15 15:27:29 +01:00
koenig-snippet-input.hbs Added group heading to existing snippets in dropdown 2021-09-08 09:54:06 +01:00
koenig-snippet-input.js Added group heading to existing snippets in dropdown 2021-09-08 09:54:06 +01:00
koenig-text-replacement-html-input.hbs 🎨 Enabled use of Grammarly extension in the editor 2021-06-03 13:22:07 +01:00
koenig-text-replacement-html-input.js Converted <KoenigCardEmailCta> to native class glimmer component 2021-07-20 18:33:39 +01:00
koenig-toolbar.hbs Updated email CTA card 2021-08-03 18:21:54 +02:00
koenig-toolbar.js Switch deprecated htmlSafe imports from @ember/string to @ember/template 2021-05-12 12:33:40 +01:00