Skip to content

chore: freeze V1 block allow-list from block-library audit (#315) - #332

Merged
ViewFromTheBox merged 1 commit into
release/1.0from
chore/315-block-set-audit
Apr 19, 2026
Merged

ViewFromTheBox merged 1 commit into
release/1.0from
chore/315-block-set-audit

Conversation

@ViewFromTheBox

@ViewFromTheBox ViewFromTheBox commented Apr 19, 2026 •

Copy link
Copy Markdown
Member

Description

Audits every block in @wordpress/block-library v9.44 against the empty-state @wordpress/core-data shim and freezes the V1 enabled_blocks / disabled_blocks config based on that audit. Adds a getEnabledBlockNames() helper on the VisualEditor class that applies the allow-list + deny-list filters, plus a snapshot test that guards the frozen default set.

Closes: #315

Type of Change

  • Enhancement (improves existing functionality)
  • Documentation update

Related Issue

Issue: #315

Motivation and Context

V1 is adopting @wordpress/* packages as a dependency (umbrella #309). Without an explicit allow-list, users hit unsupported-path errors when they insert blocks that depend on WordPress data the core-data shim does not provide (navigation, query, post-, site-, taxonomy widgets). Freezing the allow-list against an empirical audit of every block gives users a clean inserter of blocks guaranteed to render against the shim.

The follow-up work — forking the enabled blocks into artisanpack/* for deep customization — is tracked under the new V2 umbrella #331 and deliberately not scoped here.

Changes Made

  • docs/block-library-audit.md — per-block classification (green / empty-state / crash) for every block in @wordpress/block-library, with rationale for each bucket.
  • config/visual-editor.php — frozen enabled_blocks (27 entries) and disabled_blocks (17 entries) arrays matching the audit. Comment block points readers at the audit doc.
  • src/VisualEditor.php — new getEnabledBlockNames() method. Applies the allow-list, removes deny-listed names, de-duplicates while preserving order, falls back to the full registry when the allow-list is empty.
  • tests/Unit/VisualEditor/EnabledBlockNamesTest.php — snapshot guard against the frozen default set + 4 behavior tests (deny wins, empty-allow fallback, de-dup, non-string filtering).
  • README.md — new "Block defaults" section listing disabled-by-default categories and why, linking to the audit doc.

How Has This Been Tested?

Testing Environment:

  • Operating System: macOS 15
  • PHP Version: 8.4.3
  • Project Version: visual-editor 1.0.0 (release/1.0)

Tests Performed:

  1. ./vendor/bin/pest tests/Unit/VisualEditor/EnabledBlockNamesTest.php --compact — 5 passed, 6 assertions.
  2. ./vendor/bin/pest --compact — full suite 71 passed, 195 assertions.
  3. Manually skimmed docs/block-library-audit.md and the README "Block defaults" section for readability and accuracy against the issue's acceptance criteria.

Accessibility Tests Run

Not applicable — this PR only changes server-side config, a PHP helper, tests, and documentation. No UI surface is added or modified.

  • Keyboard navigation tested — n/a
  • Screen reader tested — n/a
  • Color contrast verified — n/a
  • ARIA labels checked — n/a

Details: No new UI affordances were introduced.

Tests Added

  • Unit tests added/updated
  • Integration tests added/updated
  • All tests passing

Test details: Added tests/Unit/VisualEditor/EnabledBlockNamesTest.php with a snapshot test for the frozen default set plus behavior coverage for allow/deny precedence, empty-allow fallback, de-duplication, and non-string filtering.

Documentation

  • Inline code documentation added
  • README updated
  • Wiki updated
  • API documentation updated

Documentation details: New docs/block-library-audit.md captures the full per-block classification. README gains a "Block defaults" section summarizing the disabled categories. The config/visual-editor.php block section now includes a frozen-defaults note that points to the audit doc.

Screenshots

Not applicable.

Pre-Submission Checklist

  • Followed contributing guidelines
  • Checked for other open PRs for same update
  • Code passes all tests
  • Code has been linted (no lint tooling configured in this package; manually verified conventions against sibling files)
  • Accessibility tests completed (n/a — no UI surface)
  • Code follows project style guide
  • Self-review completed
  • Comments added for complex code
  • No new warnings generated

Summary by CodeRabbit

  • New Features

    • Implemented explicit block enable/disable configuration with curated allow-lists and deny-lists.
  • Documentation

    • Added comprehensive block library audit classifying all available blocks by compatibility status.
    • Updated README with block configuration defaults and override instructions.

Audits every block in @wordpress/block-library v9.44 against the empty-state
@wordpress/core-data shim and freezes the V1 enabled_blocks / disabled_blocks
config based on that audit. Adds a getEnabledBlockNames() helper on the
VisualEditor class that applies the allow-list + deny-list filters and a
snapshot test that guards the frozen default set.

- docs/block-library-audit.md: per-block classification (green / empty-state / crash)
- config/visual-editor.php: frozen enabled_blocks (27) and disabled_blocks (17)
- src/VisualEditor.php: getEnabledBlockNames() with allow-list + deny-list + dedup
- tests/Unit/VisualEditor/EnabledBlockNamesTest.php: snapshot + 4 behavior tests
- README.md: disabled-by-default block summary linking to the audit doc

Closes #315
@coderabbitai

coderabbitai Bot commented Apr 19, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This change completes the M5 block set audit, establishing a frozen allow-list and deny-list of WordPress blocks in config/visual-editor.php, documenting the classification rationale in docs/block-library-audit.md, and implementing getEnabledBlockNames() to deterministically compute the editor's enabled blocks. Users now see only blocks guaranteed to work with the core-data shim, eliminating unsupported-path errors.

Changes

Cohort / File(s) Summary
Documentation & Audit
README.md, docs/block-library-audit.md
Added block defaults section to README explaining the frozen V1 allow/deny lists and per-block classification. Comprehensive audit document classifying all @wordpress/block-library blocks as green (functional), empty-state (no-op with shim), or crash (broken), with migration path once core-data store is replaced.
Configuration
config/visual-editor.php
Populated enabled_blocks with 30+ curated core blocks (content, media, layout, widgets) and disabled_blocks with 20+ data-dependent blocks (navigation, query, post context, taxonomy). Updated comments to document frozen V1 behavior and shim constraints.
Block Enable Logic
src/VisualEditor.php
Added public method getEnabledBlockNames() that applies allow-list from config, falls back to all registered blocks if empty, removes deny-listed entries, and returns de-duplicated list in authoring order. Introduced protected helper stringListFromConfig() for config parsing.
Test Coverage
tests/Unit/VisualEditor/EnabledBlockNamesTest.php
Added comprehensive test suite validating default frozen list, deny-list removal, fallback to all blocks, de-duplication, and handling of invalid/whitespace entries in config arrays.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Blocks now curated, deny-list declared,
A frozen V1 where schemas are spared—
From paragraph to gallery we hop,
While query-loops rest on the config's rooftop. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: freezing the V1 block allow-list based on a completed block-library audit.
Linked Issues check ✅ Passed All acceptance criteria from issue #315 are met: per-block classification document created, config frozen with curated enabled/disabled lists, snapshot test added, and README documentation updated.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #315 objectives; no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/315-block-set-audit

Comment @coderabbitai help to get the list of available commands and usage tips.

@ViewFromTheBox ViewFromTheBox moved this from Backlog to In Review in ArtisanPack UI Overview Apr 19, 2026
@ViewFromTheBox ViewFromTheBox linked an issue Apr 19, 2026 that may be closed by this pull request
7 tasks

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/VisualEditor.php`:
- Around line 113-142: The controller currently returns the full registry
instead of honoring the VisualEditor allow/deny lists; update
VisualEditorBlocksController::index() to call
VisualEditor::getEnabledBlockNames() and use that list to filter the registry
results before returning them (e.g. map the enabled names to the corresponding
entries from $this->registry->all()); ensure you reference the
getEnabledBlockNames() method on the VisualEditor instance (or injected service)
and use the registry->all() payload to pick only entries whose 'name' matches
the enabled list so enabled_blocks/disabled_blocks in config are respected.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3827872d-541a-4b4b-b08d-f67d342de71a

📥 Commits

Reviewing files that changed from the base of the PR and between 6efe2fc and 29a0d18.

📒 Files selected for processing (5)
  • README.md
  • config/visual-editor.php
  • docs/block-library-audit.md
  • src/VisualEditor.php
  • tests/Unit/VisualEditor/EnabledBlockNamesTest.php

Comment thread src/VisualEditor.php
Comment on lines +113 to +142
public function getEnabledBlockNames(): array
{
$enabled = $this->stringListFromConfig( 'artisanpack.visual-editor.enabled_blocks' );
$disabled = $this->stringListFromConfig( 'artisanpack.visual-editor.disabled_blocks' );

$candidates = [] === $enabled
? array_column( $this->registry->all(), 'name' )
: $enabled;

$denyIndex = array_flip( $disabled );
$seen = [];
$result = [];

foreach ( $candidates as $name ) {
if ( ! is_string( $name ) ) {
continue;
}

$normalized = trim( $name );

if ( '' === $normalized || isset( $denyIndex[ $normalized ] ) || isset( $seen[ $normalized ] ) ) {
continue;
}

$seen[ $normalized ] = true;
$result[] = $normalized;
}

return $result;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify call sites and current blocks API behavior.
rg -nP --type=php '\bgetEnabledBlockNames\s*\(' -C2
rg -nP --type=php 'class\s+VisualEditorBlocksController|function\s+index\s*\(|registry->all\s*\(' -C3

Repository: ArtisanPack-UI/visual-editor

Length of output: 5295


🏁 Script executed:

#!/bin/bash
# Check if VisualEditor is used in the controller
cat -n src/Http/Controllers/VisualEditorBlocksController.php

# Search for integration/feature tests of blocks endpoint
find . -type f -name "*.php" -path "*/tests/*" | xargs grep -l "VisualEditorBlocksController\|blocks.*endpoint\|/blocks\|getEnabledBlockNames" | head -10

# Check if there are any route tests
rg -nP --type=php "VisualEditorBlocksController|route.*blocks" tests/

Repository: ArtisanPack-UI/visual-editor

Length of output: 1376


🏁 Script executed:

#!/bin/bash
# Check the blocks controller test
cat -n ./tests/Feature/VisualEditor/BlocksControllerTest.php

# Also check if there are any recent commits about filtering
git log --oneline -n 20 --all -- src/Http/Controllers/VisualEditorBlocksController.php 2>/dev/null | head -5

Repository: ArtisanPack-UI/visual-editor

Length of output: 1330


🏁 Script executed:

#!/bin/bash
# Check the git commit about freezing the allow-list
git show 29a0d18 --stat 2>/dev/null | head -20

# Check if there are config files for enabled/disabled blocks
rg -P --type=php 'enabled_blocks|disabled_blocks' -C2

# Check if there's documentation about block filtering
find . -type f \( -name "*.md" -o -name "*.php" \) | xargs grep -l "enabled_blocks\|disabled_blocks\|getEnabledBlockNames" | head -10

Repository: ArtisanPack-UI/visual-editor

Length of output: 5674


The controller still returns all blocks unfiltered, bypassing the frozen V1 allow-list.

getEnabledBlockNames() was added (commit 29a0d18) but VisualEditorBlocksController::index() never integrated it. The endpoint at line 38 (src/Http/Controllers/VisualEditorBlocksController.php) returns $this->registry->all() unchanged, meaning the configured enabled_blocks and disabled_blocks from config/visual-editor.php are ignored.

Wiring required
+ use ArtisanPackUI\VisualEditor\VisualEditor;
+
  public function __construct(
      protected BlockTypeRegistry $registry,
+     protected VisualEditor $editor,
  ) {
  }

  public function index(): JsonResponse
  {
+     $enabled = array_flip( $this->editor->getEnabledBlockNames() );
+     $blocks  = array_values( array_filter(
+         $this->registry->all(),
+         static fn ( array $block ): bool => isset( $enabled[ $block['name'] ?? '' ] )
+     ) );
-     return response()->json( ['blocks' => $this->registry->all()] );
+     return response()->json( ['blocks' => $blocks] );
  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/VisualEditor.php` around lines 113 - 142, The controller currently
returns the full registry instead of honoring the VisualEditor allow/deny lists;
update VisualEditorBlocksController::index() to call
VisualEditor::getEnabledBlockNames() and use that list to filter the registry
results before returning them (e.g. map the enabled names to the corresponding
entries from $this->registry->all()); ensure you reference the
getEnabledBlockNames() method on the VisualEditor instance (or injected service)
and use the registry->all() payload to pick only entries whose 'name' matches
the enabled list so enabled_blocks/disabled_blocks in config are respected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

M5 · Block set audit

1 participant