PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / src / FormBuilder / resources / js / form-builder / src / common / revertMissingBlocks.ts

revertMissingBlocks.ts in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at src/FormBuilder/resources/js/form-builder/src/common/revertMissingBlocks.ts

23 lines 873 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {BlockInstance, getBlockType, getUnregisteredTypeHandlerName} from '@wordpress/blocks';
2
3 /**
4 * Replaces any missing blocks with the original block type.
5 *
6 * This is used to preserve the original block type definition when persisting the blocks to the database.
7 *
8 * @since 3.0.0
9 */
10 export default function revertMissingBlocks(blocks: BlockInstance[]) {
11 blocks.forEach((sectionBlock, sectionBlockIndex) => {
12 sectionBlock.innerBlocks?.forEach((innerBlock, innerBlockIndex) => {
13 const blockType = getBlockType(innerBlock.name);
14
15 if (blockType.name === getUnregisteredTypeHandlerName() && innerBlock.attributes?.originalContent) {
16 blocks[sectionBlockIndex].innerBlocks[innerBlockIndex] = JSON.parse(
17 innerBlock.attributes.originalContent
18 );
19 }
20 });
21 });
22 }
23