From 38f568635da16c1f07a58ee96ca1c780d0c18275 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 26 Jun 2017 14:08:14 +0200 Subject: [PATCH] Fix duplicate media-tag in slides when adding or removing a slide --- www/common/diffMarked.js | 32 ++++++++++++++++++++++++++++---- www/slide/slide.js | 20 ++++++++++++-------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/www/common/diffMarked.js b/www/common/diffMarked.js index 4adbbc18f..d760c0f5c 100644 --- a/www/common/diffMarked.js +++ b/www/common/diffMarked.js @@ -19,6 +19,8 @@ define([ return Marked(md); }; + var mediaMap = {}; + // Tasks list var checkedTaskItemPtn = /^\s*\[x\]\s*/; var uncheckedTaskItemPtn = /^\s*\[ \]\s*/; @@ -40,7 +42,14 @@ define([ if (href.slice(0,6) === '/file/') { var parsed = Cryptpad.parsePadUrl(href); var hexFileName = Cryptpad.base64ToHex(parsed.hashData.channel); - var mt = ''; + var src = '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName; + var mt = ''; + if (mediaMap[src]) { + mediaMap[src].forEach(function (n) { + mt += n.outerHTML; + }); + } + mt += ''; return mt; } var out = '