@topconsultnpm/sdkui-react-beta 6.12.138 → 6.12.140
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.
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import HtmlEditor, { Toolbar, Item } from 'devextreme-react/html-editor';
|
4
4
|
import TMVilViewer from '../base/TMVilViewer';
|
5
5
|
import { SDKUI_Localizator } from '../../helper';
|
6
|
+
import { FontSize } from '../../utils/theme';
|
6
7
|
const TMHtmlEditor = (props) => {
|
7
8
|
const { width = "100%", height = "100%", initialMarkup = "", mentionsConfig, onValueChanged, validationItems = [], isEditorEnabled: isEditorEnabledProp = false, toolbarMode = 'compact' } = props;
|
8
9
|
// Ref for HtmlEditor instance
|
@@ -22,8 +23,6 @@ const TMHtmlEditor = (props) => {
|
|
22
23
|
}, [isEditorEnabledProp]);
|
23
24
|
// Handler for value change
|
24
25
|
const onValueChangeCallback = (text) => {
|
25
|
-
if (text === initialMarkup)
|
26
|
-
return;
|
27
26
|
setMarkup(text);
|
28
27
|
if (onValueChanged) {
|
29
28
|
onValueChanged({ value: text });
|
@@ -33,7 +32,7 @@ const TMHtmlEditor = (props) => {
|
|
33
32
|
const hasValidationErrors = useMemo(() => {
|
34
33
|
return validationItems && validationItems.length > 0;
|
35
34
|
}, [validationItems]);
|
36
|
-
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' ?
|
35
|
+
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", fontSize: FontSize.defaultFontSize }, children: isEditorEnabled && (toolbarMode === 'compact' ?
|
37
36
|
_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: "strike" }), _jsx(Item, { name: "underline" }), _jsx(Item, { name: "separator" }), _jsx(Item, { name: "orderedList" }), _jsx(Item, { name: "bulletList" })] }) :
|
38
37
|
_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 }) })] }));
|
39
38
|
};
|