Menu Close

Editor UI runtime bag for extensions

The Blocksify editor UI API, exposed as the runtime bag on window.blocksify.editor, provides curated editor components and helper utilities to extensions.

Use the runtime bag when an extension needs Blocksify’s active editor primitives, the Repeater’s frame and controls, the Popover’s frame, responsive helpers, interaction presets, icon helpers, and matching editor CSS without bundling a copy of the Free plugin source.

What is the runtime bag?

The runtime bag is the public editor UI surface exposed by the blocksify-editor-ui script handle. Free enqueues the handle in the block editor and assigns a frozen object to window.blocksify.editor.

Published runtime bag.

window.blocksify.editor = Object.freeze( {
    ...editorUi,
    Repeater,
    Popover,
    ResponsiveField,
    StylingRepeater,
    buildSparsePreviewCss,
    GapControl,
    formatGap,
    interactions,
    generateUid,
    useStableUid,
    blockUidClass,
    resolveResponsive,
    responsiveKey,
    getResponsiveInheritedFrom,
    useActiveDevice,
    useIsHoverMode,
    IconLibrary,
    SwatchButton,
    renderIcon,
    isRenderableIcon,
    version: 2,
} );

The editorUi bag includes ten primitives: PopoverSection, Fieldset, FieldRow, TextField, Select, SegmentedControl, SegmentedTabs, OptionList, NumericField, and RecordPicker. The handle also bundles the related frame and control styles.

Why extensions should use it

A Pro-owned block or inspector panel does not automatically receive the same ui prop that Free passes to catalog editors. The runtime bag gives that code the active Free plugin’s components at runtime.

  • Extensions avoid snapshot drift from bundled component copies.
  • Free can ship component CSS through the same handle.
  • Pro can depend on the handle the same way WordPress packages depend on wp.element or wp.components.

Exported keys

UI primitives

KeyWhat it is
PopoverSectionSection wrapper for grouped popover controls.
FieldsetGrouped field container with legend support.
FieldRowRow layout for one editor field and its label.
TextFieldText input primitive used by Blocksify controls.
SelectSelect input primitive for option lists.
SegmentedControlSegmented option control for compact choices.
SegmentedTabsSegmented tab control for switching related panels.
OptionListSelectable list primitive for option groups.
NumericFieldNumeric input primitive with Blocksify field behavior.
RecordPickerRecord selection primitive for post-like data.

Styling and layout

KeyWhat it is
RepeaterShared frame and controls for ordered editor items.
PopoverShared popover frame for Blocksify editor controls.
ResponsiveFieldResponsive-aware field wrapper.
StylingRepeaterStyling repeater control for rule groups and properties.
buildSparsePreviewCssBuilds sparse preview CSS from styling values.
GapControlGap editor control used by Blocksify layout UI.
formatGapFormats gap values for control display and output.

Responsive helpers and uid helpers

KeyWhat it is
generateUidCreates a Blocksify uid string.
useStableUidReact hook that keeps a stable uid on block attributes.
blockUidClassBuilds the CSS class for a block uid.
resolveResponsiveResolves a responsive value for the current device.
responsiveKeyBuilds a device-specific responsive attribute key.
getResponsiveInheritedFromFinds the device that supplies an inherited responsive value.
useActiveDeviceReact hook for the active editor preview device.
useIsHoverModeReact hook for Blocksify hover editing mode.

Icons and interactions

KeyWhat it is
IconLibraryBlocksify icon library data for editor UI.
SwatchButtonSwatch button component for visual choices.
renderIconRenders a Blocksify icon value.
isRenderableIconChecks whether an icon value can be rendered.
interactionsInteraction presets and helpers exported for editor controls.
versionRuntime bag version. Blocksify 1.2.0 exposes 2.

DEWP wiring

Use Dependency Extraction Webpack Plugin request mapping so imports resolve to the runtime global and the generated asset file depends on blocksify-editor-ui.

Map the import to the global.

// webpack.config.js
requestToExternal: ( request ) =>
    request === '@blocksify-free/editor' ? [ 'blocksify', 'editor' ] : undefined,
requestToHandle: ( request ) =>
    request === '@blocksify-free/editor' ? 'blocksify-editor-ui' : undefined,

Import named components in the extension.

import { Repeater, FieldRow, NumericField } from '@blocksify-free/editor';

At runtime, that import resolves to window.blocksify.editor.Repeater, window.blocksify.editor.FieldRow, and window.blocksify.editor.NumericField. The generated asset dependencies ensure the handle loads first.

Additive contract

The bag is additive. Blocksify can add keys, but exposed keys should not be removed or renamed without a deprecation path because every key is a public API commitment.

Use version for feature detection when an extension can run against more than one installed Free version.

Guard runtime keys.

const editor = window.blocksify && window.blocksify.editor;

if ( editor && editor.version >= 2 && editor.SegmentedTabs ) {
    // Use the shared Blocksify tabs primitive.
}

What belongs in the bag?

Exposure is curated, not automatic. A new primitive should be added to the shared editorUi bag; a new shared frame or control component should be imported by the editor UI entry and assigned a key.

Use the broader hooks overview for PHP filters, block registration surfaces, and JavaScript hook filters. Use this runtime bag only for shared editor UI components, such as extension editors for Content Loop or Form integrations.

Was this helpful?

0

Updated