Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add new option in content transform callback #939

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/components/Image/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ export const ImageProps = {
...ImageDeviceProps,
optionName: 'device options',
}),
{
Copy link
Collaborator Author

@NikitaCG NikitaCG Apr 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for these cases

background:
  image:
    - when: <condition1>
      desktop: <desktop_url>
      mobile: <mobile_url>
    - when: <condition2>
      desktop: <desktop_url>
      mobile: <mobile_url>

type: 'array',
items: filteredItem({
...ImageObjectProps,
}),
optionName: 'options list',
},
{
type: 'array',
items: filteredItem({
...ImageDeviceProps,
}),
optionName: 'device options list',
},
],
};

Expand Down
4 changes: 2 additions & 2 deletions src/editor/containers/Editor/hooks/useEditorState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/editor/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
Loading