0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Added collections data to editor (#17320)

refs TryGhost/Product#3555
This commit is contained in:
Steve Larson 2023-07-12 07:11:07 -05:00 committed by GitHub
parent c329aa772f
commit ec04d93de8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

View file

@ -50,6 +50,7 @@
@scrollOffsetBottomSelector={{@scrollOffsetBottomSelector}}
@wordCountDidChange={{@onWordCountChange}}
@snippets={{@snippets}}
@collections={{@collections}}
@saveSnippet={{@saveSnippet}}
@updateSnippet={{@updateSnippet}}
@deleteSnippet={{@deleteSnippet}}

View file

@ -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: {

View file

@ -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();
}

View file

@ -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)
}}