-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only set block editing mode on first load
- Loading branch information
1 parent
57470e9
commit a54ba6c
Showing
4 changed files
with
107 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from './constants'; | ||
|
||
export function hasOverridableAttributes( block ) { | ||
return ( | ||
Object.keys( PARTIAL_SYNCING_SUPPORTED_BLOCKS ).includes( | ||
block.name | ||
) && | ||
!! block.attributes.metadata?.bindings && | ||
Object.values( block.attributes.metadata.bindings ).some( | ||
( binding ) => binding.source === 'core/pattern-overrides' | ||
) | ||
); | ||
} | ||
|
||
export function hasOverridableBlocks( blocks ) { | ||
return blocks.some( ( block ) => { | ||
if ( hasOverridableAttributes( block ) ) return true; | ||
return hasOverridableBlocks( block.innerBlocks ); | ||
} ); | ||
} | ||
|
||
export function getOverridableAttributes( block ) { | ||
return Object.entries( block.attributes.metadata.bindings ) | ||
.filter( | ||
( [ , binding ] ) => binding.source === 'core/pattern-overrides' | ||
) | ||
.map( ( [ attributeKey ] ) => attributeKey ); | ||
} |