@topconsultnpm/sdkui-react-beta 6.15.49 → 6.15.51
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.
- package/lib/assets/icomoon.svg +96 -96
- package/lib/assets/italy.svg +16 -16
- package/lib/assets/topmedia-six.svg +65 -65
- package/lib/assets/topmeida-six-bianco.svg +65 -65
- package/lib/components/editors/TMHtmlContentDisplay.js +2 -1
- package/lib/components/editors/TMHtmlEditor.js +1 -2
- package/lib/components/features/blog/TMBlogCommentForm.js +11 -1
- package/lib/stories/TMHtmlEditor.stories.js +13 -1
- package/package.json +1 -1
|
@@ -108,7 +108,17 @@ const TMBlogCommentForm = (props) => {
|
|
|
108
108
|
// Retrieve the comment from formData, or use an empty string if undefined
|
|
109
109
|
const comment = formData?.comment ?? "";
|
|
110
110
|
// Clean the comment by removing <p> tags and replacing </p> with line breaks
|
|
111
|
-
let cleanComment = comment
|
|
111
|
+
let cleanComment = comment
|
|
112
|
+
// Replace </p> with '' only if followed by <ol> or <ul>
|
|
113
|
+
.replace(/<\/p>(?=\s*<(ol|ul)>)/gi, '')
|
|
114
|
+
// Replace all other </p> with '\r\n'
|
|
115
|
+
.replace(/<\/p>/gi, '\r\n')
|
|
116
|
+
// Remove all <p> tags
|
|
117
|
+
.replace(/<p>/gi, '')
|
|
118
|
+
// Remove all <br> tags
|
|
119
|
+
.replace(/<br>/gi, '')
|
|
120
|
+
// Trim whitespace
|
|
121
|
+
.trim();
|
|
112
122
|
// Validate and remove any potentially dangerous HTML tags (like <script>, <iframe>, etc.)
|
|
113
123
|
cleanComment = cleanComment.replace(/<(script|iframe|embed|object|link|style|img|video|audio|svg|form|input|button|textarea|select|pre|function)[^>]*>/gi, '');
|
|
114
124
|
// Assign the cleaned comment as the description for the blog post
|
|
@@ -13,6 +13,7 @@ export default meta;
|
|
|
13
13
|
export const Default = {
|
|
14
14
|
render: (args) => {
|
|
15
15
|
const [content, setContent] = useState('');
|
|
16
|
+
const [cleanComment, setCleanComment] = useState('');
|
|
16
17
|
const [mentionsConfig, setMentionsConfig] = useState([]);
|
|
17
18
|
useEffect(() => {
|
|
18
19
|
const mentions = [{
|
|
@@ -31,7 +32,18 @@ export const Default = {
|
|
|
31
32
|
}, []);
|
|
32
33
|
const handleValueChange = (e) => {
|
|
33
34
|
setContent(e.value);
|
|
35
|
+
setCleanComment(e.value
|
|
36
|
+
// Replace </p> with '' only if followed by <ol> or <ul>
|
|
37
|
+
.replace(/<\/p>(?=\s*<(ol|ul)>)/gi, '')
|
|
38
|
+
// Replace all other </p> with '\r\n'
|
|
39
|
+
.replace(/<\/p>/gi, '\r\n')
|
|
40
|
+
// Remove all <p> tags
|
|
41
|
+
.replace(/<p>/gi, '')
|
|
42
|
+
// Remove all <br> tags
|
|
43
|
+
.replace(/<br>/gi, '')
|
|
44
|
+
// Trim whitespace
|
|
45
|
+
.trim());
|
|
34
46
|
};
|
|
35
|
-
return (_jsxs("div", { style: { padding: 20 }, children: [_jsx(TMHtmlEditor, { ...args, onValueChanged: handleValueChange, isEditorEnabled: true, mentionsConfig: mentionsConfig }), _jsxs("div", { style: { marginTop: '1rem', padding: '0.5rem', backgroundColor: '#f5f5f5' }, children: [_jsx("h4", { children: "Output" }), _jsx(TMHtmlContentDisplay, { markup:
|
|
47
|
+
return (_jsxs("div", { style: { padding: 20 }, children: [_jsx(TMHtmlEditor, { ...args, onValueChanged: handleValueChange, isEditorEnabled: true, mentionsConfig: mentionsConfig }), _jsxs("div", { style: { marginTop: '1rem', padding: '0.5rem', backgroundColor: '#f5f5f5' }, children: [_jsx("h4", { children: "Output" }), _jsx(TMHtmlContentDisplay, { markup: cleanComment, isSelected: false })] }), _jsxs("div", { style: { marginTop: '1rem', padding: '0.5rem', backgroundColor: '#e0e0e0' }, children: [_jsx("h4", { children: "Output (HTML String)" }), _jsx("pre", { style: { whiteSpace: 'pre-wrap', wordBreak: 'break-word' }, children: JSON.stringify(cleanComment) })] })] }));
|
|
36
48
|
},
|
|
37
49
|
};
|