From 42a16659572f1cfeaa32ec06a082fad21dbfd92e Mon Sep 17 00:00:00 2001 From: Nikita Gorin <36075690+NikitaCG@users.noreply.github.com> Date: Tue, 14 May 2024 15:56:39 +0300 Subject: [PATCH] fix: add new option in content transform callback (#939) * fix: add new option in content transform callback * fix: image schema --- src/components/Image/schema.ts | 14 ++++++++++++++ .../containers/Editor/hooks/useEditorState.tsx | 4 ++-- src/editor/types/index.ts | 3 ++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/Image/schema.ts b/src/components/Image/schema.ts index 171e75c4d..735c2405c 100644 --- a/src/components/Image/schema.ts +++ b/src/components/Image/schema.ts @@ -76,6 +76,20 @@ export const ImageProps = { ...ImageDeviceProps, optionName: 'device options', }), + { + type: 'array', + items: filteredItem({ + ...ImageObjectProps, + }), + optionName: 'options list', + }, + { + type: 'array', + items: filteredItem({ + ...ImageDeviceProps, + }), + optionName: 'device options list', + }, ], }; diff --git a/src/editor/containers/Editor/hooks/useEditorState.tsx b/src/editor/containers/Editor/hooks/useEditorState.tsx index e3fa40a81..85de4c81b 100644 --- a/src/editor/containers/Editor/hooks/useEditorState.tsx +++ b/src/editor/containers/Editor/hooks/useEditorState.tsx @@ -51,8 +51,8 @@ export const useEditorState = ({ const isCodeOnlyMode = codeFullscreeModeOn && isCodeEditMode; const transformedContent = useMemo( - () => (transformContent ? transformContent(content, {viewMode}) : content), - [content, transformContent, viewMode], + () => (transformContent ? transformContent(content, {viewMode, editMode}) : content), + [content, transformContent, viewMode, editMode], ); const schema = useMemo(() => generateDefaultSchema(customSchema), [customSchema]); const codeValidator = useCodeValidator(schema); diff --git a/src/editor/types/index.ts b/src/editor/types/index.ts index a09294272..336458294 100644 --- a/src/editor/types/index.ts +++ b/src/editor/types/index.ts @@ -7,7 +7,8 @@ import {EditBlockActions} from '../components/EditBlock/EditBlock'; export type EditorBlockId = number | string; interface ContentTransformersOptions { - viewMode: ViewModeItem; + viewMode?: ViewModeItem; + editMode?: EditModeItem; } export type ContentTransformer = (