Just run into this. My blueprint was derived from a c++ class so I just implemented the following in my class but you could do the same in a blueprint function library.
//! Allow the blueprint to determine whether we are running with the editor or not
UFUNCTION( BlueprintPure, Category = Whatever )
bool IsWithEditor() const
{
#if WITH_EDITOR
return true;
#else
return false;
#endif
}