Don't redraw a media-tag everytime the content has changed
This commit is contained in:
parent
2032c08066
commit
19cb920a7c
@ -53,6 +53,9 @@ body {
|
|||||||
font-family: Calibri, Ubuntu, sans-serif;
|
font-family: Calibri, Ubuntu, sans-serif;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
#previewContainer media-tag * {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
#preview {
|
#preview {
|
||||||
max-width: 40vw;
|
max-width: 40vw;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
|||||||
@ -56,6 +56,9 @@ body {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
font-family: Calibri,Ubuntu,sans-serif;
|
font-family: Calibri,Ubuntu,sans-serif;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
media-tag * {
|
||||||
|
max-width:100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#preview {
|
#preview {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ define([
|
|||||||
'/common/cryptpad-common.js',
|
'/common/cryptpad-common.js',
|
||||||
'/common/cryptget.js',
|
'/common/cryptget.js',
|
||||||
'/common/diffMarked.js',
|
'/common/diffMarked.js',
|
||||||
|
'/bower_components/tweetnacl/nacl-fast.min.js', // needed for media-tag
|
||||||
], function ($, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad,
|
], function ($, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad,
|
||||||
Cryptget, DiffMd) {
|
Cryptget, DiffMd) {
|
||||||
var Messages = Cryptpad.Messages;
|
var Messages = Cryptpad.Messages;
|
||||||
|
|||||||
@ -37,11 +37,7 @@ define([
|
|||||||
|
|
||||||
data.name = file.metadata.name;
|
data.name = file.metadata.name;
|
||||||
data.url = href;
|
data.url = href;
|
||||||
if (file.metadata.type.slice(0,6) === 'image/') {
|
data.mediatag = true;
|
||||||
data.mediatag = true;
|
|
||||||
}
|
|
||||||
//var generatedBlob = new Blob([file.blob]);
|
|
||||||
//window.URL.createObjectURL(generatedBlob);
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -60,6 +60,10 @@ define([
|
|||||||
'AUDIO',
|
'AUDIO',
|
||||||
];
|
];
|
||||||
var unsafeTag = function (info) {
|
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 (['addAttribute', 'modifyAttribute'].indexOf(info.diff.action) !== -1) {
|
||||||
if (/^on/.test(info.diff.name)) {
|
if (/^on/.test(info.diff.name)) {
|
||||||
console.log("Rejecting forbidden element attribute with name", info.diff.name);
|
console.log("Rejecting forbidden element attribute with name", info.diff.name);
|
||||||
@ -127,17 +131,7 @@ define([
|
|||||||
var DD = new DiffDOM({
|
var DD = new DiffDOM({
|
||||||
preDiffApply: function (info) {
|
preDiffApply: function (info) {
|
||||||
if (unsafeTag(info)) { return true; }
|
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) {
|
var makeDiff = function (A, B, id) {
|
||||||
@ -173,30 +167,16 @@ define([
|
|||||||
DD.apply($content[0], patch);
|
DD.apply($content[0], patch);
|
||||||
var $mts = $content.find('media-tag:not(:has(*))');
|
var $mts = $content.find('media-tag:not(:has(*))');
|
||||||
$mts.each(function (i, el) {
|
$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);
|
MediaTag(el);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$(window.document).on('decryption', function (e) {
|
||||||
|
var decrypted = e.originalEvent;
|
||||||
|
if (decrypted.callback) { decrypted.callback(); }
|
||||||
|
});
|
||||||
|
|
||||||
return DiffMd;
|
return DiffMd;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ define([
|
|||||||
'/common/cryptpad-common.js',
|
'/common/cryptpad-common.js',
|
||||||
'/common/cryptget.js',
|
'/common/cryptget.js',
|
||||||
'/slide/slide.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) {
|
], function ($, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Cryptget, Slide) {
|
||||||
var Messages = Cryptpad.Messages;
|
var Messages = Cryptpad.Messages;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user