Closed dChiamp closed 3 years ago
As you can see in the screenshots, the textColor
, backgroundColor
works for the blocks including heading block.
But in your test case, the color is not applied to the heading. Instead it is applied to the child span.
You can confirm it in Code editor
view.
In my example, the markup code is <h2 class="has-text-align-center custom-class has-vivid-red-color has-pale-pink-background-color has-text-color has-background has-medium-font-size"><span>Ths is heading block</span>.</h2>
As you can see all the classes appended to the h2 tag. But you should have color classes attached to the span in your markup.
Here is the better example.
Difference In Visual editor
Difference in Code editor
Difference in WP-GraphQL
I can confirm this not working correctly:
<!-- wp:heading {"style":{"color":{"text":"#ef275c","background":"#0d0921"}}} -->
<h2 class="has-text-color has-background" style="background-color:#0d0921;color:#ef275c">Test heading</h2>
<!-- /wp:heading -->
query MyQuery {
page(id: "example-page", idType: URI) {
blocks {
... on CoreHeadingBlock {
name
attributes {
... on CoreHeadingBlockAttributes {
content
fontSize
backgroundColor
textColor
}
}
}
}
}
}
"data": {
"page": {
"blocks": [
{},
{
"name": "core/heading",
"attributes": {
"content": "Test heading",
"fontSize": "",
"backgroundColor": "",
"textColor": ""
}
},
{}
]
}
}
I can see it doesn't work with custom values. Let me handle the case.
@drewbaker @dChiamp I fixed it and pushed to dev branch. Please check and let me know opinion. Thanks
That update is working!
Is it possible for the preset color options to return a hex like the custom colors? You can see the custom background color is a hex while the preset option returns the name string of the color:
Or better yet, textColor.name and textColor.code?
Please check the latest commit. I added backgroundColorCode
, textColorCode
, and fontSizeValue
attribute
Please check the latest commit. I added
backgroundColorCode
,textColorCode
, andfontSizeValue
attribute
Is this on all blocks that support font/background color? Like paragraph, heading? (I think maybe blockquote too?)
Yes, it supports all the blocks with backgroundColor, textColor and fontSize setting
awesome! tested and confirmed its working: ![Uploading Screen Shot 2021-04-19 at 1.52.23 PM.png…]()
BlockAttributes is not returning all attributes set in blocks.
You can see in graphiQL that the title's textAlign is properly returning "center", but textColor is not "red". (see attached images)
ideally all blocks would include these default attributes: