FIX: properly quote videos (#30099)

Follow up to f294f984cf

All that was needed was a little fix to our markdown engine to use the
"image src" as the "video src" when the "data video src" was not
defined.

That way we can use the regular image markdown with the "|video" option
(?).
This commit is contained in:
Régis Hanol 2024-12-04 12:39:38 +01:00 committed by GitHub
parent 1ce12ae718
commit d2d8fbcf3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 4 deletions

View File

@ -187,7 +187,7 @@ function renderImageOrPlayableMedia(tokens, idx, options, env, slf) {
options.discourse.previewing &&
!options.discourse.limitedSiteSettings.enableDiffhtmlPreview
) {
const origSrc = token.attrGet("data-orig-src");
const origSrc = token.attrGet("data-orig-src") || token.attrGet("src");
const origSrcId = origSrc
.substring(origSrc.lastIndexOf("/") + 1)
.split(".")[0];

View File

@ -169,9 +169,7 @@ export function selectedText() {
div
.querySelectorAll("div.video-placeholder-container[data-video-src]")
.forEach((element) => {
element.replaceWith(
`<div class="video-container"><video preload="metadata" controls><source src="${element.dataset.videoSrc}"></video></div>`
);
element.replaceWith(`![|video](${element.dataset.videoSrc})`);
});
return toMarkdown(div.outerHTML);