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

pull/1/head
yflory 8 years ago
parent 2032c08066
commit 19cb920a7c

@ -53,6 +53,9 @@ body {
font-family: Calibri, Ubuntu, sans-serif;
word-wrap: break-word;
}
#previewContainer media-tag * {
max-width: 100%;
}
#preview {
max-width: 40vw;
margin: auto;

@ -56,6 +56,9 @@ body {
box-sizing: border-box;
font-family: Calibri,Ubuntu,sans-serif;
word-wrap: break-word;
media-tag * {
max-width:100%;
}
}
#preview {

@ -9,6 +9,7 @@ define([
'/common/cryptpad-common.js',
'/common/cryptget.js',
'/common/diffMarked.js',
'/bower_components/tweetnacl/nacl-fast.min.js', // needed for media-tag
], function ($, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad,
Cryptget, DiffMd) {
var Messages = Cryptpad.Messages;

@ -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;
};

@ -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;
});

@ -9,6 +9,7 @@ define([
'/common/cryptpad-common.js',
'/common/cryptget.js',
'/slide/slide.js',
'/bower_components/tweetnacl/nacl-fast.min.js', // needed for media-tag
], function ($, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Cryptget, Slide) {
var Messages = Cryptpad.Messages;

Loading…
Cancel
Save