diff --git a/www/code/inner.js b/www/code/inner.js
index d74513035..785e82788 100644
--- a/www/code/inner.js
+++ b/www/code/inner.js
@@ -507,7 +507,7 @@ define([
var fileHost = privateData.fileHost || privateData.origin;
var src = fileHost + Hash.getBlobPathFromHex(secret.channel);
var key = Hash.encodeBase64(secret.keys.cryptKey);
- var mt = '';
+ var mt = UI.mediaTag(src, key).outerHTML;
editor.replaceSelection(mt);
}
};
diff --git a/www/common/common-interface.js b/www/common/common-interface.js
index 9bdf9ec7a..4d3520426 100644
--- a/www/common/common-interface.js
+++ b/www/common/common-interface.js
@@ -41,6 +41,15 @@ define([
return e;
};
+ // FIXME almost everywhere this is used would also be
+ // a good candidate for sframe-common's getMediatagFromHref
+ UI.mediaTag = function (src, key) {
+ return h('media-tag', {
+ src: src,
+ 'data-crypto-key': 'cryptpad:' + key,
+ });
+ };
+
var findCancelButton = UI.findCancelButton = function (root) {
if (root) {
return $(root).find('button.cancel').last();
diff --git a/www/common/diffMarked.js b/www/common/diffMarked.js
index d7c476a90..52a8cf0a1 100644
--- a/www/common/diffMarked.js
+++ b/www/common/diffMarked.js
@@ -676,7 +676,6 @@ define([
if (el.childNodes.length === 1 && el.childNodes[0].nodeType === 3) {
var type = el.getAttribute('data-plugin');
var plugin = plugins[type];
- console.log(type);
if (!plugin) { return; }
var src = canonicalizeMermaidSource(el.childNodes[0].wholeText);
el.setAttribute(plugin.attr, src);
diff --git a/www/common/inner/common-mediatag.js b/www/common/inner/common-mediatag.js
index 966724fa1..b8550fcac 100644
--- a/www/common/inner/common-mediatag.js
+++ b/www/common/inner/common-mediatag.js
@@ -127,9 +127,8 @@ define([
if (e || !data) { return void displayDefault(); }
if (typeof data !== "number") { return void displayDefault(); }
if (Util.bytesToMegabytes(data) > 0.5) { return void displayDefault(); }
- var $img = $('').appendTo($container);
- $img.attr('src', src);
- $img.attr('data-crypto-key', 'cryptpad:' + cryptKey);
+ var mt = UI.mediaTag(src, cryptKey);
+ var $img = $(mt).appendTo($container);
MT.displayMediatagImage(common, $img, function (err, $image) {
if (err) { return void console.error(err); }
centerImage($img, $image);
diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js
index 796640f6d..0fd250f80 100644
--- a/www/common/sframe-app-framework.js
+++ b/www/common/sframe-app-framework.js
@@ -748,8 +748,8 @@ define([
var privateDat = cpNfInner.metadataMgr.getPrivateData();
var origin = privateDat.fileHost || privateDat.origin;
var src = data.src = data.src.slice(0,1) === '/' ? origin + data.src : data.src;
- mediaTagEmbedder($(''), data);
+ var mt = UI.mediaTag(src, data.key);
+ mediaTagEmbedder($(mt), data);
});
}).appendTo(toolbar.$bottomL).hide();
};
diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js
index 3fd4869d1..5d3738cbb 100644
--- a/www/common/sframe-common.js
+++ b/www/common/sframe-common.js
@@ -145,8 +145,7 @@ define([
var hexFileName = secret.channel;
var origin = data.fileHost || data.origin;
var src = origin + Hash.getBlobPathFromHex(hexFileName);
- return '' +
- '';
+ return UI.mediaTag(src, key).outerHTML;
}
return;
};
diff --git a/www/kanban/inner.js b/www/kanban/inner.js
index 8eb090ffc..4832adcca 100644
--- a/www/kanban/inner.js
+++ b/www/kanban/inner.js
@@ -289,7 +289,7 @@ define([
var fileHost = privateData.fileHost || privateData.origin;
var src = fileHost + Hash.getBlobPathFromHex(secret.channel);
var key = Hash.encodeBase64(secret.keys.cryptKey);
- var mt = '';
+ var mt = UI.mediaTag(src, key).outerHTML;
editor.replaceSelection(mt);
}
};
diff --git a/www/poll/inner.js b/www/poll/inner.js
index 6d4e0590e..53faea7e9 100644
--- a/www/poll/inner.js
+++ b/www/poll/inner.js
@@ -955,7 +955,7 @@ define([
var fileHost = privateData.fileHost || privateData.origin;
var src = fileHost + Hash.getBlobPathFromHex(secret.channel);
var key = Hash.encodeBase64(secret.keys.cryptKey);
- var mt = '';
+ var mt = UI.mediaTag(src, key).outerHTML;
APP.editor.replaceSelection(mt);
}
};
@@ -1235,7 +1235,7 @@ define([
common.openFilePicker(pickerCfg, function (data) {
if (data.type === 'file' && APP.editor) {
common.setPadAttribute('atime', +new Date(), null, data.href);
- var mt = '';
+ var mt = UI.mediaTag(data.src, data.key).outerHTML;
APP.editor.replaceSelection(mt);
return;
}
diff --git a/www/slide/inner.js b/www/slide/inner.js
index 3eb1435ed..e40bd6d79 100644
--- a/www/slide/inner.js
+++ b/www/slide/inner.js
@@ -556,7 +556,7 @@ define([
var fileHost = privateData.fileHost || privateData.origin;
var src = fileHost + Hash.getBlobPathFromHex(secret.channel);
var key = Hash.encodeBase64(secret.keys.cryptKey);
- var mt = '';
+ var mt = UI.mediaTag(src, key).outerHTML;
editor.replaceSelection(mt);
}
};