From bc4dfaf62f800c222a9332c3674ab6113f88185d Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 16 Mar 2023 13:02:46 +0800 Subject: [PATCH] Add previewMode --- src/components/compose.jsx | 4 ++-- src/components/status.jsx | 7 +++++-- src/utils/handle-content-links.js | 32 ++++++++++++++++--------------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index 76f595c6..981516b2 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -633,7 +633,7 @@ function Compose({ {!!replyToStatus && (
- +
Replying to @ {replyToStatus.account.acct || replyToStatus.account.username} @@ -643,7 +643,7 @@ function Compose({ )} {!!editStatus && (
- +
Editing source status
)} diff --git a/src/components/status.jsx b/src/components/status.jsx index 8494538b..edbed593 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -70,6 +70,7 @@ function Status({ readOnly, contentTextWeight, enableTranslate, + previewMode, }) { if (skeleton) { return ( @@ -578,6 +579,7 @@ function Status({ onContextMenu={(e) => { if (size === 'l') return; if (e.metaKey) return; + if (previewMode) return; // console.log('context menu', e); const link = e.target.closest('a'); if (link && /^https?:\/\//.test(link.getAttribute('href'))) return; @@ -662,7 +664,7 @@ function Status({ )} */} {/* */}{' '} {size !== 'l' && - (url ? ( + (url && !previewMode ? ( { let { target } = e; target = target.closest('a'); @@ -35,20 +35,22 @@ function handleContentLinks(opts) { instance, }; } - } else if (target.classList.contains('hashtag')) { - e.preventDefault(); - e.stopPropagation(); - const tag = target.innerText.replace(/^#/, '').trim(); - const hashURL = instance ? `#/${instance}/t/${tag}` : `#/t/${tag}`; - console.log({ hashURL }); - location.hash = hashURL; - } else if (states.unfurledLinks[target.href]?.url) { - e.preventDefault(); - e.stopPropagation(); - states.prevLocation = { - pathname: location.hash.replace(/^#/, ''), - }; - location.hash = `#${states.unfurledLinks[target.href].url}`; + } else if (!previewMode) { + if (target.classList.contains('hashtag')) { + e.preventDefault(); + e.stopPropagation(); + const tag = target.innerText.replace(/^#/, '').trim(); + const hashURL = instance ? `#/${instance}/t/${tag}` : `#/t/${tag}`; + console.log({ hashURL }); + location.hash = hashURL; + } else if (states.unfurledLinks[target.href]?.url) { + e.preventDefault(); + e.stopPropagation(); + states.prevLocation = { + pathname: location.hash.replace(/^#/, ''), + }; + location.hash = `#${states.unfurledLinks[target.href].url}`; + } } }; }