New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WP Ai Global Styles #1994
WP Ai Global Styles #1994
Conversation
bdcd3c5
to
96f7505
Compare
URL from config will be added here https://github.com/bagrinsergiu/blox-editor/issues/26071 |
df9510c
to
a1ef05c
Compare
|
||
export const getAIGlobalStyles = (): AiGlobalStyles<Palette, FontStyle> => { | ||
const apiUrl = | ||
"https://phplaravel-1109775-4163586.cloudwaysapps.com/api/template"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use url from config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return { | ||
async getColors(res, rej) { | ||
try { | ||
const styles = await fetch(`${apiUrl}/style`).then((r) => r.json()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use async/await without then
:
const styles = await getStyles(/* ... */)
}, | ||
async getTypography(res, rej) { | ||
try { | ||
const data = await fetch(`${apiUrl}/typography`).then((r) => r.json()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here also use async/await without then
9f38fc5
to
af88b4a
Compare
editor/editor/editor.php
Outdated
@@ -93,6 +93,7 @@ public function getClientConfig($context) | |||
'project' => array( | |||
'status' => $this->getProjectStatus(), | |||
), | |||
'aiGlobalStyleUrl' => 'https://phplaravel-1109775-4163586.cloudwaysapps.com' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to be revied
async getColors(res, rej) { | ||
try { | ||
const styles = await fetch( | ||
`${aiGlobalStyleUrl}/api/template/style` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as editor api client
b2f388e
to
ad947b0
Compare
3262ca7
to
7d60fd6
Compare
|
||
res(styles.colorPalette); | ||
} catch (e) { | ||
rej(t("Failed to load meta.json")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review reject message
|
||
res(data.fontStyles); | ||
} catch (e) { | ||
rej(t("Failed to load resolves for selected DefaultTemplate")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review reject message
shouldn't be something like: "failed to load typography..." ?
@@ -5,6 +5,15 @@ export interface DefaultBlock { | |||
value: Record<string, unknown>; | |||
} | |||
|
|||
export interface AiGlobalStyles<T1, T2> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename AiGlobalStyles
as i see in previous @maxval1 review there is nothing with AI
public/editor-client/src/index.ts
Outdated
set( | ||
window.__VISUAL_CONFIG__.ui, | ||
["leftSidebar", "styles"], | ||
getAIGlobalStyles(config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename also this function
3671b4f
to
7c367b0
Compare
Related issue https://github.com/bagrinsergiu/blox-editor/issues/25691