mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-01 15:29:19 +03:00
Added fetchLabels to the Lexical config (#16774)
closes https://github.com/TryGhost/Team/issues/3183 - fetches all existing labels - returns "id" and "name" fields
This commit is contained in:
parent
080a1c92d8
commit
d86ac17e31
@ -213,6 +213,16 @@ export default class KoenigLexicalEditor extends Component {
|
||||
return this.offers;
|
||||
}
|
||||
|
||||
@task({restartable: true})
|
||||
*fetchLabelsTask() {
|
||||
if (this.labels) {
|
||||
return this.labels;
|
||||
}
|
||||
|
||||
this.labels = yield this.store.query('label', {limit: 'all', fields: 'id, name'});
|
||||
return this.labels;
|
||||
}
|
||||
|
||||
ReactComponent = (props) => {
|
||||
const fetchEmbed = async (url, {type}) => {
|
||||
let oembedEndpoint = this.ghostPaths.url.api('oembed');
|
||||
@ -239,6 +249,17 @@ export default class KoenigLexicalEditor extends Component {
|
||||
return [...defaults, ...offersLinks];
|
||||
};
|
||||
|
||||
const fetchLabels = async () => {
|
||||
const labels = await this.fetchLabelsTask.perform();
|
||||
|
||||
return labels.toArray().map((label) => {
|
||||
return {
|
||||
id: label.id,
|
||||
name: label.name
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const defaultCardConfig = {
|
||||
unsplash: {
|
||||
defaultHeaders: {
|
||||
@ -252,6 +273,7 @@ export default class KoenigLexicalEditor extends Component {
|
||||
tenor: this.config.tenor?.googleApiKey ? this.config.tenor : null,
|
||||
fetchEmbed: fetchEmbed,
|
||||
fetchAutocompleteLinks,
|
||||
fetchLabels,
|
||||
feature: {
|
||||
signupCard: this.feature.get('signupCard')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user