diff --git a/src/components/postElements/body/view/commentBodyView.js b/src/components/postElements/body/view/commentBodyView.js index 8912e2504..5eabba38a 100644 --- a/src/components/postElements/body/view/commentBodyView.js +++ b/src/components/postElements/body/view/commentBodyView.js @@ -45,7 +45,7 @@ const CommentBody = ({ data = {}; } - const { type, href, author, category, permlink, tag, proposal, videoHref } = data; + const { type, href, images, author, category, permlink, tag, proposal, videoHref } = data; switch (type) { case '_external': @@ -76,7 +76,7 @@ const CommentBody = ({ case 'markdown-video-link': break; case 'image': - setPostImages([{ url: href }]); + setPostImages(images); setIsImageModalOpen(true); break; @@ -225,6 +225,12 @@ const CommentBody = ({ color: ${EStyleSheet.value('$primaryBlack')}; font-family: Roboto, sans-serif; max-width: 100%; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } body { color: ${EStyleSheet.value('$primaryBlack')}; @@ -333,6 +339,7 @@ const CommentBody = ({ imageUrls={postImages} enableSwipeDown onCancel={() => setIsImageModalOpen(false)} + onClick={() => setIsImageModalOpen(false)} onSave={uri => _saveImage(uri)} menuContext={{ saveToLocal: intl.formatMessage({ id: 'post.save_to_local' }), diff --git a/src/components/postElements/body/view/config.js b/src/components/postElements/body/view/config.js index 33a1e0369..1cf95fcc8 100644 --- a/src/components/postElements/body/view/config.js +++ b/src/components/postElements/body/view/config.js @@ -1,9 +1,16 @@ const customBodyScript = ` var images = document.getElementsByTagName("IMG"); +var imageUrls = []; +for (var k = 0; k < images.length; k++) { + var src = images[k].getAttribute("src") || ''; + if (src) { + imageUrls.push({url: src}); + } +} for (var i = 0; i < images.length; i++) { var result = { type: 'image', - href: images[i].getAttribute("src") || '' + images: imageUrls }; var resultStr = JSON.stringify(JSON.stringify(result)); var message = 'window.ReactNativeWebView.postMessage(' + resultStr + ')'; @@ -111,15 +118,22 @@ true; const customCommentScript = ` var images = document.getElementsByTagName("IMG"); +var imageUrls = []; +for (var k = 0; k < images.length; k++) { + var src = images[k].getAttribute("src") || ''; + if (src) { + imageUrls.push({url: src}); + } +} for (var i = 0; i < images.length; i++) { var result = { type: 'image', - href: images[i].getAttribute("src") || '' + images: imageUrls }; var resultStr = JSON.stringify(JSON.stringify(result)); var message = 'window.ReactNativeWebView.postMessage(' + resultStr + ')'; if (!images[i].classList.contains("video-thumbnail") && !images[i].parentNode.classList.contains("markdown-external-link")) { - images[i].setAttribute("onClick", message); + images[i].setAttribute("onTouchStart", message); } } document.addEventListener('touchstart', function(event) { @@ -214,7 +228,7 @@ document.addEventListener('touchstart', function(event) { return false; } } -}); +}, { passive: false }); true; `; diff --git a/src/components/postElements/body/view/postBodyView.js b/src/components/postElements/body/view/postBodyView.js index ceeb7287e..13d2e1a46 100644 --- a/src/components/postElements/body/view/postBodyView.js +++ b/src/components/postElements/body/view/postBodyView.js @@ -42,7 +42,7 @@ const PostBody = ({ data = {}; } - const { type, href, author, category, permlink, tag, proposal, videoHref } = data; + const { type, href, images, author, category, permlink, tag, proposal, videoHref } = data; switch (type) { case '_external': @@ -73,7 +73,7 @@ const PostBody = ({ case 'markdown-video-link': break; case 'image': - setPostImages([{ url: href }]); + setPostImages(images); setIsImageModalOpen(true); break; @@ -328,6 +328,7 @@ const PostBody = ({ imageUrls={postImages} enableSwipeDown onCancel={() => setIsImageModalOpen(false)} + onClick={() => setIsImageModalOpen(false)} onSave={uri => _saveImage(uri)} menuContext={{ saveToLocal: intl.formatMessage({ id: 'post.save_to_local' }),