snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
57
react/features/base/dialog/components/functions.native.tsx
Normal file
57
react/features/base/dialog/components/functions.native.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import React from 'react';
|
||||
import { Text, TextStyle } from 'react-native';
|
||||
|
||||
import { brandedDialog as styles } from './native/styles';
|
||||
|
||||
/**
|
||||
* Renders a specific {@code string} which may contain HTML.
|
||||
*
|
||||
* @param {string|undefined} html - The {@code string} which may
|
||||
* contain HTML to render.
|
||||
* @returns {ReactElement[]|string}
|
||||
*/
|
||||
export function renderHTML(html?: string) {
|
||||
if (typeof html === 'string') {
|
||||
// At the time of this writing, the specified HTML contains a couple
|
||||
// of spaces one after the other. They do not cause a visible
|
||||
// problem on Web, because the specified HTML is rendered as, well,
|
||||
// HTML. However, we're not rendering HTML here.
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
html = html.replace(/\s{2,}/gi, ' ');
|
||||
|
||||
// Render text in <b>text</b> in bold.
|
||||
const opening = /<\s*b\s*>/gi;
|
||||
const closing = /<\s*\/\s*b\s*>/gi;
|
||||
let o;
|
||||
let c;
|
||||
let prevClosingLastIndex = 0;
|
||||
const r = [];
|
||||
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while (o = opening.exec(html)) {
|
||||
closing.lastIndex = opening.lastIndex;
|
||||
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
if (c = closing.exec(html)) {
|
||||
r.push(html.substring(prevClosingLastIndex, o.index));
|
||||
r.push(
|
||||
<Text style = { (styles.boldDialogText as TextStyle) }>
|
||||
{ html.substring(opening.lastIndex, c.index) }
|
||||
</Text>);
|
||||
opening.lastIndex
|
||||
= prevClosingLastIndex
|
||||
= closing.lastIndex;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (prevClosingLastIndex < html.length) {
|
||||
r.push(html.substring(prevClosingLastIndex));
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
Reference in New Issue
Block a user