PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.2
GenerateBlocks v2.0.2
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / pattern-library / utils.js
generateblocks / src / pattern-library Last commit date
components 1 year ago editor.scss 1 year ago index.js 1 year ago utils.js 2 years ago
utils.js
32 lines
1 export function updateUniqueIds( blocks ) {
2 return blocks.map( ( block ) => {
3 // Check if the block has a uniqueId attribute
4 if ( block.attributes && block.attributes.uniqueId ) {
5 // Generate a new uniqueId
6 const newUniqueId = block.clientId.substr( 2, 9 ).replace( '-', '' );
7
8 // Update the block's uniqueId attribute
9 block.attributes.uniqueId = newUniqueId;
10 }
11 // Recursively update uniqueIds for innerBlocks if they exist
12 if ( block.innerBlocks && block.innerBlocks.length > 0 ) {
13 block.innerBlocks = updateUniqueIds( block.innerBlocks );
14 }
15 return block;
16 } );
17 }
18
19 export function isEmptyContentBlock( selectedBlock ) {
20 if ( 'core/paragraph' === selectedBlock?.name ) {
21 const currentContent = selectedBlock?.attributes?.content;
22
23 if ( 'string' === typeof currentContent ) {
24 return ! currentContent.trim();
25 } else if ( 'object' === typeof currentContent ) {
26 return ! currentContent?.text.trim();
27 }
28 }
29
30 return false;
31 }
32