Gutenberg dynamic-block wrappers for shortcodes with editor previews #45
Reference in New Issue
Block a user
Delete Branch "feature/editor-blocks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The plugin's four shortcodes —
[us_booking],[us_student_login],[us_student_register],[us_group_classes]— appear as plain grey shortcode text in the block editor, so there is no way to preview the pages or style them against a theme/layout.Resolves #44
What changed
BlockRegistrar(new, wired inPlugin::boot()) registers four dynamic blocks —us-scheduler/booking,us-scheduler/student-login,us-scheduler/student-register,us-scheduler/group-classes— whoserender_callbacks delegate to the same page objects the shortcodes use, so front-end output is identical either way. Shortcodes remain for back-compat;ShortcodeRegistrarnow receives the shared page instances instead of constructing its own.assets/js/blocks.js(vanilla JS, no build step) registers the editor side of each block: title, icon, keywords,wp.serverSideRenderpreviews, andtransforms.fromshortcode transforms so pasting a shortcode auto-converts to the matching block.BlockPreview(new) renders static, script-free editor previews.BlockRegistrardetects the block-renderer REST context (REST_REQUEST) and serves these instead of the live pages — no live REST calls, redirects, or Stripe.js in the editor. Previews reproduce the live markup and CSS classes (#us-booking-app/.us-slot,#us-group-app/.us-class, the real login template, a disabled sample of the registration form), each with a.us-editor-noteexplaining what the published page shows.frontend.cssis attached as the blocks'stylehandle so it loads inside the editor and previews pick up theme styling; added a small.us-editor-notestyle.docs/features/editor-blocks.md; CLAUDE.md class table updated.Checks
composer test(214 tests, 650 assertions),composer lint(PHPStan L6 — no errors), andcomposer cs(PHPCS) all pass. NewBlockRegistrarTestcovers hook/block/asset registration, front-end delegation, and preview routing;BlockPreviewTestcovers preview markup fidelity.🤖 Generated with Claude Code