@topconsultnpm/sdkui-react-beta 6.12.72 → 6.12.75

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,20 @@ 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
13
  const [markup, setMarkup] = useState("");
14
+ useEffect(() => {
15
+ setMarkup(initialMarkup);
16
+ }, [initialMarkup]);
17
+ // Update isEditorEnabled when prop changes
18
+ useEffect(() => {
19
+ setIsEditorEnabled(isEditorEnabledProp);
20
+ }, [isEditorEnabledProp]);
14
21
  // Handler for value change
15
22
  const onValueChangeCallback = (text) => {
16
23
  setMarkup(text);
@@ -18,14 +25,12 @@ const TMHtmlEditor = (props) => {
18
25
  onValueChanged({ value: text });
19
26
  }
20
27
  };
21
- // Update isEditorEnabled when prop changes
22
- useEffect(() => {
23
- setIsEditorEnabled(isEditorEnabledProp);
24
- }, [isEditorEnabledProp]);
25
28
  // Memoized check for validation errors
26
29
  const hasValidationErrors = useMemo(() => {
27
30
  return validationItems && validationItems.length > 0;
28
31
  }, [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 && (_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" })] })) }) }), _jsx("div", { style: { width: "100%", height: validationItems.length > 0 ? "30px" : '0px' }, children: _jsx(TMVilViewer, { vil: validationItems }) })] }));
32
+ 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' ?
33
+ _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" })] }) :
34
+ _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
35
  };
31
36
  export default TMHtmlEditor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.12.72",
3
+ "version": "6.12.75",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",