From 7664eb27c4d53dfeb9fbf57813af254262a456ff Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 13 Feb 2020 16:58:28 +0000 Subject: [PATCH] Move bulk to react-sdk and reference it from riot-web land Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/usercontent/index.html | 12 -------- src/vector/usercontent/index.js | 49 ------------------------------- webpack.config.js | 4 +-- 3 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 src/vector/usercontent/index.html delete mode 100644 src/vector/usercontent/index.js diff --git a/src/vector/usercontent/index.html b/src/vector/usercontent/index.html deleted file mode 100644 index 90a0fe7c1..000000000 --- a/src/vector/usercontent/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/src/vector/usercontent/index.js b/src/vector/usercontent/index.js deleted file mode 100644 index 8e77f6860..000000000 --- a/src/vector/usercontent/index.js +++ /dev/null @@ -1,49 +0,0 @@ -var params = window.location.search.substring(1).split('&'); -var lockOrigin; -for (var i = 0; i < params.length; ++i) { - var parts = params[i].split('='); - if (parts[0] === 'origin') lockOrigin = decodeURIComponent(parts[1]); -} - -function remoteRender(event) { - const data = event.data; - - const img = document.createElement("img"); - img.id = "img"; - img.src = data.imgSrc; - img.style = data.imgStyle; - - const a = document.createElement("a"); - a.id = "a"; - a.rel = "noopener"; - a.target = "_blank"; - a.download = data.download; - a.style = data.style; - a.style.fontFamily = "Arial, Helvetica, Sans-Serif"; - a.href = window.URL.createObjectURL(data.blob); - a.appendChild(img); - a.appendChild(document.createTextNode(data.textContent)); - - const body = document.body; - // Don't display scrollbars if the link takes more than one line to display. - body.style = "margin: 0px; overflow: hidden"; - body.appendChild(a); -} - -function remoteSetTint(event) { - const data = event.data; - - const img = document.getElementById("img"); - img.src = data.imgSrc; - img.style = data.imgStyle; - - const a = document.getElementById("a"); - a.style = data.style; -} - -window.onmessage = function(e) { - if (lockOrigin === undefined || e.origin === lockOrigin) { - if (e.data.blob) remoteRender(e); - else remoteSetTint(e); - } -}; diff --git a/webpack.config.js b/webpack.config.js index 86e6eb1de..3c7e1c94b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -34,7 +34,7 @@ module.exports = (env, argv) => { "bundle": "./src/vector/index.js", "indexeddb-worker": "./src/vector/indexeddb-worker.js", "mobileguide": "./src/vector/mobile_guide/index.js", - "usercontent": "./src/vector/usercontent/index.js", + "usercontent": "./node_modules/matrix-react-sdk/src/vector/usercontent/index.js", // CSS themes "theme-light": "./node_modules/matrix-react-sdk/res/themes/light/css/light.scss", @@ -320,7 +320,7 @@ module.exports = (env, argv) => { // This is the usercontent sandbox's entry point (separate for iframing) new HtmlWebpackPlugin({ - template: './src/vector/usercontent/index.html', + template: './node_modules/matrix-react-sdk/src/vector/usercontent/index.html', filename: 'usercontent/index.html', minify: argv.mode === 'production', chunks: ['usercontent'],