@memori.ai/memori-react 7.0.3 → 7.0.5
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 +19 -0
- package/dist/I18nWrapper.js +7 -46
- package/dist/I18nWrapper.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.js +0 -2
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/ChatInputs/ChatInputs.js +2 -3
- package/dist/components/ChatInputs/ChatInputs.js.map +1 -1
- package/dist/components/ChatTextArea/ChatTextArea.css +8 -4
- package/dist/components/MemoriWidget/MemoriWidget.js +2 -6
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/helpers/configuration.js +0 -1
- package/dist/helpers/configuration.js.map +1 -1
- package/dist/helpers/utils.d.ts +27 -0
- package/dist/helpers/utils.js +55 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/index.js +2 -48
- package/dist/index.js.map +1 -1
- package/esm/I18nWrapper.js +7 -46
- package/esm/I18nWrapper.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.js +0 -2
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/ChatInputs/ChatInputs.js +2 -3
- package/esm/components/ChatInputs/ChatInputs.js.map +1 -1
- package/esm/components/ChatTextArea/ChatTextArea.css +8 -4
- package/esm/components/MemoriWidget/MemoriWidget.js +2 -6
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/helpers/configuration.js +0 -1
- package/esm/helpers/configuration.js.map +1 -1
- package/esm/helpers/utils.d.ts +27 -0
- package/esm/helpers/utils.js +52 -0
- package/esm/helpers/utils.js.map +1 -1
- package/esm/index.js +2 -48
- package/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/I18nWrapper.tsx +19 -58
- package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +0 -253
- package/src/components/ChatBubble/ChatBubble.stories.tsx +17 -8
- package/src/components/ChatBubble/ChatBubble.test.tsx +82 -2
- package/src/components/ChatBubble/ChatBubble.tsx +2 -4
- package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +2762 -13
- package/src/components/ChatInputs/ChatInputs.tsx +3 -5
- package/src/components/ChatInputs/__snapshots__/ChatInputs.test.tsx.snap +0 -138
- package/src/components/ChatTextArea/ChatTextArea.css +8 -4
- package/src/components/MemoriWidget/MemoriWidget.tsx +2 -9
- package/src/helpers/configuration.ts +0 -1
- package/src/helpers/utils.ts +57 -0
- package/src/index.tsx +2 -50
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DialogState } from '@memori.ai/memori-api-client/dist/types';
|
|
3
|
-
import SendOnEnterMenu from '../SendOnEnterMenu/SendOnEnterMenu';
|
|
3
|
+
// import SendOnEnterMenu from '../SendOnEnterMenu/SendOnEnterMenu';
|
|
4
4
|
import ChatTextArea from '../ChatTextArea/ChatTextArea';
|
|
5
5
|
import Button from '../ui/Button';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
@@ -34,8 +34,6 @@ export interface Props {
|
|
|
34
34
|
|
|
35
35
|
const ChatInputs: React.FC<Props> = ({
|
|
36
36
|
dialogState,
|
|
37
|
-
sendOnEnter = 'click',
|
|
38
|
-
setSendOnEnter,
|
|
39
37
|
userMessage = '',
|
|
40
38
|
onChangeUserMessage,
|
|
41
39
|
sendMessage,
|
|
@@ -65,10 +63,10 @@ const ChatInputs: React.FC<Props> = ({
|
|
|
65
63
|
disabled={!dialogState?.acceptsMedia}
|
|
66
64
|
/>
|
|
67
65
|
)*/}
|
|
68
|
-
|
|
66
|
+
{/*<SendOnEnterMenu
|
|
69
67
|
sendOnEnter={sendOnEnter}
|
|
70
68
|
setSendOnEnter={setSendOnEnter}
|
|
71
|
-
|
|
69
|
+
/>*/}
|
|
72
70
|
<ChatTextArea
|
|
73
71
|
value={userMessage}
|
|
74
72
|
onChange={onChangeUserMessage}
|
|
@@ -7,29 +7,6 @@ exports[`renders ChatInputs disabled unchanged 1`] = `
|
|
|
7
7
|
disabled=""
|
|
8
8
|
id="chat-fieldset"
|
|
9
9
|
>
|
|
10
|
-
<div
|
|
11
|
-
class="memori-send-on-enter-menu"
|
|
12
|
-
data-headlessui-state=""
|
|
13
|
-
>
|
|
14
|
-
<button
|
|
15
|
-
aria-expanded="false"
|
|
16
|
-
aria-haspopup="true"
|
|
17
|
-
class="memori-button memori-button--circle memori-button--icon-only memori-share-button--button memori--conversation-button"
|
|
18
|
-
data-headlessui-state=""
|
|
19
|
-
id="headlessui-menu-button-:ra:"
|
|
20
|
-
type="button"
|
|
21
|
-
>
|
|
22
|
-
<div
|
|
23
|
-
class="memori-button--icon"
|
|
24
|
-
>
|
|
25
|
-
<span
|
|
26
|
-
style="display: block; width: 1rem; height: 1rem;"
|
|
27
|
-
>
|
|
28
|
-
…
|
|
29
|
-
</span>
|
|
30
|
-
</div>
|
|
31
|
-
</button>
|
|
32
|
-
</div>
|
|
33
10
|
<div
|
|
34
11
|
class="memori-chat-textarea memori-chat-textarea--disabled"
|
|
35
12
|
data-testid="chat-textarea"
|
|
@@ -134,29 +111,6 @@ exports[`renders ChatInputs listening unchanged 1`] = `
|
|
|
134
111
|
class="memori-chat-inputs"
|
|
135
112
|
id="chat-fieldset"
|
|
136
113
|
>
|
|
137
|
-
<div
|
|
138
|
-
class="memori-send-on-enter-menu"
|
|
139
|
-
data-headlessui-state=""
|
|
140
|
-
>
|
|
141
|
-
<button
|
|
142
|
-
aria-expanded="false"
|
|
143
|
-
aria-haspopup="true"
|
|
144
|
-
class="memori-button memori-button--circle memori-button--icon-only memori-share-button--button memori--conversation-button"
|
|
145
|
-
data-headlessui-state=""
|
|
146
|
-
id="headlessui-menu-button-:r6:"
|
|
147
|
-
type="button"
|
|
148
|
-
>
|
|
149
|
-
<div
|
|
150
|
-
class="memori-button--icon"
|
|
151
|
-
>
|
|
152
|
-
<span
|
|
153
|
-
style="display: block; width: 1rem; height: 1rem;"
|
|
154
|
-
>
|
|
155
|
-
…
|
|
156
|
-
</span>
|
|
157
|
-
</div>
|
|
158
|
-
</button>
|
|
159
|
-
</div>
|
|
160
114
|
<div
|
|
161
115
|
class="memori-chat-textarea"
|
|
162
116
|
data-testid="chat-textarea"
|
|
@@ -260,29 +214,6 @@ exports[`renders ChatInputs on instruct unchanged 1`] = `
|
|
|
260
214
|
class="memori-chat-inputs"
|
|
261
215
|
id="chat-fieldset"
|
|
262
216
|
>
|
|
263
|
-
<div
|
|
264
|
-
class="memori-send-on-enter-menu"
|
|
265
|
-
data-headlessui-state=""
|
|
266
|
-
>
|
|
267
|
-
<button
|
|
268
|
-
aria-expanded="false"
|
|
269
|
-
aria-haspopup="true"
|
|
270
|
-
class="memori-button memori-button--circle memori-button--icon-only memori-share-button--button memori--conversation-button"
|
|
271
|
-
data-headlessui-state=""
|
|
272
|
-
id="headlessui-menu-button-:r4:"
|
|
273
|
-
type="button"
|
|
274
|
-
>
|
|
275
|
-
<div
|
|
276
|
-
class="memori-button--icon"
|
|
277
|
-
>
|
|
278
|
-
<span
|
|
279
|
-
style="display: block; width: 1rem; height: 1rem;"
|
|
280
|
-
>
|
|
281
|
-
…
|
|
282
|
-
</span>
|
|
283
|
-
</div>
|
|
284
|
-
</button>
|
|
285
|
-
</div>
|
|
286
217
|
<div
|
|
287
218
|
class="memori-chat-textarea"
|
|
288
219
|
data-testid="chat-textarea"
|
|
@@ -386,29 +317,6 @@ exports[`renders ChatInputs unchanged 1`] = `
|
|
|
386
317
|
class="memori-chat-inputs"
|
|
387
318
|
id="chat-fieldset"
|
|
388
319
|
>
|
|
389
|
-
<div
|
|
390
|
-
class="memori-send-on-enter-menu"
|
|
391
|
-
data-headlessui-state=""
|
|
392
|
-
>
|
|
393
|
-
<button
|
|
394
|
-
aria-expanded="false"
|
|
395
|
-
aria-haspopup="true"
|
|
396
|
-
class="memori-button memori-button--circle memori-button--icon-only memori-share-button--button memori--conversation-button"
|
|
397
|
-
data-headlessui-state=""
|
|
398
|
-
id="headlessui-menu-button-:r0:"
|
|
399
|
-
type="button"
|
|
400
|
-
>
|
|
401
|
-
<div
|
|
402
|
-
class="memori-button--icon"
|
|
403
|
-
>
|
|
404
|
-
<span
|
|
405
|
-
style="display: block; width: 1rem; height: 1rem;"
|
|
406
|
-
>
|
|
407
|
-
…
|
|
408
|
-
</span>
|
|
409
|
-
</div>
|
|
410
|
-
</button>
|
|
411
|
-
</div>
|
|
412
320
|
<div
|
|
413
321
|
class="memori-chat-textarea"
|
|
414
322
|
data-testid="chat-textarea"
|
|
@@ -511,29 +419,6 @@ exports[`renders ChatInputs with user message unchanged 1`] = `
|
|
|
511
419
|
class="memori-chat-inputs"
|
|
512
420
|
id="chat-fieldset"
|
|
513
421
|
>
|
|
514
|
-
<div
|
|
515
|
-
class="memori-send-on-enter-menu"
|
|
516
|
-
data-headlessui-state=""
|
|
517
|
-
>
|
|
518
|
-
<button
|
|
519
|
-
aria-expanded="false"
|
|
520
|
-
aria-haspopup="true"
|
|
521
|
-
class="memori-button memori-button--circle memori-button--icon-only memori-share-button--button memori--conversation-button"
|
|
522
|
-
data-headlessui-state=""
|
|
523
|
-
id="headlessui-menu-button-:r2:"
|
|
524
|
-
type="button"
|
|
525
|
-
>
|
|
526
|
-
<div
|
|
527
|
-
class="memori-button--icon"
|
|
528
|
-
>
|
|
529
|
-
<span
|
|
530
|
-
style="display: block; width: 1rem; height: 1rem;"
|
|
531
|
-
>
|
|
532
|
-
…
|
|
533
|
-
</span>
|
|
534
|
-
</div>
|
|
535
|
-
</button>
|
|
536
|
-
</div>
|
|
537
422
|
<div
|
|
538
423
|
class="memori-chat-textarea"
|
|
539
424
|
data-testid="chat-textarea"
|
|
@@ -637,29 +522,6 @@ exports[`renders ChatInputs without microphone button unchanged 1`] = `
|
|
|
637
522
|
class="memori-chat-inputs"
|
|
638
523
|
id="chat-fieldset"
|
|
639
524
|
>
|
|
640
|
-
<div
|
|
641
|
-
class="memori-send-on-enter-menu"
|
|
642
|
-
data-headlessui-state=""
|
|
643
|
-
>
|
|
644
|
-
<button
|
|
645
|
-
aria-expanded="false"
|
|
646
|
-
aria-haspopup="true"
|
|
647
|
-
class="memori-button memori-button--circle memori-button--icon-only memori-share-button--button memori--conversation-button"
|
|
648
|
-
data-headlessui-state=""
|
|
649
|
-
id="headlessui-menu-button-:r8:"
|
|
650
|
-
type="button"
|
|
651
|
-
>
|
|
652
|
-
<div
|
|
653
|
-
class="memori-button--icon"
|
|
654
|
-
>
|
|
655
|
-
<span
|
|
656
|
-
style="display: block; width: 1rem; height: 1rem;"
|
|
657
|
-
>
|
|
658
|
-
…
|
|
659
|
-
</span>
|
|
660
|
-
</div>
|
|
661
|
-
</button>
|
|
662
|
-
</div>
|
|
663
525
|
<div
|
|
664
526
|
class="memori-chat-textarea"
|
|
665
527
|
data-testid="chat-textarea"
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
box-sizing: border-box;
|
|
5
5
|
flex: 1 0 auto;
|
|
6
6
|
margin-right: 0.5rem;
|
|
7
|
-
margin-left: 0.5rem;
|
|
7
|
+
/* margin-left: 0.5rem; */
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.memori-chat-textarea--inner {
|
|
@@ -78,11 +78,15 @@ button.memori-chat-textarea--expand-button:focus {
|
|
|
78
78
|
outline: none;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
.memori-chat-textarea:not(.memori-chat-textarea--disabled)
|
|
82
|
-
.memori-chat-textarea
|
|
81
|
+
.memori-chat-textarea:not(.memori-chat-textarea--disabled)
|
|
82
|
+
.memori-chat-textarea--inner:focus
|
|
83
|
+
.memori-chat-textarea--expand-button,
|
|
84
|
+
.memori-chat-textarea:not(.memori-chat-textarea--disabled)
|
|
85
|
+
.memori-chat-textarea--inner:focus-within
|
|
86
|
+
.memori-chat-textarea--expand-button {
|
|
83
87
|
opacity: 1;
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
.memori-chat-textarea:not(.memori-chat-textarea--disabled) .memori-chat-textarea-inner:focus-within {
|
|
87
91
|
box-shadow: 0 0.2rem 0.33rem #b5b6c4;
|
|
88
|
-
}
|
|
92
|
+
}
|
|
@@ -2176,16 +2176,9 @@ const MemoriWidget = ({
|
|
|
2176
2176
|
'keypress'
|
|
2177
2177
|
);
|
|
2178
2178
|
useEffect(() => {
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
'keypress'
|
|
2182
|
-
);
|
|
2183
|
-
if (window.innerWidth <= 768) setSendOnEnter('click');
|
|
2184
|
-
else setSendOnEnter(stored);
|
|
2179
|
+
if (window.innerWidth <= 768 && hasTouchscreen()) setSendOnEnter('click');
|
|
2180
|
+
else setSendOnEnter('keypress');
|
|
2185
2181
|
}, []);
|
|
2186
|
-
useEffect(() => {
|
|
2187
|
-
setLocalConfig('sendOnEnter', sendOnEnter);
|
|
2188
|
-
}, [sendOnEnter]);
|
|
2189
2182
|
|
|
2190
2183
|
/**
|
|
2191
2184
|
* Attachments
|
|
@@ -2,7 +2,6 @@ export const keys: { [key: string]: string } = {
|
|
|
2
2
|
muteSpeaker: '@memori:muteSpeaker',
|
|
3
3
|
microphoneMode: '@memori:microphoneMode',
|
|
4
4
|
continuousSpeechTimeout: '@memori:continuousSpeechTimeout',
|
|
5
|
-
sendOnEnter: '@memori:sendOnEnter',
|
|
6
5
|
birthDate: '@memori:birthDate',
|
|
7
6
|
controlsPosition: '@memori:controlsPosition',
|
|
8
7
|
hideEmissions: '@memori:hideEmissions',
|
package/src/helpers/utils.ts
CHANGED
|
@@ -239,3 +239,60 @@ export function cleanUrl(href: string) {
|
|
|
239
239
|
}
|
|
240
240
|
return href;
|
|
241
241
|
}
|
|
242
|
+
|
|
243
|
+
export const mathJaxConfig = {
|
|
244
|
+
startup: {
|
|
245
|
+
elements: ['.memori-chat--bubble-content'],
|
|
246
|
+
},
|
|
247
|
+
options: {
|
|
248
|
+
processHtmlClass: 'memori-chat--bubble-content',
|
|
249
|
+
},
|
|
250
|
+
tex: {
|
|
251
|
+
inlineMath: [
|
|
252
|
+
['$', '$'],
|
|
253
|
+
['\\$', '\\$'],
|
|
254
|
+
['(', '\\)'],
|
|
255
|
+
['\\(', ')'],
|
|
256
|
+
['[', '\\]'],
|
|
257
|
+
['\\(', '\\)'],
|
|
258
|
+
['\\[', '\\]'],
|
|
259
|
+
['\\\\[', '\\\\]'],
|
|
260
|
+
['\\\\\\[', '\\\\\\]'],
|
|
261
|
+
['((', '))'],
|
|
262
|
+
],
|
|
263
|
+
displayMath: [
|
|
264
|
+
['$$', '$$'],
|
|
265
|
+
['\\[[', '\\]]'],
|
|
266
|
+
['\\\\[[', '\\\\]]'],
|
|
267
|
+
['\\\\\\[[', '\\\\\\]]'],
|
|
268
|
+
],
|
|
269
|
+
processEscapes: false,
|
|
270
|
+
},
|
|
271
|
+
asciimath: {
|
|
272
|
+
fixphi: true,
|
|
273
|
+
displaystyle: true,
|
|
274
|
+
decimalsign: '.',
|
|
275
|
+
},
|
|
276
|
+
skipStartupTypeset: true,
|
|
277
|
+
chtml: {
|
|
278
|
+
displayAlign: 'left',
|
|
279
|
+
},
|
|
280
|
+
svg: {
|
|
281
|
+
fontCache: 'global',
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export const installMathJaxScript = () => {
|
|
286
|
+
const script = document.createElement('script');
|
|
287
|
+
script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
|
|
288
|
+
script.async = true;
|
|
289
|
+
script.id = 'mathjax-script';
|
|
290
|
+
document.head.appendChild(script);
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export const installMathJax = () => {
|
|
294
|
+
// @ts-ignore
|
|
295
|
+
window.MathJax = mathJaxConfig;
|
|
296
|
+
|
|
297
|
+
installMathJaxScript();
|
|
298
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import MemoriWidget, {
|
|
|
11
11
|
} from './components/MemoriWidget/MemoriWidget';
|
|
12
12
|
import { Toaster } from 'react-hot-toast';
|
|
13
13
|
import { getTenant } from './helpers/tenant';
|
|
14
|
+
import { installMathJax } from './helpers/utils';
|
|
14
15
|
|
|
15
16
|
import i18n from './i18n';
|
|
16
17
|
import { I18nextProvider, useTranslation } from 'react-i18next';
|
|
@@ -210,56 +211,7 @@ const Memori: React.FC<Props> = ({
|
|
|
210
211
|
}, [uiLang]);
|
|
211
212
|
|
|
212
213
|
useEffect(() => {
|
|
213
|
-
|
|
214
|
-
window.MathJax = {
|
|
215
|
-
startup: {
|
|
216
|
-
elements: ['.memori-chat--bubble-content'],
|
|
217
|
-
},
|
|
218
|
-
options: {
|
|
219
|
-
processHtmlClass: 'memori-chat--bubble-content',
|
|
220
|
-
},
|
|
221
|
-
tex: {
|
|
222
|
-
inlineMath: [
|
|
223
|
-
['$', '$'],
|
|
224
|
-
['\\$', '\\$'],
|
|
225
|
-
['(', '\\)'],
|
|
226
|
-
['\\(', ')'],
|
|
227
|
-
['(', ')'],
|
|
228
|
-
['[', '\\]'],
|
|
229
|
-
['[', ']'],
|
|
230
|
-
['\\(', '\\)'],
|
|
231
|
-
['\\[', '\\]'],
|
|
232
|
-
['\\\\[', '\\\\]'],
|
|
233
|
-
['\\\\\\[', '\\\\\\]'],
|
|
234
|
-
['((', '))'],
|
|
235
|
-
],
|
|
236
|
-
displayMath: [
|
|
237
|
-
['$$', '$$'],
|
|
238
|
-
['\\[[', '\\]]'],
|
|
239
|
-
['\\\\[[', '\\\\]]'],
|
|
240
|
-
['\\\\\\[[', '\\\\\\]]'],
|
|
241
|
-
],
|
|
242
|
-
processEscapes: false,
|
|
243
|
-
},
|
|
244
|
-
asciimath: {
|
|
245
|
-
fixphi: true,
|
|
246
|
-
displaystyle: true,
|
|
247
|
-
decimalsign: '.',
|
|
248
|
-
},
|
|
249
|
-
skipStartupTypeset: true,
|
|
250
|
-
chtml: {
|
|
251
|
-
displayAlign: 'left',
|
|
252
|
-
},
|
|
253
|
-
svg: {
|
|
254
|
-
fontCache: 'global',
|
|
255
|
-
},
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
const script = document.createElement('script');
|
|
259
|
-
script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
|
|
260
|
-
script.async = true;
|
|
261
|
-
script.id = 'mathjax-script';
|
|
262
|
-
document.head.appendChild(script);
|
|
214
|
+
installMathJax();
|
|
263
215
|
}, []);
|
|
264
216
|
|
|
265
217
|
const renderer = memori ? (
|