Skip to content

Use Custom HTML block for freeform content behind an experiment#79498

Draft
tyxla wants to merge 1 commit into
trunkfrom
try/html-freeform-handler-experiment
Draft

Use Custom HTML block for freeform content behind an experiment#79498
tyxla wants to merge 1 commit into
trunkfrom
try/html-freeform-handler-experiment

Conversation

@tyxla

@tyxla tyxla commented Jun 24, 2026

Copy link
Copy Markdown
Member

What?

Adds a Gutenberg experiment that switches the freeform content handler — the block used to hold non-block (freeform) content that has no block delimiters — from the Classic block (core/freeform) to the Custom HTML block (core/html).

Why?

Exploring whether core/html is a better default home for freeform content than the Classic block (core/freeform). Wrapping it as an opt-in experiment so the behavior change is gated and easy to evaluate.

Part of #78067.

How?

  • packages/block-library/src/index.js — In registerCoreBlocks, the freeform content handler now checks a new window.__experimentalEnableHtmlFreeformHandler global first; when set, it calls setFreeformContentHandlerName( html.name ) instead of the Classic-block path.
  • lib/experimental/editor-settings.php — Bridges the experiment toggle to that JS global (same pattern as the existing form/block experiments).
  • lib/experimental/experiments/load.php — Registers the gutenberg-html-freeform-handler experiment in the Blocks group on the Experiments screen.

This reuses a known-good combination: the widgets editors (edit-widgets, customize-widgets) already use setFreeformContentHandlerName( 'core/html' ), and core/html is always registered, so no extra guard is needed.

Testing Instructions

  1. Build (npm run build or npm start).
  2. Go to Gutenberg → Experiments and enable "Custom HTML for freeform content".
  3. Edit a post containing non-block / freeform content (e.g. seed raw HTML via the Code editor) and confirm it is handled by the Custom HTML block rather than the Classic block.
  4. Disable the experiment and confirm the prior behavior (Classic block) is restored.

Notes

  • Default-off; behavior is unchanged unless the experiment is enabled.
  • When enabled, the experiment switches to core/html unconditionally — including when wp.oldEditor is present — so the Classic-block fallback is disabled while the experiment is on.

Adds a Gutenberg experiment that switches the freeform content handler
(used for non-block content) from the Classic block (core/freeform) to
the Custom HTML block (core/html).

- Gate the freeform handler in registerCoreBlocks on a new
  window.__experimentalEnableHtmlFreeformHandler global.
- Bridge the experiment toggle to that global in editor-settings.php.
- Register the 'gutenberg-html-freeform-handler' experiment on the
  Experiments screen.
@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Jun 24, 2026
@github-actions

Copy link
Copy Markdown

Size Change: +26 B (0%)

Total Size: 7.51 MB

📦 View Changed
Filename Size Change
build/scripts/block-library/index.min.js 324 kB +26 B (+0.01%)

compressed-size-action

@tyxla tyxla self-assigned this Jun 25, 2026
@tyxla tyxla added the [Type] Experimental Experimental feature or API. label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block library /packages/block-library [Type] Experimental Experimental feature or API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant