mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-14 04:08:32 +03:00
Add previewMode
This commit is contained in:
parent
e0688afdfc
commit
bc4dfaf62f
3 changed files with 24 additions and 19 deletions
|
@ -633,7 +633,7 @@ function Compose({
|
|||
</div>
|
||||
{!!replyToStatus && (
|
||||
<div class="status-preview">
|
||||
<Status status={replyToStatus} size="s" />
|
||||
<Status status={replyToStatus} size="s" previewMode />
|
||||
<div class="status-preview-legend reply-to">
|
||||
Replying to @
|
||||
{replyToStatus.account.acct || replyToStatus.account.username}
|
||||
|
@ -643,7 +643,7 @@ function Compose({
|
|||
)}
|
||||
{!!editStatus && (
|
||||
<div class="status-preview">
|
||||
<Status status={editStatus} size="s" />
|
||||
<Status status={editStatus} size="s" previewMode />
|
||||
<div class="status-preview-legend">Editing source status</div>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
@ -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({
|
|||
)} */}
|
||||
{/* </span> */}{' '}
|
||||
{size !== 'l' &&
|
||||
(url ? (
|
||||
(url && !previewMode ? (
|
||||
<Menu
|
||||
instanceRef={menuInstanceRef}
|
||||
portal={{
|
||||
|
@ -788,7 +790,7 @@ function Status({
|
|||
lang={language}
|
||||
ref={contentRef}
|
||||
data-read-more={readMoreText}
|
||||
onClick={handleContentLinks({ mentions, instance })}
|
||||
onClick={handleContentLinks({ mentions, instance, previewMode })}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: enhanceContent(content, {
|
||||
emojis,
|
||||
|
@ -801,6 +803,7 @@ function Status({
|
|||
a.removeAttribute('target');
|
||||
}
|
||||
});
|
||||
if (previewMode) return;
|
||||
// Unfurl Mastodon links
|
||||
dom
|
||||
.querySelectorAll(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import states from './states';
|
||||
|
||||
function handleContentLinks(opts) {
|
||||
const { mentions = [], instance } = opts || {};
|
||||
const { mentions = [], instance, previewMode } = opts || {};
|
||||
return (e) => {
|
||||
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}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue