diff --git a/css/dragquestion.css b/css/dragquestion.css index 376ea31b..08ef785c 100644 --- a/css/dragquestion.css +++ b/css/dragquestion.css @@ -58,7 +58,6 @@ html.h5p-iframe .h5p-container.h5p-dragquestion.h5p-semi-fullscreen { border: 0.1em solid #c6c6c6; cursor: pointer; position: absolute; - text-align: center; padding: 0.3em 0.3em; line-height: 1.25em; diff --git a/library.json b/library.json index af8f3def..c1fb923d 100644 --- a/library.json +++ b/library.json @@ -3,8 +3,8 @@ "description": "Drag and drop the elements into the correct drop zones.", "contentType": "Question", "majorVersion": 1, - "minorVersion": 14, - "patchVersion": 20, + "minorVersion": 15, + "patchVersion": 0, "embedTypes": [ "iframe" ], @@ -66,4 +66,4 @@ "minorVersion": 0 } ] -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index fb385dc9..24cbc94e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "h5p-drag-question", - "version": "1.10.1", + "version": "1.15.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "h5p-drag-question", - "version": "1.10.1", + "version": "1.15.0", "license": "MIT", "devDependencies": { "@babel/cli": "^7.18.6", diff --git a/package.json b/package.json index 510a7e55..d4bade69 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "h5p-drag-question", - "version": "1.10.1", + "version": "1.15.0", "description": "Drag and drop the elements into the correct drop zones.", "main": "h5p-drag-question.js", "scripts": { diff --git a/upgrades.js b/upgrades.js index 23db04c1..958328ba 100644 --- a/upgrades.js +++ b/upgrades.js @@ -157,6 +157,33 @@ H5PUpgrades['H5P.DragQuestion'] = (function () { }); } + finished(null, parameters, extras); + }, + /** + * Regardless of what alignment was set in the editor, the stylesheet + * would always center the text. For not breaking the view of existing + * content, set all text to be centered in params - can be changed by + * user in the editor after upgrade. + */ + 15: function (parameters, finished, extras) { + if (Array.isArray(parameters.question.task.elements)) { + parameters.question.task.elements = + parameters.question.task.elements.map((element) => { + if ( + element.type?.library !== 'H5P.AdvancedText 1.1' || + typeof element.type?.params?.text !== 'string' + ) { + return element; + } + + element.type.params.text = element.type.params.text.replace( + /
]*>/g, '
' + ); + + return element; + }); + } + finished(null, parameters, extras); } }