@tellescope/chat 1.4.26 → 1.4.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/chat",
3
- "version": "1.4.26",
3
+ "version": "1.4.27",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -34,13 +34,13 @@
34
34
  "@fontsource/roboto": "^4.5.1",
35
35
  "@mui/icons-material": "^5.0.1",
36
36
  "@mui/material": "^5.0.2",
37
- "@tellescope/constants": "^1.4.26",
38
- "@tellescope/react-components": "^1.4.26",
39
- "@tellescope/sdk": "^1.4.26",
40
- "@tellescope/types-client": "^1.4.26",
41
- "@tellescope/types-models": "^1.4.26",
42
- "@tellescope/types-utilities": "^1.3.20",
43
- "@tellescope/utilities": "^1.4.26",
37
+ "@tellescope/constants": "^1.4.27",
38
+ "@tellescope/react-components": "^1.4.27",
39
+ "@tellescope/sdk": "^1.4.27",
40
+ "@tellescope/types-client": "^1.4.27",
41
+ "@tellescope/types-models": "^1.4.27",
42
+ "@tellescope/types-utilities": "^1.4.27",
43
+ "@tellescope/utilities": "^1.4.27",
44
44
  "@typescript-eslint/eslint-plugin": "^4.33.0",
45
45
  "@typescript-eslint/parser": "^4.33.0",
46
46
  "eslint": "^7.32.0",
@@ -51,7 +51,7 @@
51
51
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
52
52
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
53
53
  },
54
- "gitHead": "79ff60f52dfe1f21c9918ff097d978c523d4390b",
54
+ "gitHead": "d7860894a5b584eca1e5e571e7181710d295835c",
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  }
package/src/chat.tsx CHANGED
@@ -59,7 +59,7 @@ import {
59
59
  Session,
60
60
  EnduserSession,
61
61
  } from "@tellescope/sdk"
62
- import { SendMessage } from "./components"
62
+ import { HTMLMessage, SendMessage } from "./components"
63
63
 
64
64
  export {
65
65
  user_display_name, // for convenience
@@ -184,13 +184,19 @@ export const Message = ({
184
184
 
185
185
  const messageComponent = IN_REACT_WEB ? (
186
186
  <Typography component="div" style={{ ...textStyle, ...textBGStyle }}>
187
- {message.message}
187
+ {message.html
188
+ ? <HTMLMessage html={message.html} />
189
+ : message.message
190
+ }
188
191
  {attachments}
189
192
  </Typography>
190
193
  ) : (
191
194
  <Flex style={{ ...textBGStyle }}>
192
195
  <Typography component="div" style={{ ...textStyle }}>
193
- {message.message}
196
+ {message.html
197
+ ? <HTMLMessage html={message.html} />
198
+ : message.message
199
+ }
194
200
  {attachments}
195
201
  </Typography>
196
202
  </Flex>
@@ -393,7 +399,6 @@ const ConversationPreview = ({ onClick, selected, room, style, displayInfo, sele
393
399
  }
394
400
 
395
401
  const PreviewWithData = ({ PreviewComponent=ConversationPreview, ...props }: Omit<ConversationPreviewProps, 'displayInfo'> & Pick<SidebarInfo, 'PreviewComponent'>) => {
396
- const session = useResolvedSession()
397
402
  const [displayInfo] = useChatRoomDisplayInfo(props.room.id)
398
403
 
399
404
  return (
@@ -1,5 +1,5 @@
1
1
  import { launchImageLibrary, launchCamera } from 'react-native-image-picker';
2
- import { Modal, TextInput } from "react-native"
2
+ import { Modal, TextInput, useWindowDimensions } from "react-native"
3
3
  import { Avatar } from 'react-native-paper'
4
4
  import {
5
5
  useFileUpload,
@@ -14,6 +14,32 @@ import {
14
14
  useResolvedSession,
15
15
  } from "@tellescope/react-components"
16
16
  import { useState } from 'react';
17
+ import { HTMLMessageProps } from './components';
18
+ import { remove_script_tags } from '@tellescope/utilities';
19
+ import RenderHtml from 'react-native-render-html';
20
+
21
+ export const HTMLMessage = ({ html } : HTMLMessageProps) => {
22
+ const { width } = useWindowDimensions();
23
+ return (
24
+ <RenderHtml
25
+ contentWidth={width}
26
+ source={{
27
+ html: (
28
+ remove_script_tags(html)
29
+ )
30
+ }}
31
+ tagsStyles={{
32
+ 'body': {
33
+ color: 'white',
34
+ },
35
+ 'a': {
36
+ color: 'white',
37
+ textDecorationColor: 'white', // underline color in the link
38
+ }
39
+ }}
40
+ />
41
+ );
42
+ }
17
43
 
18
44
  const CHAT_ICON_SIZE = 35
19
45
  const SendImageOrVideo = ({
@@ -7,9 +7,25 @@ import {
7
7
  SendIcon,
8
8
  useChats,
9
9
  } from "@tellescope/react-components"
10
- import { user_display_name } from "@tellescope/utilities";
10
+ import { remove_script_tags, user_display_name } from "@tellescope/utilities";
11
11
  import { Checkbox, TextField, FormControlLabel, Grid } from "@mui/material";
12
12
 
13
+ export interface HTMLMessageProps {
14
+ html: string,
15
+ }
16
+ export const HTMLMessage = ({ html } : HTMLMessageProps) => {
17
+ return (
18
+ <div
19
+ dangerouslySetInnerHTML={{
20
+ __html: remove_script_tags(
21
+ html.replaceAll('<a', '<a style="color: white;"')
22
+ ),
23
+ }}
24
+ />
25
+
26
+ )
27
+ }
28
+
13
29
  interface SendMessage_T {
14
30
  roomId: string,
15
31
  onNewMessage?: (m: ChatMessage) => void;