Repository navigation
Move blocks to block API version 3 - #366
Merged
Merged
Conversation
Declare apiVersion 3 in the PHP registration and in registerBlockType. The edit component already used useBlockProps and ownerDocument, so no editor JS change was needed beyond the version. The editor stylesheet was enqueued on enqueue_block_editor_assets, which does not reach the iframed canvas that API version 3 uses. It is now enqueued on enqueue_block_assets (admin only), which WordPress mirrors into the iframe.
Declare apiVersion 3 in the PHP registration and in registerBlockType. The edit component already used useBlockProps and does not touch the global document or window, so no editor JS change was needed beyond the version. The editor stylesheet was enqueued on enqueue_block_editor_assets, which does not reach the iframed canvas that API version 3 uses. It is now enqueued on enqueue_block_assets (admin only), which WordPress mirrors into the iframe.
Declare apiVersion 3 in the PHP registration and in registerBlockType. The edit component already used useBlockProps and does not touch the global document or window, and the stylesheet is already enqueued on enqueue_block_assets, so nothing else had to change.
Declare apiVersion 3 in the PHP registration and in registerBlockType. The edit component already puts useBlockProps on its root nav, does not touch the global document or window, and the stylesheet is already enqueued on enqueue_block_assets, so nothing else had to change. The compiled editor script was rebuilt with the local babel, which emits different (equivalent) helper functions for the props spread.
Declare apiVersion 3 in the PHP registration and in registerBlockType. The theme typography hints in the sidebar resolved CSS custom properties with getComputedStyle( document.documentElement ), which is the wp-admin document. The theme presets live inside the iframed canvas, so the lookup now goes through the block root (a ref passed to useBlockProps) and its ownerDocument. The block's editor_style handle already reaches the iframe; a test now covers it. The block is only instantiated by FrontBlocks Pro, so the free plugin does not register it by itself.
Declare apiVersion 3 in the PHP registration and in registerBlockType. The edit component already puts useBlockProps on its root. The jQuery UI autocomplete is bound to the search field rendered in the inspector sidebar (the wp-admin document, not the iframed canvas), so its script and stylesheet on enqueue_block_editor_assets are still the right place and nothing else had to change.
Declare apiVersion 3 in the PHP registration and in registerBlockType. The saved markup is unchanged (the save function already uses useBlockProps.save); a block serialized with API version 1 parses as valid and re-serializes identically. Editor fixes for the iframed canvas: - While an animation preview is shown the edit output had no root carrying the block props (API version 1 added the wrapper by itself), so the block lost its wrapper, selection and toolbar. The preview is now wrapped in an element that gets the useBlockProps props. - The terminal, block, random reveal and shuffle previews created their nodes with the global document.createElement; they now use the ownerDocument of the element they populate. The stylesheet already reaches the iframe through the block editor_style.
Declare apiVersion 3 in the PHP registration and in registerBlockType. The edit component already puts useBlockProps on its root and does not touch the global document or window. The editor stylesheet was enqueued on enqueue_block_editor_assets, which does not reach the iframed canvas that API version 3 uses. It is now enqueued on enqueue_block_assets (admin only), which WordPress mirrors into the iframe. The registration arguments moved into get_block_args() so they can be asserted without WooCommerce, which the registration is gated on and the unit tests do not load.
block.json already declared apiVersion 3, but the editor script, which is hand-written (no build step), did not: it registered the block without a version and its edit output had no root carrying useBlockProps, which API version 3 requires. The edit output is now wrapped in an element that gets the block props, and registerBlockType declares apiVersion 3. The pre-5.5 fallback registration in PHP also declares api_version 3 so both registration paths agree. The fallback preview checked for a "signup" mode that does not exist (the attribute value is "register"); fixed while touching it. Adds a unit test for the registration, which had none.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
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
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.
What
Moves every block FrontBlocks registers itself to block API version 3 (
api_version => 3in PHP / block.json andapiVersion: 3in JS), one commit per block. Before this PR none of them declared a version (so they were v1), except Google Login, whose PHP/block.json already said 3 while its JS did not.before-afterenqueue_block_editor_assetstoenqueue_block_assets(admin only), so it reaches the editor iframestacked-imagesreading-timetable-of-contentsuser-textgetComputedStyle(document.documentElement)now goes through the block root'sownerDocument(ref onuseBlockProps)insert-posttext-animationuseBlockPropsroot and lost its wrapper/selection, now wrapped; 6document.createElementcalls useel.ownerDocument; saved markup is identical to v1product-categoriesget_block_args()because registration is gated on WooCommerce and unit tests could not load itgoogle-loginedit()output now has auseBlockPropsroot; the pre-5.5 fallback registration getsapi_version3; also fixes a'signup'vs'register'typo in the fallback previewExtensions of core blocks (
register_block_type_args,addFilter) are untouched.Tests
api_versionis 3, plus a CSS-hook test where the hook changed (newGoogleSignInTest).getBlockType().apiVersion === 3, block root insideiframe[name="editor-canvas"], no page or console errors, publish and frontend render. Product Categories was run with WooCommerce and 3 categories; Google Login unconfigured and with a fake client id; Text Animation preview mode also checked.CookieNoticeDeprecationNoticeTest(anaction=install-pluginassertion). It fails the same way on trunk, so it is not caused by this PR.Not verified / to check by hand
frontblocks-toc-option.jshas slightly different but equivalent helper functions for the props spread.readme.txthas no Unreleased section (the top entry is the released 1.5.6).