2024-05-28 08:40:16 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import {
|
|
|
|
BlockPopover,
|
|
|
|
// @ts-expect-error No types for this exist yet.
|
|
|
|
} from '@wordpress/block-editor';
|
|
|
|
|
2024-07-16 10:19:00 +00:00
|
|
|
const isPatternToolkitFullComposabilityFeatureFlagEnabled = () => {
|
2024-07-16 09:22:01 +00:00
|
|
|
// @ts-expect-error temp fix
|
|
|
|
if ( window.parent?.window.cys_aiFlow ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-05-28 08:40:16 +00:00
|
|
|
return window.wcAdminFeatures[ 'pattern-toolkit-full-composability' ];
|
|
|
|
};
|
|
|
|
|
2024-07-16 10:19:00 +00:00
|
|
|
const isGutenbergAPIAvailableForFullComposability = () => {
|
2024-05-28 08:40:16 +00:00
|
|
|
return [ BlockPopover ].every(
|
|
|
|
( api ) => api !== undefined && api !== null
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const isFullComposabilityFeatureAndAPIAvailable = () => {
|
2024-07-16 09:22:01 +00:00
|
|
|
// @ts-expect-error temp fix
|
|
|
|
if ( window.parent?.window.cys_aiFlow ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-05-28 08:40:16 +00:00
|
|
|
return (
|
|
|
|
isPatternToolkitFullComposabilityFeatureFlagEnabled() &&
|
|
|
|
isGutenbergAPIAvailableForFullComposability()
|
|
|
|
);
|
|
|
|
};
|