From a3edbf4fef5efd8293cb4d6139b2513441cb741e Mon Sep 17 00:00:00 2001 From: James Date: Mon, 15 Aug 2022 18:41:34 -0700 Subject: [PATCH] fix: #568 --- .../forms/field-types/RichText/plugins/withHTML.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/admin/components/forms/field-types/RichText/plugins/withHTML.tsx b/src/admin/components/forms/field-types/RichText/plugins/withHTML.tsx index 371a4590cc..0edc8befab 100644 --- a/src/admin/components/forms/field-types/RichText/plugins/withHTML.tsx +++ b/src/admin/components/forms/field-types/RichText/plugins/withHTML.tsx @@ -10,7 +10,6 @@ const ELEMENT_TAGS = { H4: () => ({ type: 'h4' }), H5: () => ({ type: 'h5' }), H6: () => ({ type: 'h6' }), - IMG: (el) => ({ type: 'image', url: el.getAttribute('src') }), LI: () => ({ type: 'li' }), OL: () => ({ type: 'ol' }), P: () => ({ type: 'p' }), @@ -47,10 +46,15 @@ const deserialize = (el) => { ) { [parent] = el.childNodes; } - const children = Array.from(parent.childNodes) + + let children = Array.from(parent.childNodes) .map(deserialize) .flat(); + if (children.length === 0) { + children = [{ text: '' }]; + } + if (el.nodeName === 'BODY') { return jsx('fragment', {}, children); }