diff --git a/www/code/code.css b/www/code/code.css index 8c6cb3240..320256ab5 100644 --- a/www/code/code.css +++ b/www/code/code.css @@ -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; diff --git a/www/code/code.less b/www/code/code.less index 5f1aa2365..47b430350 100644 --- a/www/code/code.less +++ b/www/code/code.less @@ -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 { diff --git a/www/code/main.js b/www/code/main.js index 6a04c73ec..e9f42dae3 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -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; diff --git a/www/common/common-file.js b/www/common/common-file.js index bd6a85908..843196f83 100644 --- a/www/common/common-file.js +++ b/www/common/common-file.js @@ -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; }; diff --git a/www/common/diffMarked.js b/www/common/diffMarked.js index d78dc5480..1394fe7da 100644 --- a/www/common/diffMarked.js +++ b/www/common/diffMarked.js @@ -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; }); diff --git a/www/slide/main.js b/www/slide/main.js index e197fcc52..d0299ff6d 100644 --- a/www/slide/main.js +++ b/www/slide/main.js @@ -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;