Skip to content

Commit

Permalink
Ignore img tag when using linkifier
Browse files Browse the repository at this point in the history
  • Loading branch information
tpmai22 committed Mar 11, 2022
1 parent 8adb138 commit d237429
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion src/api/parser/src/data/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Post {
}

// Wrap an <a> tag on any link inside our content
article.content = linkifyHtml(article.content);
article.content = linkifyHtml(article.content, { ignoreTags: ['img'] });

let html;
try {
Expand Down
7 changes: 0 additions & 7 deletions src/web/src/components/Posts/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,6 @@ function handleZoom(e: MouseEvent) {
e.preventDefault();
zoomInImage(e.target);
}
// if the user clicks an anchor with an image inside, do not open the image link in a new tab.
else if (
e.target instanceof HTMLAnchorElement &&
e.target.firstChild instanceof HTMLImageElement
) {
e.preventDefault();
}
}

const PostComponent = ({ postUrl, currentPost, totalPosts }: Props) => {
Expand Down

0 comments on commit d237429

Please sign in to comment.