FIX: properly quote videos ()

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
app/assets/javascripts
discourse-markdown-it/src
discourse/app/lib

View File

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

View File

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