Skip to content

Commit

Permalink
fix: πŸ› incorrect order of links generated
Browse files Browse the repository at this point in the history
The addLinksFromRichTextNode crawls through the nodes and always picks
up the last item in that array. This causes links to be entity links to
be generated in the incorrect order. Instead of taking the last node,
the first one is picked up to parse the nodes in the order they appeared
in the rich text
  • Loading branch information
Imanpal Singh committed Jun 24, 2022
1 parent b29c17d commit b44024f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/rich-text-links/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function addLinksFromRichTextNode(node: Node, links: EntityLinkMaps, type?: stri
const toCrawl: Node[] = [node];

while (toCrawl.length > 0) {
const { data, content, nodeType } = toCrawl.pop() as Block;
const { data, content, nodeType } = toCrawl.shift() as Block;
const hasRequestedNodeType = !type || nodeType === type;

if (hasRequestedNodeType && isLinkObject(data)) {
Expand Down

0 comments on commit b44024f

Please sign in to comment.