-
Notifications
You must be signed in to change notification settings - Fork 22
Experiment: use dynamic block server-side rendering #272
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
Open
mlwilkerson
wants to merge
47
commits into
main
Choose a base branch
from
render-callback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or 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
and server-side rendering it
updated for justification and alignment
wrapper block props
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR is an experiment to explore using dynamic blocks for the Font Awesome Icon block, in order to avoid storing raw HTML in posts.
This support issue shows that users with only the Editor role may not be able to save icon blocks that involve raw HTML. Using dynamic blocks with server-side rendering via
render_callbackis one way to avoid saving raw HTML intopost_content.The PR demonstrates that this works, as expected. It saves the
abstractas generated by@fortawesome/fontawesome-svg-coreas a separate attribute, instead of the rendered<svg>. The back end PHP code that implements therender_callbackthen renders the<svg>from thatabstractattribute.So far, so good.
However, that only work for icon blocks. It won't work for rich text icons.
It won't work for rich text icons because, in their case, the operative block is the paragraph, or button--as examples--into which the rich text icon has been inserted. The
render_callbackonly works to render blocks associated with thatrender_callback--not bits of content inserted into other blocks.KSES filtering vs. dynamic block rendering
This experiment is an alternative to modifying the KSES filtering. The KSES filter is what strips out the raw HTML
<svg>upon saving, when the user lacks theunfiltered_htmlcapability. In a default installation, both an Admin and Editor have theunfiltered_htmlcapability. But for sites that are more security-hardened, these users may not have theunfiltered_htmlcapability.So one way to make it work would be the modify the KSES filters to allow for saving our
<svg>HTML by any user who can edit content. This would affect allpost_content, not just ours.If the KSES filter were modified, it would mean that the raw
<svg>HTML could saved directly into thepost_content.If the KSES filter were not modified, then it would require using dynamic blocks--as in this PR. Instead of saving raw HTML into the
post_content, theabstractis stored as part of the HTML comment that serialized all of the block's attributes. Then therender_callbackdoes its rendering based on thatabstract.