Repository navigation
feat: M1 · install Gutenberg packages and mount sandbox canvas #327
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
Merged
ViewFromTheBox
merged 2 commits into
release/1.0
from
feature/311-gutenberg-packages-installed
Apr 19, 2026
Merged
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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
| "extends": [ | ||
| "config:recommended", | ||
| ":semanticCommits" | ||
| ], | ||
| "packageRules": [ | ||
| { | ||
| "description": "Group all @wordpress/* package updates into a single PR on a two-week cadence, and keep them exact-pinned so Gutenberg's cross-package version coupling stays in lockstep.", | ||
| "matchPackagePrefixes": ["@wordpress/"], | ||
| "groupName": "gutenberg", | ||
| "groupSlug": "gutenberg", | ||
| "schedule": ["every 2 weeks on monday"], | ||
| "rangeStrategy": "pin", | ||
| "labels": ["dependencies", "gutenberg"] | ||
| } | ||
| ] | ||
| } |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>ArtisanPack Visual Editor — Gutenberg Sandbox (dev)</title> | ||
| </head> | ||
| <body> | ||
| <div id="ve-sandbox-root"></div> | ||
| <script type="module" src="./main.tsx"></script> | ||
| </body> | ||
| </html> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { createElement } from 'react'; | ||
| import { createRoot } from 'react-dom/client'; | ||
|
|
||
| /** | ||
| * M1 sandbox entry (#311). Dynamically imports the Gutenberg-using module so | ||
| * `@wordpress/*` lands in a dedicated `gutenberg` chunk (see vite.config.ts) | ||
| * that only downloads when the editor mounts. | ||
| */ | ||
|
|
||
| const MOUNT_ID = 've-sandbox-root'; | ||
|
|
||
| async function bootSandbox(): Promise<void> { | ||
| const container = document.getElementById(MOUNT_ID); | ||
|
|
||
| if (!container) { | ||
| console.error( | ||
| `visual-editor sandbox: missing #${MOUNT_ID} mount point. Render the temporary /ve-sandbox Blade route or include a <div id="${MOUNT_ID}">.` | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const { SandboxEditor } = await import('./sandbox-editor'); | ||
|
|
||
| createRoot(container).render(createElement(SandboxEditor)); | ||
| } | ||
|
|
||
| void bootSandbox(); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { useState } from 'react'; | ||
| import { createBlock, type BlockInstance } from '@wordpress/blocks'; | ||
| import { | ||
| BlockEditorProvider, | ||
| BlockList, | ||
| BlockTools, | ||
| WritingFlow, | ||
| } from '@wordpress/block-editor'; | ||
| import { registerCoreBlocks } from '@wordpress/block-library'; | ||
| import { Popover, SlotFillProvider } from '@wordpress/components'; | ||
| import { __ } from '@wordpress/i18n'; | ||
|
|
||
| import '@wordpress/components/build-style/style.css'; | ||
| import '@wordpress/block-editor/build-style/style.css'; | ||
| import '@wordpress/block-editor/build-style/content.css'; | ||
| import '@wordpress/block-library/build-style/style.css'; | ||
| import '@wordpress/block-library/build-style/editor.css'; | ||
|
|
||
| registerCoreBlocks(); | ||
|
|
||
| const initialBlocks: BlockInstance[] = [ | ||
| createBlock('core/paragraph', { | ||
| content: __( | ||
| 'Hello from the Gutenberg sandbox.', | ||
| 'artisanpack-visual-editor' | ||
| ), | ||
| }), | ||
| ]; | ||
|
|
||
| /** | ||
| * Minimal `BlockEditorProvider` mount used to prove `@wordpress/*` imports | ||
| * cleanly and the Gutenberg canvas renders. M2+ replaces this with the real | ||
| * editor shell; see docs/gutenberg-adoption.md and issue #311. | ||
| */ | ||
| export function SandboxEditor(): JSX.Element { | ||
| const [blocks, setBlocks] = useState<BlockInstance[]>(initialBlocks); | ||
|
|
||
| return ( | ||
| <SlotFillProvider> | ||
| <BlockEditorProvider | ||
| value={blocks} | ||
| onInput={(next: BlockInstance[]) => setBlocks(next)} | ||
| onChange={(next: BlockInstance[]) => setBlocks(next)} | ||
| > | ||
| <div className="editor-styles-wrapper"> | ||
| <BlockTools> | ||
| <WritingFlow> | ||
| <BlockList /> | ||
| </WritingFlow> | ||
| </BlockTools> | ||
| </div> | ||
| <Popover.Slot /> | ||
| </BlockEditorProvider> | ||
| </SlotFillProvider> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>ArtisanPack Visual Editor — Gutenberg Sandbox</title> | ||
| @viteReactRefresh | ||
| {{-- Temporary sandbox for M1 (#311). Proves @wordpress/* packages import cleanly | ||
| and lazy-load into a dedicated `gutenberg` chunk. Deleted once the real editor | ||
| shell ships (M3+); see docs/gutenberg-adoption.md. --}} | ||
| @vite(['resources/js/visual-editor/sandbox/main.tsx']) | ||
| </head> | ||
| <body> | ||
| <div id="ve-sandbox-root"></div> | ||
| </body> | ||
| </html> |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| // M1 sandbox wiring tests (#311). The /ve-sandbox route mounts an empty | ||
| // BlockEditorProvider to prove @wordpress/* packages import cleanly and | ||
| // lazy-load. Removed when the real editor shell ships (M3+). | ||
|
|
||
| $repoRoot = __DIR__.'/../..'; | ||
| $viewPath = $repoRoot.'/resources/views/sandbox/index.blade.php'; | ||
| $routesPath = $repoRoot.'/routes/web.php'; | ||
| $mainEntryPath = $repoRoot.'/resources/js/visual-editor/sandbox/main.tsx'; | ||
| $sandboxEditorPath = $repoRoot.'/resources/js/visual-editor/sandbox/sandbox-editor.tsx'; | ||
| $packageJsonPath = $repoRoot.'/package.json'; | ||
| $viteConfigPath = $repoRoot.'/vite.config.ts'; | ||
| $renovateConfigPath = $repoRoot.'/.github/renovate.json'; | ||
|
|
||
| test('sandbox blade view exists and renders the ve-sandbox-root element', function () use ($viewPath) { | ||
| expect(file_exists($viewPath))->toBeTrue(); | ||
|
|
||
| $contents = file_get_contents($viewPath); | ||
|
|
||
| expect($contents)->toContain('id="ve-sandbox-root"'); | ||
| expect($contents)->toContain("@vite(['resources/js/visual-editor/sandbox/main.tsx'])"); | ||
| }); | ||
|
|
||
| test('package routes register the /ve-sandbox path', function () use ($routesPath) { | ||
| $contents = file_get_contents($routesPath); | ||
|
|
||
| expect($contents)->toContain("Route::get('/ve-sandbox'"); | ||
| expect($contents)->toContain('visual-editor::sandbox.index'); | ||
| expect($contents)->toContain("->name('visual-editor.sandbox')"); | ||
| }); | ||
|
|
||
| test('sandbox main entry targets #ve-sandbox-root and dynamic-imports the gutenberg module', function () use ($mainEntryPath) { | ||
| $contents = file_get_contents($mainEntryPath); | ||
|
|
||
| expect($contents)->toContain("'ve-sandbox-root'"); | ||
| expect($contents)->toContain('console.error'); | ||
| expect($contents)->toContain("await import('./sandbox-editor')"); | ||
| }); | ||
|
|
||
| test('sandbox editor component mounts BlockEditorProvider against a hardcoded block tree', function () use ($sandboxEditorPath) { | ||
| $contents = file_get_contents($sandboxEditorPath); | ||
|
|
||
| expect($contents)->toContain("from '@wordpress/blocks'"); | ||
| expect($contents)->toContain("from '@wordpress/block-editor'"); | ||
| expect($contents)->toContain("from '@wordpress/block-library'"); | ||
| expect($contents)->toContain("from '@wordpress/components'"); | ||
| expect($contents)->toContain("from '@wordpress/i18n'"); | ||
| expect($contents)->toContain('BlockEditorProvider'); | ||
| expect($contents)->toContain('registerCoreBlocks()'); | ||
| expect($contents)->toContain('createBlock('); | ||
| }); | ||
|
|
||
| test('package.json pins the @wordpress/* dependencies exactly', function () use ($packageJsonPath) { | ||
| $packageJson = json_decode(file_get_contents($packageJsonPath), true); | ||
|
|
||
| expect($packageJson)->toBeArray(); | ||
|
|
||
| $required = [ | ||
| '@wordpress/blocks', | ||
| '@wordpress/block-editor', | ||
| '@wordpress/block-library', | ||
| '@wordpress/components', | ||
| '@wordpress/i18n', | ||
| ]; | ||
|
|
||
| foreach ($required as $pkg) { | ||
| expect($packageJson['dependencies'])->toHaveKey($pkg); | ||
|
|
||
| $version = $packageJson['dependencies'][$pkg]; | ||
| expect($version) | ||
| ->not->toStartWith('^') | ||
| ->not->toStartWith('~') | ||
| ->toMatch('/^\d+\.\d+\.\d+/', "{$pkg} must be exact-pinned, got: {$version}"); | ||
| } | ||
| }); | ||
|
|
||
| test('package.json pins react and react-dom exactly to match Gutenberg peers', function () use ($packageJsonPath) { | ||
| $packageJson = json_decode(file_get_contents($packageJsonPath), true); | ||
|
|
||
| foreach (['react', 'react-dom'] as $pkg) { | ||
| $version = $packageJson['dependencies'][$pkg]; | ||
| expect($version) | ||
| ->not->toStartWith('^') | ||
| ->not->toStartWith('~') | ||
| ->toStartWith('18.'); | ||
| } | ||
| }); | ||
|
|
||
| test('vite config emits a gutenberg chunk and registers the sandbox entry', function () use ($viteConfigPath) { | ||
| $contents = file_get_contents($viteConfigPath); | ||
|
|
||
| expect($contents)->toContain('sandbox:'); | ||
| expect($contents)->toContain('manualChunks'); | ||
| expect($contents)->toContain("'/node_modules/@wordpress/'"); | ||
| expect($contents)->toContain("return 'gutenberg'"); | ||
| }); | ||
|
|
||
| test('renovate config groups @wordpress/* updates on a two-week cadence', function () use ($renovateConfigPath) { | ||
| expect(file_exists($renovateConfigPath))->toBeTrue(); | ||
|
|
||
| $config = json_decode(file_get_contents($renovateConfigPath), true); | ||
|
|
||
| expect($config)->toBeArray(); | ||
| expect($config)->toHaveKey('packageRules'); | ||
|
|
||
| $gutenbergRule = null; | ||
| foreach ($config['packageRules'] as $rule) { | ||
| if (($rule['groupName'] ?? null) === 'gutenberg') { | ||
| $gutenbergRule = $rule; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| expect($gutenbergRule)->not->toBeNull(); | ||
| expect($gutenbergRule['matchPackagePrefixes'] ?? [])->toContain('@wordpress/'); | ||
| expect($gutenbergRule['schedule'] ?? [])->toContain('every 2 weeks on monday'); | ||
| expect($gutenbergRule['rangeStrategy'] ?? null)->toBe('pin'); | ||
| }); |
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
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.
🧩 Analysis chain
🏁 Script executed:
Repository: ArtisanPack-UI/visual-editor
Length of output: 1326
🏁 Script executed:
Repository: ArtisanPack-UI/visual-editor
Length of output: 1417
🏁 Script executed:
Repository: ArtisanPack-UI/visual-editor
Length of output: 3249
Address
manifest: falsewith Laravel's@vite()directive in production.The Rollup configuration is otherwise correct—multi-entry setup, hashing for cache busting, and
@wordpress/*module isolation work as intended. However,manifest: falseon line 69 creates a production blocker:@vite()helper in production requiresmanifest.jsonto resolve hashed asset paths[name].js), but chunks/assets are hashed (chunks/[name]-[hash].js,assets/[name]-[hash][extname])@vite()cannot load the hashed dependencies, breaking asset resolutionGenerate the manifest or use a Laravel Vite plugin to handle hashing, or ensure this is a dev-only build and production uses a separate config.
🤖 Prompt for AI Agents