@topconsultnpm/sdkui-react-beta 6.12.72 → 6.12.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,8 @@ export interface ITMHtmlEditor {
|
|
4
4
|
width?: string;
|
5
5
|
/** Height of the editor (e.g., '300px') */
|
6
6
|
height?: string;
|
7
|
+
/** Initial value markup */
|
8
|
+
initialMarkup?: string;
|
7
9
|
/** Callback function triggered when the content value changes */
|
8
10
|
onValueChanged?: (e: {
|
9
11
|
value: string;
|
@@ -22,6 +24,8 @@ export interface ITMHtmlEditor {
|
|
22
24
|
validationItems?: Array<ValidationItem>;
|
23
25
|
/** If true, enables rich text editing mode */
|
24
26
|
isEditorEnabled?: boolean;
|
27
|
+
/** Defines the toolbar layout mode (compact: Shows a minimal toolbar, expanded: Displays the full toolbar */
|
28
|
+
toolbarMode?: 'compact' | 'expanded';
|
25
29
|
}
|
26
30
|
declare const TMHtmlEditor: (props: ITMHtmlEditor) => import("react/jsx-runtime").JSX.Element;
|
27
31
|
export default TMHtmlEditor;
|
@@ -4,13 +4,17 @@ import HtmlEditor, { Toolbar, Item } from 'devextreme-react/html-editor';
|
|
4
4
|
import TMVilViewer from '../base/TMVilViewer';
|
5
5
|
import { SDKUI_Localizator } from '../../helper';
|
6
6
|
const TMHtmlEditor = (props) => {
|
7
|
-
const { width = "100%", height = "100%", mentionsConfig, onValueChanged, validationItems = [], isEditorEnabled: isEditorEnabledProp = false } = props;
|
7
|
+
const { width = "100%", height = "100%", initialMarkup = "", mentionsConfig, onValueChanged, validationItems = [], isEditorEnabled: isEditorEnabledProp = false, toolbarMode = 'compact' } = props;
|
8
8
|
// Ref for HtmlEditor instance
|
9
9
|
const editorRef = useRef(null);
|
10
10
|
// State for editor enable/disable
|
11
11
|
const [isEditorEnabled, setIsEditorEnabled] = useState(false);
|
12
12
|
// State to hold HTML markup
|
13
|
-
const [markup, setMarkup] = useState(
|
13
|
+
const [markup, setMarkup] = useState(initialMarkup);
|
14
|
+
// Update isEditorEnabled when prop changes
|
15
|
+
useEffect(() => {
|
16
|
+
setIsEditorEnabled(isEditorEnabledProp);
|
17
|
+
}, [isEditorEnabledProp]);
|
14
18
|
// Handler for value change
|
15
19
|
const onValueChangeCallback = (text) => {
|
16
20
|
setMarkup(text);
|
@@ -18,14 +22,12 @@ const TMHtmlEditor = (props) => {
|
|
18
22
|
onValueChanged({ value: text });
|
19
23
|
}
|
20
24
|
};
|
21
|
-
// Update isEditorEnabled when prop changes
|
22
|
-
useEffect(() => {
|
23
|
-
setIsEditorEnabled(isEditorEnabledProp);
|
24
|
-
}, [isEditorEnabledProp]);
|
25
25
|
// Memoized check for validation errors
|
26
26
|
const hasValidationErrors = useMemo(() => {
|
27
27
|
return validationItems && validationItems.length > 0;
|
28
28
|
}, [validationItems]);
|
29
|
-
return (_jsxs("div", { style: { height: validationItems.length > 0 ? `calc(${height} - 30px)` : "100%", width: width }, children: [_jsx("div", { className: "custom-mentions-wrapper", style: { borderWidth: '1px', borderStyle: 'solid', borderColor: hasValidationErrors ? "red" : "#e0e0e0 #e0e0e0 #616161", width: "100%", height: "100%" }, children: _jsx(HtmlEditor, { ref: editorRef, placeholder: SDKUI_Localizator.TypeAMessage + "...", width: "100%", height: "100%", value: markup, onValueChange: onValueChangeCallback, mentions: mentionsConfig, style: { overflow: 'hidden', outline: "none" }, children: isEditorEnabled && (
|
29
|
+
return (_jsxs("div", { style: { height: validationItems.length > 0 ? `calc(${height} - 30px)` : "100%", width: width }, children: [_jsx("div", { className: "custom-mentions-wrapper", style: { borderWidth: '1px', borderStyle: 'solid', borderColor: hasValidationErrors ? "red" : "#e0e0e0 #e0e0e0 #616161", width: "100%", height: "100%" }, children: _jsx(HtmlEditor, { ref: editorRef, placeholder: SDKUI_Localizator.TypeAMessage + "...", width: "100%", height: "100%", value: markup, onValueChange: onValueChangeCallback, mentions: mentionsConfig, style: { overflow: 'hidden', outline: "none" }, children: isEditorEnabled && (toolbarMode === 'compact' ?
|
30
|
+
_jsxs(Toolbar, { multiline: false, children: [_jsx(Item, { name: "undo" }), _jsx(Item, { name: "redo" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "bold" }), _jsx(Item, { name: "italic" }), _jsx(Item, { name: "underline" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "orderedList" }), _jsx(Item, { name: "bulletList" })] }) :
|
31
|
+
_jsxs(Toolbar, { children: [_jsx(Item, { name: "undo" }), _jsx(Item, { name: "redo" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "bold" }), _jsx(Item, { name: "italic" }), _jsx(Item, { name: "strike" }), _jsx(Item, { name: "underline" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "alignLeft" }), _jsx(Item, { name: "alignCenter" }), _jsx(Item, { name: "alignRight" }), _jsx(Item, { name: "alignJustify" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "color" }), _jsx(Item, { name: "background" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "link" }), _jsx(Item, { name: "image" }), _jsx(Item, { name: "separator" })] })) }) }), _jsx("div", { style: { width: "100%", height: validationItems.length > 0 ? "30px" : '0px' }, children: _jsx(TMVilViewer, { vil: validationItems }) })] }));
|
30
32
|
};
|
31
33
|
export default TMHtmlEditor;
|