@openpeepshq/rn-components 0.6.4 → 0.6.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "React Native community screens and shared UI (extracted from the Black Ambition app) for the OpenPeeps stack.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -133,6 +133,7 @@
|
|
|
133
133
|
"react-native-uuid": "^2.0.3",
|
|
134
134
|
"react-native-video": "^6.19.2",
|
|
135
135
|
"react-native-voip-push-notification": "^3.3.2",
|
|
136
|
+
"react-native-webview": "^14.0.1",
|
|
136
137
|
"react-native-worklets": "^0.8.1",
|
|
137
138
|
"tailwind-merge": "^3.0.1",
|
|
138
139
|
"tailwindcss": "^3.4.17",
|
|
@@ -141,8 +142,8 @@
|
|
|
141
142
|
"timezones-list": "^3.1.0",
|
|
142
143
|
"validator": "^13.15.23",
|
|
143
144
|
"zustand": "^5.0.3",
|
|
144
|
-
"@openpeepshq/
|
|
145
|
-
"@openpeepshq/
|
|
145
|
+
"@openpeepshq/common": "^0.3.2",
|
|
146
|
+
"@openpeepshq/react": "^0.6.1"
|
|
146
147
|
},
|
|
147
148
|
"devDependencies": {
|
|
148
149
|
"@babel/core": "^7.26.7",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
import { WebView } from 'react-native-webview';
|
|
3
4
|
import type { RenderFunction } from 'react-native-markdown-display';
|
|
4
5
|
import {
|
|
5
6
|
extractIframeSrcs,
|
|
@@ -10,7 +11,7 @@ const TAG_RE = /<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>/g;
|
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Renderer for markdown-it `html_inline` tokens.
|
|
13
|
-
* Extracts iframes (rendered as
|
|
14
|
+
* Extracts iframes (rendered as inline WebViews) and strips other HTML.
|
|
14
15
|
*/
|
|
15
16
|
export const htmlInlineRenderer =
|
|
16
17
|
(onIframePress: (url: string) => void): RenderFunction =>
|
|
@@ -35,20 +36,27 @@ const renderHtmlContent = (
|
|
|
35
36
|
raw: string,
|
|
36
37
|
onIframePress: (url: string) => void
|
|
37
38
|
): React.ReactElement | null => {
|
|
38
|
-
// Iframes:
|
|
39
|
+
// Iframes: render as inline WebViews so embedded content (YouTube, etc.)
|
|
40
|
+
// is visible without leaving the app.
|
|
39
41
|
const iframes = extractIframeSrcs(raw);
|
|
40
42
|
if (iframes.length > 0) {
|
|
41
43
|
return (
|
|
42
44
|
<View style={styles.iframeContainer} key={raw.slice(0, 40)}>
|
|
43
45
|
{iframes.map((src, i) => (
|
|
44
46
|
<View key={`${i}-${src.slice(0, 20)}`} style={styles.iframeRow}>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
<WebView
|
|
48
|
+
source={{ uri: src }}
|
|
49
|
+
style={styles.webview}
|
|
50
|
+
scrollEnabled={false}
|
|
51
|
+
onNavigationStateChange={(nav) => {
|
|
52
|
+
// Intercept navigations away from the original embed URL
|
|
53
|
+
// and open them in the system browser instead.
|
|
54
|
+
if (nav.url !== src) {
|
|
55
|
+
onIframePress(nav.url);
|
|
56
|
+
}
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
<Text style={styles.iframeUrl} onPress={() => onIframePress(src)}>
|
|
52
60
|
{src}
|
|
53
61
|
</Text>
|
|
54
62
|
</View>
|
|
@@ -80,15 +88,15 @@ const renderHtmlContent = (
|
|
|
80
88
|
const styles = StyleSheet.create({
|
|
81
89
|
iframeContainer: { marginVertical: 8 },
|
|
82
90
|
iframeRow: { flexDirection: 'column', alignItems: 'flex-start' },
|
|
83
|
-
iframeLink: {
|
|
84
|
-
color: '#007AFF',
|
|
85
|
-
textDecorationLine: 'underline',
|
|
86
|
-
fontSize: 14,
|
|
87
|
-
},
|
|
88
91
|
iframeUrl: {
|
|
89
92
|
color: '#666',
|
|
90
93
|
fontSize: 12,
|
|
91
94
|
marginTop: 4,
|
|
92
95
|
},
|
|
96
|
+
webview: {
|
|
97
|
+
width: '100%',
|
|
98
|
+
aspectRatio: 16 / 9,
|
|
99
|
+
borderRadius: 8,
|
|
100
|
+
},
|
|
93
101
|
text: { fontSize: 16, lineHeight: 24 },
|
|
94
102
|
});
|