mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05: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
1 changed files with 22 additions and 0 deletions
|
@ -213,6 +213,16 @@ export default class KoenigLexicalEditor extends Component {
|
||||||
return this.offers;
|
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) => {
|
ReactComponent = (props) => {
|
||||||
const fetchEmbed = async (url, {type}) => {
|
const fetchEmbed = async (url, {type}) => {
|
||||||
let oembedEndpoint = this.ghostPaths.url.api('oembed');
|
let oembedEndpoint = this.ghostPaths.url.api('oembed');
|
||||||
|
@ -239,6 +249,17 @@ export default class KoenigLexicalEditor extends Component {
|
||||||
return [...defaults, ...offersLinks];
|
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 = {
|
const defaultCardConfig = {
|
||||||
unsplash: {
|
unsplash: {
|
||||||
defaultHeaders: {
|
defaultHeaders: {
|
||||||
|
@ -252,6 +273,7 @@ export default class KoenigLexicalEditor extends Component {
|
||||||
tenor: this.config.tenor?.googleApiKey ? this.config.tenor : null,
|
tenor: this.config.tenor?.googleApiKey ? this.config.tenor : null,
|
||||||
fetchEmbed: fetchEmbed,
|
fetchEmbed: fetchEmbed,
|
||||||
fetchAutocompleteLinks,
|
fetchAutocompleteLinks,
|
||||||
|
fetchLabels,
|
||||||
feature: {
|
feature: {
|
||||||
signupCard: this.feature.get('signupCard')
|
signupCard: this.feature.get('signupCard')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue