diff --git a/ghost/admin/app/components/gh-koenig-editor.hbs b/ghost/admin/app/components/gh-koenig-editor.hbs index 513752abb9..ecb2912a36 100644 --- a/ghost/admin/app/components/gh-koenig-editor.hbs +++ b/ghost/admin/app/components/gh-koenig-editor.hbs @@ -50,6 +50,7 @@ @scrollOffsetBottomSelector={{@scrollOffsetBottomSelector}} @wordCountDidChange={{@onWordCountChange}} @snippets={{@snippets}} + @collections={{@collections}} @saveSnippet={{@saveSnippet}} @updateSnippet={{@updateSnippet}} @deleteSnippet={{@deleteSnippet}} diff --git a/ghost/admin/app/components/koenig-lexical-editor.js b/ghost/admin/app/components/koenig-lexical-editor.js index 284e3f138f..4ecfb391f6 100644 --- a/ghost/admin/app/components/koenig-lexical-editor.js +++ b/ghost/admin/app/components/koenig-lexical-editor.js @@ -239,6 +239,14 @@ export default class KoenigLexicalEditor extends Component { return response; }; + const fetchCollectionPosts = async (collectionSlug) => { + const collectionPostsEndpoint = this.ghostPaths.url.api('collections', collectionSlug,'posts'); + const {collection_posts: collectionPosts} = await this.ajax.request(collectionPostsEndpoint, { + data: {limit: 12} + }); + return collectionPosts; + }; + const fetchAutocompleteLinks = async () => { const offers = await this.fetchOffersTask.perform(); @@ -273,7 +281,8 @@ export default class KoenigLexicalEditor extends Component { } }, tenor: this.config.tenor?.googleApiKey ? this.config.tenor : null, - fetchEmbed: fetchEmbed, + fetchEmbed, + fetchCollectionPosts, fetchAutocompleteLinks, fetchLabels, feature: { diff --git a/ghost/admin/app/controllers/lexical-editor.js b/ghost/admin/app/controllers/lexical-editor.js index ef3a3ba019..cc372b3155 100644 --- a/ghost/admin/app/controllers/lexical-editor.js +++ b/ghost/admin/app/controllers/lexical-editor.js @@ -187,6 +187,11 @@ export default class LexicalEditorController extends Controller { }); } + @computed + get collections() { + return this.store.peekAll('collection'); + } + @computed('session.user.{isAdmin,isEditor}') get canManageSnippets() { let {user} = this.session; @@ -775,10 +780,13 @@ export default class LexicalEditorController extends Controller { } } - // load supplemental data such as snippets and members count in the background + // load supplemental data such as snippets and collections in the background @restartableTask *backgroundLoaderTask() { yield this.store.query('snippet', {limit: 'all'}); + if (this.post.displayName === 'page' && this.feature.get('collections') && this.feature.get('collectionsCard')) { + yield this.store.query('collection', {limit: 'all'}); + } this.syncMobiledocSnippets(); } diff --git a/ghost/admin/app/templates/lexical-editor.hbs b/ghost/admin/app/templates/lexical-editor.hbs index b78315188f..e4dc4c71e6 100644 --- a/ghost/admin/app/templates/lexical-editor.hbs +++ b/ghost/admin/app/templates/lexical-editor.hbs @@ -86,6 +86,7 @@ @cardOptions={{hash post=this.post snippets=this.snippets + collections=this.collections deleteSnippet=(if this.canManageSnippets this.confirmDeleteSnippet) createSnippet=(if this.canManageSnippets this.createSnippet) }}