diff --git a/node_modules/react-native-markdown-display/src/lib/AstRenderer.js b/node_modules/react-native-markdown-display/src/lib/AstRenderer.js index 608e945..edafe12 100644 --- a/node_modules/react-native-markdown-display/src/lib/AstRenderer.js +++ b/node_modules/react-native-markdown-display/src/lib/AstRenderer.js @@ -1,6 +1,5 @@ import {StyleSheet} from 'react-native'; -import getUniqueID from './util/getUniqueID'; import convertAdditionalStyles from './util/convertAdditionalStyles'; import textStyleProps from './data/textStyleProps'; @@ -180,7 +179,7 @@ export default class AstRenderer { * @return {*} */ render = (nodes) => { - const root = {type: 'body', key: getUniqueID(), children: nodes}; + const root = {type: 'body', key: 'rnmr_root', children: nodes}; return this.renderNode(root, [], true); }; } diff --git a/node_modules/react-native-markdown-display/src/lib/util/tokensToAST.js b/node_modules/react-native-markdown-display/src/lib/util/tokensToAST.js index b0ed265..68e2150 100644 --- a/node_modules/react-native-markdown-display/src/lib/util/tokensToAST.js +++ b/node_modules/react-native-markdown-display/src/lib/util/tokensToAST.js @@ -1,4 +1,3 @@ -import getUniqueID from './getUniqueID'; import getTokenTypeByToken from './getTokenTypeByToken'; /** @@ -7,9 +6,10 @@ import getTokenTypeByToken from './getTokenTypeByToken'; * @param {number} tokenIndex * @return {{type: string, content, tokenIndex: *, index: number, attributes: {}, children: *}} */ -function createNode(token, tokenIndex) { +function createNode(token, tokenIndex, parentKey) { const type = getTokenTypeByToken(token); const content = token.content; + const keyPath = parentKey ? `${parentKey}.${tokenIndex}` : `${tokenIndex}`; let attributes = {}; @@ -27,12 +27,12 @@ function createNode(token, tokenIndex) { sourceMeta: token.meta, block: token.block, markup: token.markup, - key: getUniqueID() + '_' + type, + key: `rnmr_${keyPath}_${type}`, content, tokenIndex, index: 0, attributes, - children: tokensToAST(token.children), + children: tokensToAST(token.children, keyPath), }; } @@ -41,7 +41,7 @@ function createNode(token, tokenIndex) { * @param {Array<{type: string, tag:string, content: string, children: *, attrs: Array}>}tokens * @return {Array} */ -export default function tokensToAST(tokens) { +export default function tokensToAST(tokens, parentKey = '') { let stack = []; let children = []; @@ -51,7 +51,7 @@ export default function tokensToAST(tokens) { for (let i = 0; i < tokens.length; i++) { const token = tokens[i]; - const astNode = createNode(token, i); + const astNode = createNode(token, i, parentKey); if ( !(