Fix post-editor preview mode (#7532)
## 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 a similar styling as in Posts. Co-authored-by: jessopb <36554050+jessopb@users.noreply.github.com>
This commit is contained in:
parent
79f05a831f
commit
daab8a28ed
3 changed files with 12 additions and 7 deletions
|
@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Fix post-editor preview mode _community pr!_ ([#7532](https://github.com/lbryio/lbry-desktop/pull/7532))
|
||||||
|
|
||||||
## [0.52.6] - [2022-04-04]
|
## [0.52.6] - [2022-04-04]
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ type SimpleTextProps = {
|
||||||
type SimpleLinkProps = {
|
type SimpleLinkProps = {
|
||||||
href?: string,
|
href?: string,
|
||||||
title?: string,
|
title?: string,
|
||||||
|
embed?: boolean,
|
||||||
children?: React.Node,
|
children?: React.Node,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ const SimpleText = (props: SimpleTextProps) => {
|
||||||
// ****************************************************************************
|
// ****************************************************************************
|
||||||
|
|
||||||
const SimpleLink = (props: SimpleLinkProps) => {
|
const SimpleLink = (props: SimpleLinkProps) => {
|
||||||
const { title, children, href } = props;
|
const { title, children, href, embed } = props;
|
||||||
|
|
||||||
if (!href) {
|
if (!href) {
|
||||||
return children || null;
|
return children || null;
|
||||||
|
@ -82,13 +83,13 @@ const SimpleLink = (props: SimpleLinkProps) => {
|
||||||
|
|
||||||
const [uri, search] = href.split('?');
|
const [uri, search] = href.split('?');
|
||||||
const urlParams = new URLSearchParams(search);
|
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
|
// Decode this since users might just copy it from the url bar
|
||||||
const decodedUri = decodeURI(uri);
|
const decodedUri = decodeURI(uri);
|
||||||
return (
|
return (
|
||||||
<div className="embed__inline-button-preview">
|
<div className="embed__inline-button embed__inline-button--preview">
|
||||||
<pre>{decodedUri}</pre>
|
<pre>{decodedUri}</pre>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -195,7 +196,11 @@ export default React.memo<MarkdownProps>(function MarkdownPreview(props: Markdow
|
||||||
// Workaraund of remarkOptions.Fragment
|
// Workaraund of remarkOptions.Fragment
|
||||||
div: React.Fragment,
|
div: React.Fragment,
|
||||||
img: (imgProps) =>
|
img: (imgProps) =>
|
||||||
isStakeEnoughForPreview(stakedLevel) && !isEmote(imgProps.title, imgProps.src) ? (
|
noDataStore ? (
|
||||||
|
<div className="file-viewer file-viewer--document">
|
||||||
|
<img {...imgProps} />
|
||||||
|
</div>
|
||||||
|
) : isStakeEnoughForPreview(stakedLevel) && !isEmote(imgProps.title, imgProps.src) ? (
|
||||||
<ZoomableImage {...imgProps} />
|
<ZoomableImage {...imgProps} />
|
||||||
) : (
|
) : (
|
||||||
<SimpleImageLink src={imgProps.src} alt={imgProps.alt} title={imgProps.title} />
|
<SimpleImageLink src={imgProps.src} alt={imgProps.alt} title={imgProps.title} />
|
||||||
|
|
|
@ -38,8 +38,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.embed__inline-button-preview {
|
.embed__inline-button--preview {
|
||||||
@extend .embed__inline-button;
|
|
||||||
background-color: var(--color-editor-inline-code-bg);
|
background-color: var(--color-editor-inline-code-bg);
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue