@solidxai/core-ui 0.1.22-beta.1 → 0.1.22-beta.2
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/dist/components/core/chatter/SolidChatterCustomMessage.d.ts.map +1 -1
- package/dist/components/core/chatter/SolidChatterCustomMessage.js +17 -5
- package/dist/components/core/chatter/SolidChatterCustomMessage.js.map +1 -1
- package/dist/components/core/chatter/SolidChatterCustomMessage.tsx +23 -6
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolidChatterCustomMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/core/chatter/SolidChatterCustomMessage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"SolidChatterCustomMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/core/chatter/SolidChatterCustomMessage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,UAAU,8BAA8B;IACpC,OAAO,EAAE,MAAM,CAAC;CACnB;AA8BD,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC,8BAA8B,CAqB9E,CAAC"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import DOMPurify from 'dompurify';
|
|
2
3
|
import MarkdownViewer from '../../../components/common/MarkdownViewer';
|
|
3
4
|
import styles from './chatter.module.css';
|
|
5
|
+
// react-markdown (no rehype-raw wired in) strips/escapes embedded raw HTML rather than
|
|
6
|
+
// rendering it, so a body that's actual HTML (e.g. an imported Odoo audit-log <table>) must be
|
|
7
|
+
// rendered separately from Markdown, via the same sanitize-then-dangerouslySetInnerHTML pattern
|
|
8
|
+
// SolidRichTextField already uses for rich-text bodies - not routed through MarkdownViewer.
|
|
9
|
+
var isHtml = function (text) {
|
|
10
|
+
if (!text || typeof text !== 'string')
|
|
11
|
+
return false;
|
|
12
|
+
return /<\/?[a-z][\s\S]*?>/i.test(text);
|
|
13
|
+
};
|
|
4
14
|
var isMarkupLanguage = function (text) {
|
|
5
15
|
if (!text || typeof text !== 'string')
|
|
6
16
|
return false;
|
|
@@ -16,14 +26,16 @@ var isMarkupLanguage = function (text) {
|
|
|
16
26
|
/^\s*\|.*\|/m,
|
|
17
27
|
/^\s*>\s+/m,
|
|
18
28
|
];
|
|
19
|
-
|
|
20
|
-
var htmlPattern = /<\/?[a-z][\s\S]*?>/i;
|
|
21
|
-
return markdownPatterns.some(function (pattern) { return pattern.test(text); }) || htmlPattern.test(text);
|
|
29
|
+
return markdownPatterns.some(function (pattern) { return pattern.test(text); });
|
|
22
30
|
};
|
|
23
31
|
export var SolidChatterCustomMessage = function (_a) {
|
|
24
32
|
var message = _a.message;
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
if (isHtml(message)) {
|
|
34
|
+
return (_jsx("div", { className: "custom-message-wrapper",
|
|
35
|
+
// Imported email bodies carry fixed-width tables; scroll inside the bubble instead of widening the panel.
|
|
36
|
+
style: { maxWidth: '100%', overflowX: 'auto' }, dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(message) } }));
|
|
37
|
+
}
|
|
38
|
+
if (isMarkupLanguage(message)) {
|
|
27
39
|
return (_jsx("div", { className: "custom-message-wrapper", children: _jsx(MarkdownViewer, { data: message }) }));
|
|
28
40
|
}
|
|
29
41
|
return _jsx("p", { className: styles.solidMessageText, children: message });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolidChatterCustomMessage.js","sourceRoot":"","sources":["../../../../src/components/core/chatter/SolidChatterCustomMessage.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,MAAM,2CAA2C,CAAA;AACtE,OAAO,MAAM,MAAM,sBAAsB,CAAA;AAMzC,IAAM,gBAAgB,GAAG,UAAC,IAAY;IAClC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAEpD,IAAM,gBAAgB,GAAG;QACrB,aAAa;QACb,aAAa;QACb,SAAS;QACT,OAAO;QACP,gBAAgB;QAChB,eAAe;QACf,eAAe;QACf,gBAAgB;QAChB,aAAa;QACb,WAAW;KACd,CAAC;IAEF,
|
|
1
|
+
{"version":3,"file":"SolidChatterCustomMessage.js","sourceRoot":"","sources":["../../../../src/components/core/chatter/SolidChatterCustomMessage.tsx"],"names":[],"mappings":";AAEA,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,cAAc,MAAM,2CAA2C,CAAA;AACtE,OAAO,MAAM,MAAM,sBAAsB,CAAA;AAMzC,uFAAuF;AACvF,+FAA+F;AAC/F,gGAAgG;AAChG,4FAA4F;AAC5F,IAAM,MAAM,GAAG,UAAC,IAAY;IACxB,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACpD,OAAO,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,IAAM,gBAAgB,GAAG,UAAC,IAAY;IAClC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAEpD,IAAM,gBAAgB,GAAG;QACrB,aAAa;QACb,aAAa;QACb,SAAS;QACT,OAAO;QACP,gBAAgB;QAChB,eAAe;QACf,eAAe;QACf,gBAAgB;QAChB,aAAa;QACb,WAAW;KACd,CAAC;IAEF,OAAO,gBAAgB,CAAC,IAAI,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAlB,CAAkB,CAAC,CAAC;AAChE,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,yBAAyB,GAA6C,UAAC,EAAW;QAAT,OAAO,aAAA;IACzF,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE;QACjB,OAAO,CACH,cACI,SAAS,EAAC,wBAAwB;YAClC,0GAA0G;YAC1G,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAC9C,uBAAuB,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,GAClE,CACL,CAAC;KACL;IAED,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE;QAC3B,OAAO,CACH,cAAK,SAAS,EAAC,wBAAwB,YACnC,KAAC,cAAc,IAAC,IAAI,EAAE,OAAO,GAAI,GAC/B,CACT,CAAC;KACL;IAED,OAAO,YAAG,SAAS,EAAE,MAAM,CAAC,gBAAgB,YAAG,OAAO,GAAK,CAAC;AAChE,CAAC,CAAC","sourcesContent":["\nimport React from 'react'\nimport DOMPurify from 'dompurify'\nimport MarkdownViewer from '../../../components/common/MarkdownViewer'\nimport styles from './chatter.module.css'\n\ninterface SolidChatterCustomMessageProps {\n message: string;\n}\n\n// react-markdown (no rehype-raw wired in) strips/escapes embedded raw HTML rather than\n// rendering it, so a body that's actual HTML (e.g. an imported Odoo audit-log <table>) must be\n// rendered separately from Markdown, via the same sanitize-then-dangerouslySetInnerHTML pattern\n// SolidRichTextField already uses for rich-text bodies - not routed through MarkdownViewer.\nconst isHtml = (text: string): boolean => {\n if (!text || typeof text !== 'string') return false;\n return /<\\/?[a-z][\\s\\S]*?>/i.test(text);\n};\n\nconst isMarkupLanguage = (text: string): boolean => {\n if (!text || typeof text !== 'string') return false;\n\n const markdownPatterns = [\n /^#{1,6}\\s+/m,\n /\\*\\*.*?\\*\\*/,\n /\\*.*?\\*/,\n /`.*?`/,\n /```[\\s\\S]*?```/,\n /^\\s*[-*+]\\s+/m,\n /^\\s*\\d+\\.\\s+/m,\n /\\[.*?\\]\\(.*?\\)/,\n /^\\s*\\|.*\\|/m,\n /^\\s*>\\s+/m,\n ];\n\n return markdownPatterns.some(pattern => pattern.test(text));\n};\n\nexport const SolidChatterCustomMessage: React.FC<SolidChatterCustomMessageProps> = ({ message }) => {\n if (isHtml(message)) {\n return (\n <div\n className=\"custom-message-wrapper\"\n // Imported email bodies carry fixed-width tables; scroll inside the bubble instead of widening the panel.\n style={{ maxWidth: '100%', overflowX: 'auto' }}\n dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(message) }}\n />\n );\n }\n\n if (isMarkupLanguage(message)) {\n return (\n <div className=\"custom-message-wrapper\">\n <MarkdownViewer data={message} />\n </div>\n );\n }\n\n return <p className={styles.solidMessageText}>{message}</p>;\n};\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import React from 'react'
|
|
3
|
+
import DOMPurify from 'dompurify'
|
|
3
4
|
import MarkdownViewer from '../../../components/common/MarkdownViewer'
|
|
4
5
|
import styles from './chatter.module.css'
|
|
5
6
|
|
|
@@ -7,6 +8,15 @@ interface SolidChatterCustomMessageProps {
|
|
|
7
8
|
message: string;
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
// react-markdown (no rehype-raw wired in) strips/escapes embedded raw HTML rather than
|
|
12
|
+
// rendering it, so a body that's actual HTML (e.g. an imported Odoo audit-log <table>) must be
|
|
13
|
+
// rendered separately from Markdown, via the same sanitize-then-dangerouslySetInnerHTML pattern
|
|
14
|
+
// SolidRichTextField already uses for rich-text bodies - not routed through MarkdownViewer.
|
|
15
|
+
const isHtml = (text: string): boolean => {
|
|
16
|
+
if (!text || typeof text !== 'string') return false;
|
|
17
|
+
return /<\/?[a-z][\s\S]*?>/i.test(text);
|
|
18
|
+
};
|
|
19
|
+
|
|
10
20
|
const isMarkupLanguage = (text: string): boolean => {
|
|
11
21
|
if (!text || typeof text !== 'string') return false;
|
|
12
22
|
|
|
@@ -23,15 +33,22 @@ const isMarkupLanguage = (text: string): boolean => {
|
|
|
23
33
|
/^\s*>\s+/m,
|
|
24
34
|
];
|
|
25
35
|
|
|
26
|
-
|
|
27
|
-
const htmlPattern = /<\/?[a-z][\s\S]*?>/i;
|
|
28
|
-
|
|
29
|
-
return markdownPatterns.some(pattern => pattern.test(text)) || htmlPattern.test(text);
|
|
36
|
+
return markdownPatterns.some(pattern => pattern.test(text));
|
|
30
37
|
};
|
|
31
38
|
|
|
32
39
|
export const SolidChatterCustomMessage: React.FC<SolidChatterCustomMessageProps> = ({ message }) => {
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
if (isHtml(message)) {
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
className="custom-message-wrapper"
|
|
44
|
+
// Imported email bodies carry fixed-width tables; scroll inside the bubble instead of widening the panel.
|
|
45
|
+
style={{ maxWidth: '100%', overflowX: 'auto' }}
|
|
46
|
+
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(message) }}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (isMarkupLanguage(message)) {
|
|
35
52
|
return (
|
|
36
53
|
<div className="custom-message-wrapper">
|
|
37
54
|
<MarkdownViewer data={message} />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidxai/core-ui",
|
|
3
|
-
"version": "0.1.22-beta.
|
|
3
|
+
"version": "0.1.22-beta.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build:tailwind": "tailwindcss -i ./src/resources/solid-tailwind.css -o ./src/resources/solid-tailwind-generated.css -c ./tailwind.config.js --minify",
|
|
6
6
|
"prebuild": "npm run build:tailwind && npm run copy-resources && npm run copy-styles",
|