From 9a7a3438444c23c782188b3c05d51b873f5f3908 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Thu, 3 Jan 2019 12:50:44 +0100 Subject: [PATCH] HFP-2508 Remove caching of pasted content Objects can not be referenced by multiple widgets when used in the editor --- js/h5p.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index bbca97f..4787d48 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -2207,23 +2207,13 @@ H5P.createTitle = function (rawTitle, maxLength) { H5P.setClipboard(clipboardItem); }; - /** - * This is a cache for pasted data to prevent parsing multiple times. - * @type {Object} - */ - var parsedClipboard = null; - /** * Retrieve parsed clipboard data. * * @return {Object} */ H5P.getClipboard = function () { - if (!parsedClipboard) { - parsedClipboard = parseClipboard(); - } - - return parsedClipboard; + return parseClipboard(); }; /** @@ -2234,9 +2224,6 @@ H5P.createTitle = function (rawTitle, maxLength) { H5P.setClipboard = function (clipboardItem) { localStorage.setItem('h5pClipboard', JSON.stringify(clipboardItem)); - // Clear cache - parsedClipboard = null; - // Trigger an event so all 'Paste' buttons may be enabled. H5P.externalDispatcher.trigger('datainclipboard', {reset: false}); }; @@ -2332,9 +2319,6 @@ H5P.createTitle = function (rawTitle, maxLength) { window.addEventListener('storage', function (event) { // Pick up clipboard changes from other tabs if (event.key === 'h5pClipboard') { - // Clear cache - parsedClipboard = null; - // Trigger an event so all 'Paste' buttons may be enabled. H5P.externalDispatcher.trigger('datainclipboard', {reset: event.newValue === null}); }