HFP-2508 Remove caching of pasted content

Objects can not be referenced by multiple widgets when used in the editor
content-upgrade-on-upload
Frode Petterson 2019-01-03 12:50:44 +01:00
parent f19ca76461
commit 9a7a343844
1 changed files with 1 additions and 17 deletions

View File

@ -2207,23 +2207,13 @@ H5P.createTitle = function (rawTitle, maxLength) {
H5P.setClipboard(clipboardItem); H5P.setClipboard(clipboardItem);
}; };
/**
* This is a cache for pasted data to prevent parsing multiple times.
* @type {Object}
*/
var parsedClipboard = null;
/** /**
* Retrieve parsed clipboard data. * Retrieve parsed clipboard data.
* *
* @return {Object} * @return {Object}
*/ */
H5P.getClipboard = function () { H5P.getClipboard = function () {
if (!parsedClipboard) { return parseClipboard();
parsedClipboard = parseClipboard();
}
return parsedClipboard;
}; };
/** /**
@ -2234,9 +2224,6 @@ H5P.createTitle = function (rawTitle, maxLength) {
H5P.setClipboard = function (clipboardItem) { H5P.setClipboard = function (clipboardItem) {
localStorage.setItem('h5pClipboard', JSON.stringify(clipboardItem)); localStorage.setItem('h5pClipboard', JSON.stringify(clipboardItem));
// Clear cache
parsedClipboard = null;
// Trigger an event so all 'Paste' buttons may be enabled. // Trigger an event so all 'Paste' buttons may be enabled.
H5P.externalDispatcher.trigger('datainclipboard', {reset: false}); H5P.externalDispatcher.trigger('datainclipboard', {reset: false});
}; };
@ -2332,9 +2319,6 @@ H5P.createTitle = function (rawTitle, maxLength) {
window.addEventListener('storage', function (event) { window.addEventListener('storage', function (event) {
// Pick up clipboard changes from other tabs // Pick up clipboard changes from other tabs
if (event.key === 'h5pClipboard') { if (event.key === 'h5pClipboard') {
// Clear cache
parsedClipboard = null;
// Trigger an event so all 'Paste' buttons may be enabled. // Trigger an event so all 'Paste' buttons may be enabled.
H5P.externalDispatcher.trigger('datainclipboard', {reset: event.newValue === null}); H5P.externalDispatcher.trigger('datainclipboard', {reset: event.newValue === null});
} }