@memori.ai/memori-react 7.11.0 → 7.11.1
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/CHANGELOG.md +8 -0
- package/dist/components/ChatBubble/ChatBubble.js +7 -8
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +3 -3
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.js +7 -8
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +3 -3
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChatBubble/ChatBubble.stories.tsx +59 -1
- package/src/components/ChatBubble/ChatBubble.tsx +25 -28
- package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +462 -291
- package/src/components/MemoriWidget/MemoriWidget.tsx +6 -3
- package/src/index.stories.tsx +26 -1
|
@@ -33,7 +33,7 @@ import markedExtendedTables from '../../helpers/markedExtendedTables';
|
|
|
33
33
|
marked.use({
|
|
34
34
|
async: false,
|
|
35
35
|
gfm: true,
|
|
36
|
-
pedantic:
|
|
36
|
+
pedantic: false,
|
|
37
37
|
renderer: {
|
|
38
38
|
link: ({ href, title, text }) => {
|
|
39
39
|
const cleanHref = cleanUrl(href);
|
|
@@ -81,37 +81,34 @@ const parseSquaredBrackets = (text: string) => {
|
|
|
81
81
|
|
|
82
82
|
const renderMsg = (text: string, useMathFormatting = false) => {
|
|
83
83
|
try {
|
|
84
|
-
let parsedText =
|
|
85
|
-
(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
)
|
|
104
|
-
.trim()
|
|
105
|
-
.replace(/\n/g, '<br>'),
|
|
106
|
-
{
|
|
107
|
-
ADD_ATTR: ['target'],
|
|
108
|
-
}
|
|
109
|
-
);
|
|
84
|
+
let parsedText = (
|
|
85
|
+
marked.parse(
|
|
86
|
+
text
|
|
87
|
+
// remove leading and trailing whitespaces
|
|
88
|
+
.trim()
|
|
89
|
+
// remove markdown links
|
|
90
|
+
.replaceAll(
|
|
91
|
+
/\[([^\]]+)\]\(([^\)]+)\)/g,
|
|
92
|
+
'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
|
|
93
|
+
)
|
|
94
|
+
// remove markdown multiline code blocks but keep the content
|
|
95
|
+
.replaceAll(/```markdown([^```]+)```/g, '$1')
|
|
96
|
+
.replaceAll('($', '( $')
|
|
97
|
+
.replaceAll(':$', ': $')
|
|
98
|
+
.replaceAll('\frac', '\\frac')
|
|
99
|
+
.replaceAll('\beta', '\\beta')
|
|
100
|
+
.replaceAll('cdot', '\\cdot')
|
|
101
|
+
) as string
|
|
102
|
+
).trim();
|
|
110
103
|
|
|
111
104
|
if (useMathFormatting) {
|
|
112
|
-
parsedText = parseSquaredBrackets(parsedText);
|
|
105
|
+
parsedText = parseSquaredBrackets(parsedText.replace(/\n/g, '<br>'));
|
|
113
106
|
}
|
|
114
107
|
|
|
108
|
+
parsedText = DOMPurify.sanitize(parsedText, {
|
|
109
|
+
ADD_ATTR: ['target'],
|
|
110
|
+
});
|
|
111
|
+
|
|
115
112
|
return (
|
|
116
113
|
parsedText
|
|
117
114
|
// replace consecutive <br> with a single <br>
|