Handle timestamp in Markdown.

The videojs player is exposed through the 'window' object.
This commit is contained in:
infiinte-persistence 2020-12-09 22:32:42 +08:00 committed by Sean Yesmunt
parent 93709fbeb8
commit 3f1913e5f4
3 changed files with 34 additions and 4 deletions

View file

@ -18,6 +18,16 @@ 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))
### Changed
### Fixed
## [0.49.0] - [2020-12-10]
### Added
- Better search suggestions ([#5124](https://github.com/lbryio/lbry-desktop/pull/5124))
- Inline video player in comments/markdown posts ([#4894](https://github.com/lbryio/lbry-desktop/pull/4894))
- Better handling of winning claim + top page improvements ([#4944](https://github.com/lbryio/lbry-desktop/pull/4944))

View file

@ -62,10 +62,27 @@ function MarkdownLink(props: Props) {
}
}
if (href.startsWith('?t=')) {
// Video timestamp markers
element = (
<Button
button="link"
iconRight={undefined}
title={title || decodedUri}
label={children}
className="button--external-link"
onClick={() => {
if (window.player) {
window.player.currentTime(parseInt(href.substr(3)));
window.scrollTo(0, 0);
}
}}
/>
);
} else if (!simpleLinks && ((protocol && protocol[0] === 'lbry:' && isURIValid(decodedUri)) || lbryUrlFromLink)) {
// 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)) {
element = (
<ClaimLink
uri={lbryUrlFromLink || decodedUri}

View file

@ -345,6 +345,8 @@ export default React.memo<Props>(function VideoJs(props: Props) {
}
});
window.player = player;
// fixes #3498 (https://github.com/lbryio/lbry-desktop/issues/3498)
// summary: on firefox the focus would stick to the fullscreen button which caused buggy behavior with spacebar
// $FlowFixMe
@ -357,6 +359,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
if (player) {
player.dispose();
window.player = undefined;
}
};
}