|
@@ -104,13 +104,49 @@ class WaitForOwnerDialog extends Component {
|
104
|
104
|
*
|
105
|
105
|
* @param {string} html - The <tt>string</tt> which may contain HTML to
|
106
|
106
|
* render.
|
107
|
|
- * @returns {string}
|
|
107
|
+ * @returns {ReactElement[]|string}
|
108
|
108
|
*/
|
109
|
109
|
_renderHTML(html) {
|
110
|
110
|
if (typeof html === 'string') {
|
111
|
|
- // TODO Limited styling may easily be provided by utilizing Text
|
112
|
|
- // with style.
|
113
|
|
- return html.replace(/<\/?b>/gi, '');
|
|
111
|
+ // At the time of this writing, the specified HTML contains a couple
|
|
112
|
+ // of spaces one after the other. They do not cause a visible
|
|
113
|
+ // problem on Web, because the specified HTML is rendered as, well,
|
|
114
|
+ // HTML. However, we're not rendering HTML here.
|
|
115
|
+
|
|
116
|
+ // eslint-disable-next-line no-param-reassign
|
|
117
|
+ html = html.replace(/\s{2,}/gi, ' ');
|
|
118
|
+
|
|
119
|
+ // Render text in <b>text</b> in bold.
|
|
120
|
+ const opening = /<\s*b\s*>/gi;
|
|
121
|
+ const closing = /<\s*\/\s*b\s*>/gi;
|
|
122
|
+ let o;
|
|
123
|
+ let c;
|
|
124
|
+ let prevClosingLastIndex = 0;
|
|
125
|
+ const r = [];
|
|
126
|
+
|
|
127
|
+ // eslint-disable-next-line no-cond-assign
|
|
128
|
+ while (o = opening.exec(html)) {
|
|
129
|
+ closing.lastIndex = opening.lastIndex;
|
|
130
|
+
|
|
131
|
+ // eslint-disable-next-line no-cond-assign
|
|
132
|
+ if (c = closing.exec(html)) {
|
|
133
|
+ r.push(html.substring(prevClosingLastIndex, o.index));
|
|
134
|
+ r.push(
|
|
135
|
+ <Text style = { styles.boldDialogText }>
|
|
136
|
+ { html.substring(opening.lastIndex, c.index) }
|
|
137
|
+ </Text>);
|
|
138
|
+ opening.lastIndex
|
|
139
|
+ = prevClosingLastIndex
|
|
140
|
+ = closing.lastIndex;
|
|
141
|
+ } else {
|
|
142
|
+ break;
|
|
143
|
+ }
|
|
144
|
+ }
|
|
145
|
+ if (prevClosingLastIndex < html.length) {
|
|
146
|
+ r.push(html.substring(prevClosingLastIndex));
|
|
147
|
+ }
|
|
148
|
+
|
|
149
|
+ return r;
|
114
|
150
|
}
|
115
|
151
|
|
116
|
152
|
return html;
|