dmeditor
Version:
dmeditor is a block-style visual editor. Data is in json format.
133 lines (132 loc) • 3.76 kB
TypeScript
import { ComponentType } from 'react';
import type { DME, DMEData } from '../types';
export type BrowseLinkCallbackParams = string;
export type BrowseImageCallbackParams = DME.ImageInfo[];
export interface SavedBlockData {
name: string;
image?: string;
savedData: {
id?: string;
type?: string;
style?: {
[style: string]: string;
};
data: DMEData.DefaultDataType;
children?: Array<DMEData.DefaultBlockType>;
};
}
export interface CallbackConfig {
browseImage?: ComponentType<{
value: BrowseImageCallbackParams;
onChange: (value: BrowseImageCallbackParams) => void;
multiple?: boolean;
}>;
browseLink?: ComponentType<{
value: BrowseLinkCallbackParams;
onChange: (value: BrowseLinkCallbackParams) => void;
}>;
canEditControl?: (block: DMEData.Block) => boolean;
getSavedBlocks?: (widget: string) => Array<SavedBlockData>;
}
export interface widgetConfig {
allowedTypes?: Array<string>;
[prop: string]: any;
}
export interface DMEConfigType {
general?: {
projectStyles?: {
default: string;
[prop: string]: string;
};
imagePath?: (path: string, size?: 'thumbnail' | string) => string;
deviceWidth?: {
mobile: number;
tablet: number;
pc: number;
};
};
editor: {
defaultTheme: string;
favouriteWidgets?: Array<string>;
zIndex?: number;
enableEditControl?: boolean;
defaultStyle?: {
[widget: string]: {
[styleKey: string]: string;
};
};
categories?: Array<DME.WidgetCategory>;
ui: {
[variable: string]: string;
};
};
widgets?: {
[widget: string]: widgetConfig;
};
plugins?: {
imageHandlers?: Array<React.ComponentType<{
image: DME.ImageInfo;
onChange: (imageInfo: DME.ImageInfo) => void;
}>>;
[plugin: string]: any;
};
}
declare const dmeConfig: {
general: {
projectStyles: {
default: string;
[prop: string]: string;
};
imagePath: (path: string, size?: 'thumbnail' | string) => string;
deviceWidth: {
mobile: number;
tablet: number;
pc: number;
};
themes: Array<DME.PageTheme>;
[prop: string]: string | number | boolean | Record<string, any>;
};
editor: {
defaultTheme: string;
favouriteWidgets: Array<string>;
defaultStyle: {
[widget: string]: {
[styleKey: string]: string;
};
};
enableEditControl: boolean;
categories: Array<DME.WidgetCategory>;
settingGroups: {
[key: string]: string;
};
richText: {
fontFamily: Array<{
value: string;
label: string;
}>;
fontSize: Array<{
value: string;
label: string;
}>;
};
zIndex: number;
ui: {
[variable: string]: string;
};
};
widgets: {
[widget: string]: widgetConfig;
};
plugins: {
imageHandlers: Array<React.ComponentType<{
image: DME.ImageInfo;
onChange: (imageInfo: DME.ImageInfo) => void;
}>>;
[plugin: string]: any;
};
callbacks: CallbackConfig;
};
declare const setDMEditorConfig: (config: DMEConfigType) => void;
declare const setDMEditorCallback: (config: CallbackConfig) => void;
export * from './style';
export { dmeConfig, setDMEditorConfig, setDMEditorCallback };