-
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
c4b422a
commit 6f53cc9
Showing
4 changed files
with
106 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 ); | ||
} |