@ -26,7 +26,14 @@ import NostrLink from "Element/NostrLink";
|
|||||||
import RevealMedia from "Element/RevealMedia";
|
import RevealMedia from "Element/RevealMedia";
|
||||||
import MagnetLink from "Element/MagnetLink";
|
import MagnetLink from "Element/MagnetLink";
|
||||||
|
|
||||||
export default function HyperText({ link, creator, depth }: { link: string; creator: string; depth?: number }) {
|
interface HypeTextProps {
|
||||||
|
link: string;
|
||||||
|
creator: string;
|
||||||
|
depth?: number;
|
||||||
|
disableMediaSpotlight?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function HyperText({ link, creator, depth, disableMediaSpotlight }: HypeTextProps) {
|
||||||
const a = link;
|
const a = link;
|
||||||
try {
|
try {
|
||||||
const url = new URL(a);
|
const url = new URL(a);
|
||||||
@ -42,7 +49,7 @@ export default function HyperText({ link, creator, depth }: { link: string; crea
|
|||||||
const isWavlakeLink = WavlakeRegex.test(a);
|
const isWavlakeLink = WavlakeRegex.test(a);
|
||||||
const extension = FileExtensionRegex.test(url.pathname.toLowerCase()) && RegExp.$1;
|
const extension = FileExtensionRegex.test(url.pathname.toLowerCase()) && RegExp.$1;
|
||||||
if (extension && !isAppleMusicLink) {
|
if (extension && !isAppleMusicLink) {
|
||||||
return <RevealMedia link={a} creator={creator} />;
|
return <RevealMedia link={a} creator={creator} disableSpotlight={disableMediaSpotlight} />;
|
||||||
} else if (tweetId) {
|
} else if (tweetId) {
|
||||||
return (
|
return (
|
||||||
<div className="tweet" key={tweetId}>
|
<div className="tweet" key={tweetId}>
|
||||||
|
@ -28,6 +28,7 @@ interface MediaElementProps {
|
|||||||
magnet?: string;
|
magnet?: string;
|
||||||
sha256?: string;
|
sha256?: string;
|
||||||
blurHash?: string;
|
blurHash?: string;
|
||||||
|
disableSpotlight?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface L402Object {
|
interface L402Object {
|
||||||
@ -166,11 +167,15 @@ export function MediaElement(props: MediaElementProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (props.mime.startsWith("image/")) {
|
if (props.mime.startsWith("image/")) {
|
||||||
return (
|
if (!(props.disableSpotlight ?? false)) {
|
||||||
<SpotlightMedia>
|
return (
|
||||||
<ProxyImg key={props.url} src={url} onError={() => probeFor402()} />
|
<SpotlightMedia>
|
||||||
</SpotlightMedia>
|
<ProxyImg key={props.url} src={url} onError={() => probeFor402()} />
|
||||||
);
|
</SpotlightMedia>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return <ProxyImg key={props.url} src={url} onError={() => probeFor402()} />;
|
||||||
|
}
|
||||||
} else if (props.mime.startsWith("audio/")) {
|
} else if (props.mime.startsWith("audio/")) {
|
||||||
return <audio key={props.url} src={url} controls onError={() => probeFor402()} />;
|
return <audio key={props.url} src={url} controls onError={() => probeFor402()} />;
|
||||||
} else if (props.mime.startsWith("video/")) {
|
} else if (props.mime.startsWith("video/")) {
|
||||||
|
@ -114,7 +114,11 @@ export default function Poll(props: PollProps) {
|
|||||||
return (
|
return (
|
||||||
<div key={a[1]} className="flex" onClick={e => zapVote(e, opt)}>
|
<div key={a[1]} className="flex" onClick={e => zapVote(e, opt)}>
|
||||||
<div className="f-grow">
|
<div className="f-grow">
|
||||||
{opt === voting ? <Spinner /> : <Text content={desc} tags={props.ev.tags} creator={props.ev.pubkey} />}
|
{opt === voting ? (
|
||||||
|
<Spinner />
|
||||||
|
) : (
|
||||||
|
<Text content={desc} tags={props.ev.tags} creator={props.ev.pubkey} disableMediaSpotlight={true} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{showResults && (
|
{showResults && (
|
||||||
<>
|
<>
|
||||||
|
@ -8,6 +8,7 @@ import { MediaElement } from "Element/MediaElement";
|
|||||||
interface RevealMediaProps {
|
interface RevealMediaProps {
|
||||||
creator: string;
|
creator: string;
|
||||||
link: string;
|
link: string;
|
||||||
|
disableSpotlight?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function RevealMedia(props: RevealMediaProps) {
|
export default function RevealMedia(props: RevealMediaProps) {
|
||||||
@ -52,10 +53,12 @@ export default function RevealMedia(props: RevealMediaProps) {
|
|||||||
return (
|
return (
|
||||||
<Reveal
|
<Reveal
|
||||||
message={<FormattedMessage defaultMessage="Click to load content from {link}" values={{ link: hostname }} />}>
|
message={<FormattedMessage defaultMessage="Click to load content from {link}" values={{ link: hostname }} />}>
|
||||||
<MediaElement mime={`${type}/${extension}`} url={url.toString()} />
|
<MediaElement mime={`${type}/${extension}`} url={url.toString()} disableSpotlight={props.disableSpotlight} />
|
||||||
</Reveal>
|
</Reveal>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return <MediaElement mime={`${type}/${extension}`} url={url.toString()} />;
|
return (
|
||||||
|
<MediaElement mime={`${type}/${extension}`} url={url.toString()} disableSpotlight={props.disableSpotlight} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,11 @@ export interface TextProps {
|
|||||||
creator: HexKey;
|
creator: HexKey;
|
||||||
tags: Array<Array<string>>;
|
tags: Array<Array<string>>;
|
||||||
disableMedia?: boolean;
|
disableMedia?: boolean;
|
||||||
|
disableMediaSpotlight?: boolean;
|
||||||
depth?: number;
|
depth?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Text({ content, tags, creator, disableMedia, depth }: TextProps) {
|
export default function Text({ content, tags, creator, disableMedia, depth, disableMediaSpotlight }: TextProps) {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
function extractLinks(fragments: Fragment[]) {
|
function extractLinks(fragments: Fragment[]) {
|
||||||
@ -57,7 +58,9 @@ export default function Text({ content, tags, creator, disableMedia, depth }: Te
|
|||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return <HyperText link={a} creator={creator} depth={depth} />;
|
return (
|
||||||
|
<HyperText link={a} creator={creator} depth={depth} disableMediaSpotlight={disableMediaSpotlight} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user