Fix post-editor preview mode

## Cause
It broke because lack of awareness that we can't use our components in preview mode. For some reason, we don't have redux access in SimpleMDE's preview mode.

## Change
- Restore the stub for iframes
- Fix preview for images, and apply the same styling as in posts.
This commit is contained in:
infinite-persistence 2022-04-01 14:09:22 +08:00 committed by Thomas Zarebczan
parent a61f943465
commit e0415ec493
2 changed files with 13 additions and 7 deletions

View file

@ -37,6 +37,7 @@ type SimpleTextProps = {
type SimpleLinkProps = {
href?: string,
title?: string,
embed?: boolean,
children?: React.Node,
};
@ -72,7 +73,7 @@ const SimpleText = (props: SimpleTextProps) => {
// ****************************************************************************
const SimpleLink = (props: SimpleLinkProps) => {
const { title, children, href } = props;
const { title, children, href, embed } = props;
if (!href) {
return children || null;
@ -88,13 +89,13 @@ const SimpleLink = (props: SimpleLinkProps) => {
const [uri, search] = href.split('?');
const urlParams = new URLSearchParams(search);
const embed = urlParams.get('embed');
const embedParam = urlParams.get('embed');
if (embed) {
if (embed || embedParam) {
// Decode this since users might just copy it from the url bar
const decodedUri = decodeURI(uri);
return (
<div className="embed__inline-button-preview">
<div className="embed__inline-button embed__inline-button--preview">
<pre>{decodedUri}</pre>
</div>
);
@ -205,7 +206,13 @@ export default React.memo<MarkdownProps>(function MarkdownPreview(props: Markdow
? getImageProxyUrl(imgProps.src)
: getThumbnailCdnUrl({ thumbnail: imgProps.src, width: 0, height: 0, quality: 85 })) ||
MISSING_THUMB_DEFAULT;
if ((isStakeEnoughForPreview(stakedLevel) || hasMembership) && !isEmote(imgProps.title, imgProps.src)) {
if (noDataStore) {
return (
<div className="file-viewer file-viewer--document">
<img {...imgProps} src={imageCdnUrl} />
</div>
);
} else if ((isStakeEnoughForPreview(stakedLevel) || hasMembership) && !isEmote(imgProps.title, imgProps.src)) {
return <ZoomableImage {...imgProps} src={imageCdnUrl} />;
} else {
return (

View file

@ -38,8 +38,7 @@
}
}
.embed__inline-button-preview {
@extend .embed__inline-button;
.embed__inline-button--preview {
background-color: var(--color-editor-inline-code-bg);
width: 50%;
}