From b39133d3206f600114f5616384f6f18998ed78be Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Fri, 1 Apr 2022 14:09:22 +0800 Subject: [PATCH] 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 a similar styling as in Posts. --- CHANGELOG.md | 9 ++++++++- ui/component/common/markdown-preview.jsx | 15 ++++++++++----- ui/scss/component/_embed-player.scss | 3 +-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5073bbd5..a0b75d5fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased for Desktop] +### Added + +### Changed + +### Fixed +- Fix post-editor preview mode _community pr!_ ([#7532](https://github.com/lbryio/lbry-desktop/pull/7532)) + ## [0.52.6] - [2022-04-04] ### Added @@ -54,7 +61,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Reenabled generating thumbs from video ([#7384](https://github.com/lbryio/lbry-desktop/pull/7409)) - Brought in playlist drag and drop playlist reordering _odysee team!_ ([#7442](https://github.com/lbryio/lbry-desktop/pull/7442)) - Added duration overlays to ClaimPreview component ([#7420](https://github.com/lbryio/lbry-desktop/pull/7420)) -- Some Horizontal Scroll groundwork from _odysee team!_ +- Some Horizontal Scroll groundwork from _odysee team!_ - Comment Emotes and Stickers and Mentions refactors from _odysee team!_ ([#7435](https://github.com/lbryio/lbry-desktop/pull/7435)) - Seek forward and back from _odysee team!_ () ([#7460](https://github.com/lbryio/lbry-desktop/pull/7460)) diff --git a/ui/component/common/markdown-preview.jsx b/ui/component/common/markdown-preview.jsx index 90edcc161..246edfc58 100644 --- a/ui/component/common/markdown-preview.jsx +++ b/ui/component/common/markdown-preview.jsx @@ -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 ( -
+
{decodedUri}
); @@ -195,7 +196,11 @@ export default React.memo(function MarkdownPreview(props: Markdow // Workaraund of remarkOptions.Fragment div: React.Fragment, img: (imgProps) => - isStakeEnoughForPreview(stakedLevel) && !isEmote(imgProps.title, imgProps.src) ? ( + noDataStore ? ( +
+ +
+ ) : isStakeEnoughForPreview(stakedLevel) && !isEmote(imgProps.title, imgProps.src) ? ( ) : ( diff --git a/ui/scss/component/_embed-player.scss b/ui/scss/component/_embed-player.scss index 59ee8119f..5c37fc9a6 100644 --- a/ui/scss/component/_embed-player.scss +++ b/ui/scss/component/_embed-player.scss @@ -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%; } -- 2.45.2