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);
};
/**
* 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});
}