: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/utils.js
* Returns the active style from the given className.
* @param {Array} styles Block styles.
* @param {string} className Class name
* @return {Object?} The active style.
function getActiveStyle(styles, className) {
for (const style of new (external_wp_tokenList_default())(className).values()) {
if (style.indexOf('is-style-') === -1) {
const potentialStyleName = style.substring(9);
const activeStyle = styles?.find(({
}) => name === potentialStyleName);
return getDefaultStyle(styles);
* Replaces the active style in the block's className.
* @param {string} className Class name.
* @param {Object?} activeStyle The replaced style.
* @param {Object} newStyle The replacing style.
* @return {string} The updated className.
function replaceActiveStyle(className, activeStyle, newStyle) {
const list = new (external_wp_tokenList_default())(className);
list.remove('is-style-' + activeStyle.name);
list.add('is-style-' + newStyle.name);
* Returns a collection of styles that can be represented on the frontend.
* The function checks a style collection for a default style. If none is found, it adds one to
* act as a fallback for when there is no active style applied to a block. The default item also serves
* as a switch on the frontend to deactivate non-default styles.
* @param {Array} styles Block styles.
* @return {Array<Object?>} The style collection.
function getRenderedStyles(styles) {
if (!styles || styles.length === 0) {
return getDefaultStyle(styles) ? styles : [{
label: (0,external_wp_i18n_namespaceObject._x)('Default', 'block style'),
* Returns a style object from a collection of styles where that style object is the default block style.
* @param {Array} styles Block styles.
* @return {Object?} The default style object, if found.
function getDefaultStyle(styles) {
return styles?.find(style => style.isDefault);
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/use-styles-for-block.js
* @param {WPBlock} block Block object.
* @param {WPBlockType} type Block type settings.
* @return {WPBlock} A generic block ready for styles preview.
function useGenericPreviewBlock(block, type) {
return (0,external_wp_element_namespaceObject.useMemo)(() => {
const example = type?.example;
const blockName = type?.name;
if (example && blockName) {
return (0,external_wp_blocks_namespaceObject.getBlockFromExample)(blockName, {
attributes: example.attributes,
innerBlocks: example.innerBlocks
return (0,external_wp_blocks_namespaceObject.cloneBlock)(block);
}, [type?.example ? block?.name : block, type]);
* @typedef useStylesForBlocksArguments
* @property {string} clientId Block client ID.
* @property {() => void} onSwitch Block style switch callback function.
* @param {useStylesForBlocksArguments} useStylesForBlocks arguments.
* @return {Object} Results of the select methods.
function useStylesForBlocks({
const selector = select => {
const block = getBlock(clientId);
const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
} = select(external_wp_blocks_namespaceObject.store);
styles: getBlockStyles(block.name),
className: block.attributes.className || ''
} = (0,external_wp_data_namespaceObject.useSelect)(selector, [clientId]);
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
const stylesToRender = getRenderedStyles(styles);
const activeStyle = getActiveStyle(stylesToRender, className);
const genericPreviewBlock = useGenericPreviewBlock(block, blockType);
const onSelect = style => {
const styleClassName = replaceActiveStyle(className, activeStyle, style);
updateBlockAttributes(clientId, {
className: styleClassName
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/menu-items.js
const menu_items_noop = () => {};
function BlockStylesMenuItems({
onSwitch = menu_items_noop
if (!stylesToRender || stylesToRender.length === 0) {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
children: stylesToRender.map(style => {
const menuItemText = style.label || style.name;
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
icon: activeStyle.name === style.name ? library_check : null,
onClick: () => onSelect(style),
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-styles-menu.js
function BlockStylesMenu({
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
label: (0,external_wp_i18n_namespaceObject.__)('Styles'),
className: "block-editor-block-switcher__styles__menugroup",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockStylesMenuItems, {
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/utils.js
* Try to find a matching block by a block's name in a provided
* block. We recurse through InnerBlocks and return the reference
* of the matched block (it could be an InnerBlock).
* If no match is found return nothing.
* @param {WPBlock} block The block to try to find a match.
* @param {string} selectedBlockName The block's name to use for matching condition.
* @param {Set} consumedBlocks A set holding the previously matched/consumed blocks.
* @return {WPBlock | undefined} The matched block if found or nothing(`undefined`).
const getMatchingBlockByName = (block, selectedBlockName, consumedBlocks = new Set()) => {
// Check if block has been consumed already.
if (consumedBlocks.has(clientId)) {
if (name === selectedBlockName) {
// Try to find a matching block from InnerBlocks recursively.
for (const innerBlock of innerBlocks) {
const match = getMatchingBlockByName(innerBlock, selectedBlockName, consumedBlocks);
* Find and return the block attributes to retain through
* the transformation, based on Block Type's `role:content`
* attributes. If no `role:content` attributes exist,
* return selected block's attributes.
* @param {string} name Block type's namespaced name.
* @param {Object} attributes Selected block's attributes.
* @return {Object} The block's attributes to retain.
const getRetainedBlockAttributes = (name, attributes) => {
const contentAttributes = (0,external_wp_blocks_namespaceObject.__experimentalGetBlockAttributesNamesByRole)(name, 'content');
if (!contentAttributes?.length) {
return contentAttributes.reduce((_accumulator, attribute) => {
if (attributes[attribute]) {
_accumulator[attribute] = attributes[attribute];
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/use-transformed-patterns.js
* Mutate the matched block's attributes by getting
* which block type's attributes to retain and prioritize
* them in the merging of the attributes.
* @param {WPBlock} match The matched block.
* @param {WPBlock} selectedBlock The selected block.
const transformMatchingBlock = (match, selectedBlock) => {
// Get the block attributes to retain through the transformation.
const retainedBlockAttributes = getRetainedBlockAttributes(selectedBlock.name, selectedBlock.attributes);
...retainedBlockAttributes
* By providing the selected blocks and pattern's blocks
* find the matching blocks, transform them and return them.
* If not all selected blocks are matched, return nothing.
* @param {WPBlock[]} selectedBlocks The selected blocks.
* @param {WPBlock[]} patternBlocks The pattern's blocks.
* @return {WPBlock[]|void} The transformed pattern's blocks or undefined if not all selected blocks have been matched.
const getPatternTransformedBlocks = (selectedBlocks, patternBlocks) => {
// Clone Pattern's blocks to produce new clientIds and be able to mutate the matches.
const _patternBlocks = patternBlocks.map(block => (0,external_wp_blocks_namespaceObject.cloneBlock)(block));
* Keep track of the consumed pattern blocks.
* This is needed because we loop the selected blocks
* and for example we may have selected two paragraphs and
* the pattern's blocks could have more `paragraphs`.
const consumedBlocks = new Set();
for (const selectedBlock of selectedBlocks) {
for (const patternBlock of _patternBlocks) {
const match = getMatchingBlockByName(patternBlock, selectedBlock.name, consumedBlocks);
consumedBlocks.add(match.clientId);
// We update (mutate) the matching pattern block.
transformMatchingBlock(match, selectedBlock);
// No need to loop through other pattern's blocks.
// Bail eary if a selected block has not been matched.
* @typedef {WPBlockPattern & {transformedBlocks: WPBlock[]}} TransformedBlockPattern
* Custom hook that accepts patterns from state and the selected
* blocks and tries to match these with the pattern's blocks.
* If all selected blocks are matched with a Pattern's block,
* we transform them by retaining block's attributes with `role:content`.
* The transformed pattern's blocks are set to a new pattern
* property `transformedBlocks`.
* @param {WPBlockPattern[]} patterns Patterns from state.
* @param {WPBlock[]} selectedBlocks The currently selected blocks.
* @return {TransformedBlockPattern[]} Returns the eligible matched patterns with all the selected blocks.
const useTransformedPatterns = (patterns, selectedBlocks) => {
return (0,external_wp_element_namespaceObject.useMemo)(() => patterns.reduce((accumulator, _pattern) => {
const transformedBlocks = getPatternTransformedBlocks(selectedBlocks, _pattern.blocks);
}, []), [patterns, selectedBlocks]);
/* harmony default export */ const use_transformed_patterns = (useTransformedPatterns);
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/pattern-transformations-menu.js
CompositeV2: pattern_transformations_menu_Composite,
CompositeItemV2: pattern_transformations_menu_CompositeItem,
useCompositeStoreV2: pattern_transformations_menu_useCompositeStore
} = unlock(external_wp_components_namespaceObject.privateApis);
function PatternTransformationsMenu({
const [showTransforms, setShowTransforms] = (0,external_wp_element_namespaceObject.useState)(false);
const patterns = use_transformed_patterns(statePatterns, blocks);
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
className: "block-editor-block-switcher__pattern__transforms__menugroup",
children: [showTransforms && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreviewPatternsPopover, {
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
setShowTransforms(!showTransforms);
children: (0,external_wp_i18n_namespaceObject.__)('Patterns')
function PreviewPatternsPopover({
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
className: "block-editor-block-switcher__popover__preview__parent",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
className: "block-editor-block-switcher__popover__preview__container",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover, {
className: "block-editor-block-switcher__preview__popover",
position: "bottom right",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
className: "block-editor-block-switcher__preview is-pattern-list-preview",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pattern_transformations_menu_BlockPatternsList, {
function pattern_transformations_menu_BlockPatternsList({
const composite = pattern_transformations_menu_useCompositeStore();
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pattern_transformations_menu_Composite, {
className: "block-editor-block-switcher__preview-patterns-container",
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Patterns list'),