Don't redraw a media-tag everytime the content has changed

This commit is contained in:
yflory
2017-06-13 17:21:22 +02:00
parent 2032c08066
commit 19cb920a7c
6 changed files with 18 additions and 34 deletions

View File

@@ -37,11 +37,7 @@ define([
data.name = file.metadata.name;
data.url = href;
if (file.metadata.type.slice(0,6) === 'image/') {
data.mediatag = true;
}
//var generatedBlob = new Blob([file.blob]);
//window.URL.createObjectURL(generatedBlob);
data.mediatag = true;
return data;
};

View File

@@ -60,6 +60,10 @@ define([
'AUDIO',
];
var unsafeTag = function (info) {
if (info.node && $(info.node).parents('media-tag').length) {
// Do not remove elements inside a media-tag
return true;
}
if (['addAttribute', 'modifyAttribute'].indexOf(info.diff.action) !== -1) {
if (/^on/.test(info.diff.name)) {
console.log("Rejecting forbidden element attribute with name", info.diff.name);
@@ -127,17 +131,7 @@ define([
var DD = new DiffDOM({
preDiffApply: function (info) {
if (unsafeTag(info)) { return true; }
//var mt = mediaTag(info);
//console.log(mt);
//if (mt) { toTransform = toTransform.concat(mt); }
},
postDiffApply: function () {
/*while (toTransform.length) {
var el = toTransform.pop();
console.log(el);
MediaTag(el);
}*/
}
});
var makeDiff = function (A, B, id) {
@@ -173,30 +167,16 @@ define([
DD.apply($content[0], patch);
var $mts = $content.find('media-tag:not(:has(*))');
$mts.each(function (i, el) {
console.log(el);
var allowedMediaTypes = [
'image/png',
'image/jpeg',
'image/jpg',
'image/gif',
'audio/mp3',
'audio/ogg',
'audio/wav',
'audio/webm',
'video/mp4',
'video/ogg',
'video/webm',
'application/pdf',
'application/dash+xml',
'download'
];
MediaTag.CryptoFilter.setAllowedMediaTypes(allowedMediaTypes);
MediaTag(el);
});
}
};
$(window.document).on('decryption', function (e) {
var decrypted = e.originalEvent;
if (decrypted.callback) { decrypted.callback(); }
});
return DiffMd;
});