Assuming that the metafield is always a Rich Text metafield, you can edit the code to the following:
{%- case block.settings.content %}
{% when 'description' %}
{{product.description}}
{% when 'reviews' %}
{% if settings.reviewApp == "loox" %}
{{ product.metafields.loox.reviews }}
{% elsif settings.reviewApp == "shopifyReviews" %}
{{ product.metafields.spr.reviews }}
{% elsif settings.reviewApp == "alireviews" %}
{{ shop.metafields.review_collector.review_code }}
{% endif %}
{% when 'custom' %}
{{ block.settings.customContent }}
{% when 'metafield' %}
{% assign metafield = product.metafields[block.settings.metafieldNS][block.settings.metafieldKey] %}
{% if metafield contains '"children":' %}
{{ metafield | metafield_tag }}
{% else %}
{{ metafield }}
{% endif %}
{% when 'page' %}
{% assign page = pages[block.settings.page] %}
{{page.content}}
{% when 'productPage' %}
{% assign handle = 'content-' | append: product.handle %}
{% assign page = pages[handle] %}
{% assign price = product.price | money | strip_html %}
{% assign prediscount = product.compare_at_price_max | money | strip_html %}
{{page.content | replace: '%product%', product.title | replace: '%brand%', product.vendor | replace: '%price%', price | replace: '%prediscount%', prediscount}}
{% endcase %}
{% comment %}
{% blockdef %}
{% endblockdef %}
{% endcomment %}
Note that this does a simple if else check to see if it contains the string of text ‘“children”:’ (all Rich Text metafields have this text inside).
Obviously make sure you’ve got a copy of your code and let me know if you have any issues.