From d2d8fbcf3be44b3cb14f274cbd1e8dc98e3e1408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 4 Dec 2024 12:39:38 +0100 Subject: [PATCH] FIX: properly quote videos (#30099) Follow up to f294f984cf64236a63e9ed21df3c8782e046c90f 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 (?). --- app/assets/javascripts/discourse-markdown-it/src/engine.js | 2 +- app/assets/javascripts/discourse/app/lib/utilities.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse-markdown-it/src/engine.js b/app/assets/javascripts/discourse-markdown-it/src/engine.js index 8e5deb7bdf0..21a1ddf4d97 100644 --- a/app/assets/javascripts/discourse-markdown-it/src/engine.js +++ b/app/assets/javascripts/discourse-markdown-it/src/engine.js @@ -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]; diff --git a/app/assets/javascripts/discourse/app/lib/utilities.js b/app/assets/javascripts/discourse/app/lib/utilities.js index 6c9a9a3c366..57ad015b19c 100644 --- a/app/assets/javascripts/discourse/app/lib/utilities.js +++ b/app/assets/javascripts/discourse/app/lib/utilities.js @@ -169,9 +169,7 @@ export function selectedText() { div .querySelectorAll("div.video-placeholder-container[data-video-src]") .forEach((element) => { - element.replaceWith( - `
` - ); + element.replaceWith(`![|video](${element.dataset.videoSrc})`); }); return toMarkdown(div.outerHTML);