devextreme-react
Version:
DevExtreme React UI and Visualization Components
255 lines (253 loc) • 8.39 kB
JavaScript
/*!
* devextreme-react
* Version: 24.2.6
* Build date: Mon Mar 17 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file in the root of the project for details.
*
* https://github.com/DevExpress/devextreme-react
*/
"use client";
import * as React from "react";
import { memo, forwardRef, useImperativeHandle, useRef, useMemo } from "react";
import dxHtmlEditor from "devextreme/ui/html_editor";
import { Component as BaseComponent } from "./core/component";
import NestedOption from "./core/nested-option";
const HtmlEditor = memo(forwardRef((props, ref) => {
const baseRef = useRef(null);
useImperativeHandle(ref, () => ({
instance() {
return baseRef.current?.getInstance();
}
}), [baseRef.current]);
const subscribableOptions = useMemo(() => (["value"]), []);
const independentEvents = useMemo(() => (["onContentReady", "onDisposing", "onFocusIn", "onFocusOut", "onInitialized", "onValueChanged"]), []);
const defaults = useMemo(() => ({
defaultValue: "value",
}), []);
const expectedChildren = useMemo(() => ({
converter: { optionName: "converter", isCollectionItem: false },
imageUpload: { optionName: "imageUpload", isCollectionItem: false },
mediaResizing: { optionName: "mediaResizing", isCollectionItem: false },
mention: { optionName: "mentions", isCollectionItem: true },
tableContextMenu: { optionName: "tableContextMenu", isCollectionItem: false },
tableResizing: { optionName: "tableResizing", isCollectionItem: false },
toolbar: { optionName: "toolbar", isCollectionItem: false },
variables: { optionName: "variables", isCollectionItem: false }
}), []);
return (React.createElement((BaseComponent), {
WidgetClass: dxHtmlEditor,
ref: baseRef,
subscribableOptions,
independentEvents,
defaults,
expectedChildren,
...props,
}));
}));
const _componentConverter = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "converter",
},
});
};
const Converter = Object.assign(_componentConverter, {
componentType: "option",
});
const _componentFileUploaderOptions = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "fileUploaderOptions",
DefaultsProps: {
defaultValue: "value"
},
},
});
};
const FileUploaderOptions = Object.assign(_componentFileUploaderOptions, {
componentType: "option",
});
const _componentImageUpload = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "imageUpload",
ExpectedChildren: {
fileUploaderOptions: { optionName: "fileUploaderOptions", isCollectionItem: false },
tab: { optionName: "tabs", isCollectionItem: true }
},
},
});
};
const ImageUpload = Object.assign(_componentImageUpload, {
componentType: "option",
});
const _componentItem = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
ExpectedChildren: {
item: { optionName: "items", isCollectionItem: true }
},
TemplateProps: [{
tmplOption: "template",
render: "render",
component: "component"
}, {
tmplOption: "menuItemTemplate",
render: "menuItemRender",
component: "menuItemComponent"
}],
},
});
};
const Item = Object.assign(_componentItem, {
componentType: "option",
});
const _componentMediaResizing = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "mediaResizing",
},
});
};
const MediaResizing = Object.assign(_componentMediaResizing, {
componentType: "option",
});
const _componentMention = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "mentions",
IsCollectionItem: true,
TemplateProps: [{
tmplOption: "itemTemplate",
render: "itemRender",
component: "itemComponent"
}, {
tmplOption: "template",
render: "render",
component: "component"
}],
},
});
};
const Mention = Object.assign(_componentMention, {
componentType: "option",
});
const _componentTab = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "tabs",
IsCollectionItem: true,
},
});
};
const Tab = Object.assign(_componentTab, {
componentType: "option",
});
const _componentTableContextMenu = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "tableContextMenu",
ExpectedChildren: {
item: { optionName: "items", isCollectionItem: true },
tableContextMenuItem: { optionName: "items", isCollectionItem: true }
},
},
});
};
const TableContextMenu = Object.assign(_componentTableContextMenu, {
componentType: "option",
});
const _componentTableContextMenuItem = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
ExpectedChildren: {
item: { optionName: "items", isCollectionItem: true }
},
TemplateProps: [{
tmplOption: "template",
render: "render",
component: "component"
}],
},
});
};
const TableContextMenuItem = Object.assign(_componentTableContextMenuItem, {
componentType: "option",
});
const _componentTableResizing = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "tableResizing",
},
});
};
const TableResizing = Object.assign(_componentTableResizing, {
componentType: "option",
});
const _componentToolbar = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "toolbar",
ExpectedChildren: {
item: { optionName: "items", isCollectionItem: true },
toolbarItem: { optionName: "items", isCollectionItem: true }
},
},
});
};
const Toolbar = Object.assign(_componentToolbar, {
componentType: "option",
});
const _componentToolbarItem = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "items",
IsCollectionItem: true,
TemplateProps: [{
tmplOption: "menuItemTemplate",
render: "menuItemRender",
component: "menuItemComponent"
}, {
tmplOption: "template",
render: "render",
component: "component"
}],
},
});
};
const ToolbarItem = Object.assign(_componentToolbarItem, {
componentType: "option",
});
const _componentVariables = (props) => {
return React.createElement((NestedOption), {
...props,
elementDescriptor: {
OptionName: "variables",
},
});
};
const Variables = Object.assign(_componentVariables, {
componentType: "option",
});
export default HtmlEditor;
export { HtmlEditor, Converter, FileUploaderOptions, ImageUpload, Item, MediaResizing, Mention, Tab, TableContextMenu, TableContextMenuItem, TableResizing, Toolbar, ToolbarItem, Variables };