From 897128a168b8300b59174718e48b97e6d77036d9 Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Tue, 15 Dec 2020 15:15:02 +0800 Subject: [PATCH] Restore "Handle timestamp in Markdown." This reverts the revertion in: - 85f8965d441ef980e6c8b31387180fc8814b11ab. - d3f0e471e55d1e3e0bb6a70cfd0c14c15ba55f54. --- CHANGELOG.md | 1 + ui/component/common/markdown-preview.jsx | 3 + ui/component/markdownLink/view.jsx | 25 +++++- .../viewers/videoViewer/internal/videojs.jsx | 3 + ui/util/remark-timestamp.js | 81 +++++++++++++++++++ 5 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 ui/util/remark-timestamp.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 65de39135..760e62ba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added +- Turn timestamps in a video's description and comments into links _community pr!_ ([#5156](https://github.com/lbryio/lbry-desktop/pull/5156)) - Mobile video player enhancements and the ability to tap on the left and right edges to seek _community pr!_ ([#5119](https://github.com/lbryio/lbry-desktop/pull/5119)) ### Changed diff --git a/ui/component/common/markdown-preview.jsx b/ui/component/common/markdown-preview.jsx index 0a87267c9..26d41555c 100644 --- a/ui/component/common/markdown-preview.jsx +++ b/ui/component/common/markdown-preview.jsx @@ -10,6 +10,7 @@ import reactRenderer from 'remark-react'; import MarkdownLink from 'component/markdownLink'; import defaultSchema from 'hast-util-sanitize/lib/github.json'; import { formatedLinks, inlineLinks } from 'util/remark-lbry'; +import { formattedTimestamp, inlineTimestamp } from 'util/remark-timestamp'; type SimpleTextProps = { children?: React.Node, @@ -149,6 +150,8 @@ const MarkdownPreview = (props: MarkdownProps) => { // Note: The order is important .use(formatedLinks) .use(inlineLinks) + .use(isMarkdownPost ? null : inlineTimestamp) + .use(isMarkdownPost ? null : formattedTimestamp) // Emojis .use(remarkEmoji) // Render new lines without needing spaces. diff --git a/ui/component/markdownLink/view.jsx b/ui/component/markdownLink/view.jsx index 130d273e5..2f0ab6986 100644 --- a/ui/component/markdownLink/view.jsx +++ b/ui/component/markdownLink/view.jsx @@ -62,10 +62,27 @@ function MarkdownLink(props: Props) { } } - // Return plain text if no valid url - // Return external link if protocol is http or https - // Return local link if protocol is lbry uri - if (!simpleLinks && ((protocol && protocol[0] === 'lbry:' && isURIValid(decodedUri)) || lbryUrlFromLink)) { + if (href.startsWith('?t=')) { + // Video timestamp markers + element = ( +