Fix post-editor preview mode #7532

Merged
infinite-persistence merged 2 commits from fix.mde.preview into master 2022-04-13 18:22:05 +02:00
3 changed files with 12 additions and 7 deletions

View file

@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
### Fixed
- Fix post-editor preview mode _community pr!_ ([#7532](https://github.com/lbryio/lbry-desktop/pull/7532))
## [0.52.6] - [2022-04-04]

View file

@ -33,6 +33,7 @@ type SimpleTextProps = {
type SimpleLinkProps = {
href?: string,
title?: string,
embed?: boolean,
children?: React.Node,
};
@ -66,7 +67,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;
@ -82,13 +83,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>
);
@ -195,7 +196,11 @@ export default React.memo<MarkdownProps>(function MarkdownPreview(props: Markdow
// Workaraund of remarkOptions.Fragment
div: React.Fragment,
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} />
) : (
<SimpleImageLink src={imgProps.src} alt={imgProps.alt} title={imgProps.title} />

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%;
}