-
Notifications
You must be signed in to change notification settings - Fork 15
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
Added block and content resolver for CoreFootnotes #335
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
"@wpengine/wp-graphql-content-blocks": minor | ||
--- | ||
|
||
Added content resolver for CoreFootnotes when the post_meta isn't loaded | ||
|
||
|
||
```gql | ||
fragment CoreFootnotesBlockFragment on CoreFootnotes { | ||
innerBlocks { | ||
renderedHtml | ||
} | ||
} | ||
|
||
query Post($id: ID!) { | ||
post(id: $id, idType: DATABASE_ID) { | ||
databaseId | ||
editorBlocks { | ||
...CoreFootnotesBlockFragment | ||
} | ||
} | ||
} | ||
``` | ||
|
||
|
||
```json | ||
{ | ||
"data": { | ||
"post": { | ||
"databaseId": 16, | ||
"editorBlocks": [ | ||
{}, | ||
{ | ||
"innerBlocks": [ | ||
{ | ||
"renderedHtml": "<ol class=\"footnotes\"><li id=\"d4051e5e-1547-49ff-ab6d-bec1caa6aabc\"><a href=\"https://wpengine.com/about-us/\">https://wpengine.com/about-us/</a></li><li id=\"2e79de23-68a8-42eb-87ab-1f2467a21752\"><a href=\"https://wpengine.com/support/\">https://wpengine.com/support/</a></li></ol>" | ||
} | ||
] | ||
}, | ||
{} | ||
] | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
/** | ||
* Core Paragraph Block | ||
* | ||
* @package WPGraphQL\ContentBlocks\Blocks | ||
*/ | ||
|
||
namespace WPGraphQL\ContentBlocks\Blocks; | ||
|
||
/** | ||
* Class CoreParagraph | ||
*/ | ||
class CoreFootnotes extends Block { | ||
/** | ||
* {@inheritDoc} | ||
* | ||
* @var array|null | ||
*/ | ||
protected ?array $additional_block_attributes = [ | ||
'cssClassName' => [ | ||
'type' => 'string', | ||
'selector' => 'p', | ||
'source' => 'attribute', | ||
'attribute' => 'class', | ||
], | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
But core/footnotes doesn't have inner blocks...
https://github.com/WordPress/gutenberg/blob/be5ce8aefa49b394a57aa540d9c9b091510ed8f1/packages/block-library/src/footnotes/index.php#L19
https://github.com/WordPress/gutenberg/blob/be5ce8aefa49b394a57aa540d9c9b091510ed8f1/packages/block-library/src/footnotes/edit.js#L49 ...
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.
I was actually able to render the footnotes HTML without checking out this branch. This is on the main branch:
Do we really need to expose the individual footnote items from this list? I'm not sure.
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.
@theodesp @justlevine I think if we can get the data (as per @theodesp GQL query) then is there any need for this? I don't think we should add any new blocks/logic if we can already get the data? The other thing is footnotes are directly correlated with content so not sure if adding a new block for footnotes is needed on reflection.
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.
agree there's no need, and personally don't see the value, especially versus the cost of maintaining this (and any other manual deviation that we cant auto-infer from WP core in our schema generation)
Unit tests are always nice to alert us if
renderedHtml
or something else changes in the future, but I don't see that in this diff anyway.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.
Thanks @justlevine
I don't see any point either if we can just query the data. I will close this PR out. Thanks for the really good feedback aswell.