|
9 | 9 | IGNORED_TAGS,
|
10 | 10 | TEXT_TAGS_IGNORING_ASSOCIATION,
|
11 | 11 | STYLESETS,
|
12 |
| - TextOnlyPropTypes |
13 |
| -} from './HTMLUtils'; |
| 12 | + TextOnlyPropTypes, TEXT_TAGS_MUST_INLINE |
| 13 | +} from './HTMLUtils' |
14 | 14 | import { generateDefaultBlockStyles, generateDefaultTextStyles } from './HTMLDefaultStyles';
|
15 | 15 | import htmlparser2 from 'htmlparser2';
|
16 | 16 | import * as HTMLRenderers from './HTMLRenderers';
|
@@ -226,7 +226,38 @@ export default class HTML extends PureComponent {
|
226 | 226 | };
|
227 | 227 | }
|
228 | 228 | }
|
| 229 | + |
| 230 | + //Fixed multiple Emoji can not be inline while got img tag |
| 231 | + if (child.wrapper === 'Text' && TEXT_TAGS_MUST_INLINE.indexOf(child.tagName) !== -1 |
| 232 | + && children.length > 1) { |
| 233 | + // Texts outside <p> or not <p> themselves (with siblings) |
| 234 | + let wrappedTexts = []; |
| 235 | + for (let j = i; j < children.length; j++) { |
| 236 | + // Loop on its next siblings and store them in an array |
| 237 | + // until we encounter a block or a <p> |
| 238 | + let nextSibling = children[j]; |
| 239 | + if (nextSibling.wrapper !== 'Text' || (TEXT_TAGS_MUST_INLINE.indexOf(nextSibling.tagName) === -1)) { |
| 240 | + break; |
| 241 | + } |
| 242 | + wrappedTexts.push(nextSibling); |
| 243 | + // Remove the child that has been nested |
| 244 | + children[j] = false; |
| 245 | + } |
| 246 | + // Replace the raw text with a <p> that has wrappedTexts as its children |
| 247 | + if (wrappedTexts.length) { |
| 248 | + children[i] = { |
| 249 | + attribs: {}, |
| 250 | + children: wrappedTexts, |
| 251 | + nodeIndex: i, |
| 252 | + parent: child.parent, |
| 253 | + parentTag: child.parentTag, |
| 254 | + tagName: 'textwrapper', |
| 255 | + wrapper: 'Text' |
| 256 | + }; |
| 257 | + } |
| 258 | + } |
229 | 259 | }
|
| 260 | + |
230 | 261 | return children.filter((parsedNode) => parsedNode !== false && parsedNode !== undefined);
|
231 | 262 | }
|
232 | 263 |
|
@@ -383,6 +414,7 @@ export default class HTML extends PureComponent {
|
383 | 414 | */
|
384 | 415 | renderRNElements (RNElements, parentWrapper = 'root', parentIndex = 0, props = this.props) {
|
385 | 416 | const { tagsStyles, classesStyles, emSize, ptSize, ignoredStyles, allowedStyles, baseFontStyle } = props;
|
| 417 | + |
386 | 418 | return RNElements && RNElements.length ? RNElements.map((element, index) => {
|
387 | 419 | const { attribs, data, tagName, parentTag, children, nodeIndex, wrapper } = element;
|
388 | 420 | const Wrapper = wrapper === 'Text' ? Text : View;
|
|
0 commit comments