From 98ad8650f3a7172e245e475fd0833b10869f1760 Mon Sep 17 00:00:00 2001 From: David Matejka Date: Tue, 16 Jan 2024 13:21:21 +0100 Subject: [PATCH 1/2] fix(admin): fix invalid import in richtext --- .../richText/baseEditor/createEditorWithEssentials.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/admin/src/components/bindingFacade/richText/baseEditor/createEditorWithEssentials.tsx b/packages/admin/src/components/bindingFacade/richText/baseEditor/createEditorWithEssentials.tsx index 1925b85c6..8408af732 100644 --- a/packages/admin/src/components/bindingFacade/richText/baseEditor/createEditorWithEssentials.tsx +++ b/packages/admin/src/components/bindingFacade/richText/baseEditor/createEditorWithEssentials.tsx @@ -1,4 +1,4 @@ -import { createElement, ReactElement } from 'react' +import { createElement, isValidElement, ReactElement } from 'react' import { createEditor, Descendant, @@ -134,7 +134,7 @@ export const createEditorWithEssentials = (defaultElementType: string): Editor = if (props.leaf[mark.type] === true) { const markerEl = mark.render({ ...props, children: el }) if (markerEl !== null) { - if (!React.isValidElement(markerEl)) { + if (!isValidElement(markerEl)) { throw new Error(`Mark plugin ${mark.type} returned a non-React element`) } el = markerEl From e735501bdce73d2a1eb7d51e28d599201b6cd923 Mon Sep 17 00:00:00 2001 From: David Matejka Date: Tue, 16 Jan 2024 13:22:44 +0100 Subject: [PATCH 2/2] fix(react-richtext-renderer): fix default field name handling in useRichTextBlocksRSource --- .../src/hooks/useRichTextBlocksSource.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-richtext-renderer/src/hooks/useRichTextBlocksSource.ts b/packages/react-richtext-renderer/src/hooks/useRichTextBlocksSource.ts index 35708819b..b40108a6f 100644 --- a/packages/react-richtext-renderer/src/hooks/useRichTextBlocksSource.ts +++ b/packages/react-richtext-renderer/src/hooks/useRichTextBlocksSource.ts @@ -6,9 +6,9 @@ import { RichTextRendererError } from '../RichTextRendererError' export const useRichTextBlocksSource = ({ deserialize = defaultDeserialize, blocks, - referencesField = 'references', - sourceField = 'source', - referenceDiscriminationField = 'type', + referencesField, + sourceField, + referenceDiscriminationField, }: RichTextBlockSource) => { return useMemo((): RichTextBlock[] => { const sourceFieldResolved = sourceField ?? 'source' @@ -16,7 +16,7 @@ export const useRichTextBlocksSource = { - if (!(sourceField in block)) { + if (!(sourceFieldResolved in block)) { throw new RichTextRendererError( `Found a block without a '${sourceFieldResolved}' field. ` + (sourceField === undefined