MDL-67129 atto_h5p: uneditable .h5p-placeholder container
authorBas Brands <bas@moodle.com>
Tue, 5 Nov 2019 11:26:32 +0000 (12:26 +0100)
committerBas Brands <bas@moodle.com>
Thu, 7 Nov 2019 13:06:38 +0000 (14:06 +0100)
lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button-debug.js
lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button-min.js
lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button.js
lib/editor/atto/plugins/h5p/yui/src/button/js/button.js

index 61169c4..836a2bf 100644 (file)
Binary files a/lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button-debug.js and b/lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button-debug.js differ
index a31effc..f18c330 100644 (file)
Binary files a/lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button-min.js and b/lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button-min.js differ
index 61169c4..836a2bf 100644 (file)
Binary files a/lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button.js and b/lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button.js differ
index dbe30b3..66971a8 100644 (file)
@@ -128,9 +128,11 @@ var CSS = {
             '</form>',
 
         H5PTEMPLATE = '' +
-            '<div class="h5p-placeholder">' +
+            '{{#if addParagraphs}}<p><br></p>{{/if}}' +
+            '<div class="h5p-placeholder" contenteditable="false">' +
                 '{{{url}}}' +
-            '</div><div><br></div>';
+            '</div>' +
+            '{{#if addParagraphs}}<p><br></p>{{/if}}';
 
 Y.namespace('M.atto_h5p').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
     /**
@@ -185,6 +187,7 @@ Y.namespace('M.atto_h5p').Button = Y.Base.create('button', Y.M.editor_atto.Edito
         });
 
         this.editor.on(['keyup', 'cut'], this._clearH5P, this);
+        this.editor.all('.h5p-placeholder').setAttribute('contenteditable', 'false');
         this.editor.delegate('dblclick', this._handleDblClick, '.h5p-placeholder', this);
         this.editor.delegate('click', this._handleClick, '.h5p-placeholder', this);
     },
@@ -468,12 +471,16 @@ Y.namespace('M.atto_h5p').Button = Y.Base.create('button', Y.M.editor_atto.Edito
             return;
         }
 
-        // Focus on the editor in preparation for inserting the h5p.
+        // Focus on the editor in preparation for inserting the H5P.
         host.focus();
 
+        // Add an empty paragraph after new H5P container that can catch the cursor.
+        var addParagraphs = true;
+
         // If a H5P placeholder was selected we can destroy it now.
         if (this._H5PDiv) {
             this._H5PDiv.remove();
+            addParagraphs = false;
         }
 
         if (url !== '') {
@@ -533,7 +540,8 @@ Y.namespace('M.atto_h5p').Button = Y.Base.create('button', Y.M.editor_atto.Edito
             var h5ptemplate = Y.Handlebars.compile(H5PTEMPLATE);
 
             h5phtml = h5ptemplate({
-                url: h5pfile + params
+                url: h5pfile + params,
+                addParagraphs: addParagraphs
             });
 
             this.get('host').insertContentAtFocusPoint(h5phtml);