File size: 1,171 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import React from 'react';
import type { BackgroundSettings } from './types/settings';
import type { BackgroundState } from './types/state';
import { defaultSettings } from './default/settings';
import type { CellPlugin } from '@react-page/editor';
import { lazyLoad } from '@react-page/editor';
const Icon = lazyLoad(() => import('@mui/icons-material/CropLandscape'));
const createPlugin = (settings: BackgroundSettings) => {
const mergedSettings = { ...defaultSettings, ...settings };
const Controls = mergedSettings.Controls;
const Renderer = mergedSettings.Renderer;
const plugin: CellPlugin<BackgroundState> = {
controls: {
type: 'custom',
Component: (props) => <Controls {...props} {...mergedSettings} />,
},
Renderer: (props) => <Renderer {...props} {...mergedSettings} />,
id: 'ory/editor/core/layout/background',
version: 1,
title: mergedSettings.translations?.pluginName,
description: mergedSettings.translations?.pluginDescription,
icon: <Icon />,
createInitialChildren: settings.getInitialChildren,
cellStyle: mergedSettings.cellStyle,
};
return plugin;
};
export default createPlugin;
|