diff --git a/lib/editor/tiny/plugins/h5p/amd/build/filtercontent.min.js b/lib/editor/tiny/plugins/h5p/amd/build/filtercontent.min.js index 8078589c5be..00a47bb288b 100644 --- a/lib/editor/tiny/plugins/h5p/amd/build/filtercontent.min.js +++ b/lib/editor/tiny/plugins/h5p/amd/build/filtercontent.min.js @@ -1,3 +1,3 @@ -define("tiny_h5p/filtercontent",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.setup=void 0;_exports.setup=async editor=>{editor.on("PreInit",(()=>{editor.formatter.register("h5p",{inline:"div",classes:"h5p-placeholder"})})),editor.on("SetContent",(()=>{editor.getBody().querySelectorAll(".h5p-placeholder:not([contenteditable])").forEach((node=>{node.contentEditable=!1}))}))}})); +define("tiny_h5p/filtercontent",["exports","editor_tiny/options"],(function(_exports,_options){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.setup=void 0;_exports.setup=async editor=>{const classSelector=".".concat("h5p-placeholder");(0,_options.registerPlaceholderSelectors)(editor,[classSelector]),editor.on("PreInit",(()=>{editor.formatter.register("h5p",{inline:"div",classes:"h5p-placeholder"})})),editor.on("SetContent",(()=>{editor.getBody().querySelectorAll("".concat(classSelector,":not([contenteditable])")).forEach((node=>{node.contentEditable=!1}))}))}})); //# sourceMappingURL=filtercontent.min.js.map \ No newline at end of file diff --git a/lib/editor/tiny/plugins/h5p/amd/build/filtercontent.min.js.map b/lib/editor/tiny/plugins/h5p/amd/build/filtercontent.min.js.map index f2cb6c50b9b..6ec9dc6db77 100644 --- a/lib/editor/tiny/plugins/h5p/amd/build/filtercontent.min.js.map +++ b/lib/editor/tiny/plugins/h5p/amd/build/filtercontent.min.js.map @@ -1 +1 @@ -{"version":3,"file":"filtercontent.min.js","sources":["../src/filtercontent.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny H5P Content configuration.\n *\n * @module tiny_h5p/filtercontent\n * @copyright 2022 Andrew Lyons \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport const setup = async(editor) => {\n // Register the H5P Formatter for use in all buttons.\n editor.on('PreInit', () => {\n editor.formatter.register('h5p', {\n inline: 'div',\n classes: 'h5p-placeholder',\n });\n });\n\n editor.on('SetContent', () => {\n // Listen to the SetContent event on the editor and update any h5p-placeholder to not be editable.\n // Doing this means that the inner content of the placeholder cannot be changed without using the dialogue.\n // The SetContent event is called whenever content is changed by actions such as initial load, paste, undo, etc.\n editor.getBody().querySelectorAll('.h5p-placeholder:not([contenteditable])').forEach((node) => {\n node.contentEditable = false;\n });\n });\n};\n"],"names":["async","editor","on","formatter","register","inline","classes","getBody","querySelectorAll","forEach","node","contentEditable"],"mappings":"6JAuBqBA,MAAAA,SAEjBC,OAAOC,GAAG,WAAW,KACjBD,OAAOE,UAAUC,SAAS,MAAO,CAC7BC,OAAQ,MACRC,QAAS,uBAIjBL,OAAOC,GAAG,cAAc,KAIpBD,OAAOM,UAAUC,iBAAiB,2CAA2CC,SAASC,OAClFA,KAAKC,iBAAkB"} \ No newline at end of file +{"version":3,"file":"filtercontent.min.js","sources":["../src/filtercontent.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny H5P Content configuration.\n *\n * @module tiny_h5p/filtercontent\n * @copyright 2022 Andrew Lyons \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {registerPlaceholderSelectors} from 'editor_tiny/options';\n\nexport const setup = async(editor) => {\n const className = 'h5p-placeholder';\n const classSelector = `.${className}`;\n // Register the H5P Formatter to the placeholder selector list.\n registerPlaceholderSelectors(editor, [classSelector]);\n // Register the H5P Formatter for use in all buttons.\n editor.on('PreInit', () => {\n editor.formatter.register('h5p', {\n inline: 'div',\n classes: className,\n });\n });\n\n editor.on('SetContent', () => {\n // Listen to the SetContent event on the editor and update any h5p-placeholder to not be editable.\n // Doing this means that the inner content of the placeholder cannot be changed without using the dialogue.\n // The SetContent event is called whenever content is changed by actions such as initial load, paste, undo, etc.\n editor.getBody().querySelectorAll(`${classSelector}:not([contenteditable])`).forEach((node) => {\n node.contentEditable = false;\n });\n });\n};\n"],"names":["async","classSelector","editor","on","formatter","register","inline","classes","getBody","querySelectorAll","forEach","node","contentEditable"],"mappings":"4LAyBqBA,MAAAA,eAEXC,yBADY,6DAGWC,OAAQ,CAACD,gBAEtCC,OAAOC,GAAG,WAAW,KACjBD,OAAOE,UAAUC,SAAS,MAAO,CAC7BC,OAAQ,MACRC,QARU,uBAYlBL,OAAOC,GAAG,cAAc,KAIpBD,OAAOM,UAAUC,2BAAoBR,0CAAwCS,SAASC,OAClFA,KAAKC,iBAAkB"} \ No newline at end of file diff --git a/lib/editor/tiny/plugins/h5p/amd/src/filtercontent.js b/lib/editor/tiny/plugins/h5p/amd/src/filtercontent.js index 69f35cbdc15..b7cd819ccae 100644 --- a/lib/editor/tiny/plugins/h5p/amd/src/filtercontent.js +++ b/lib/editor/tiny/plugins/h5p/amd/src/filtercontent.js @@ -21,12 +21,18 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +import {registerPlaceholderSelectors} from 'editor_tiny/options'; + export const setup = async(editor) => { + const className = 'h5p-placeholder'; + const classSelector = `.${className}`; + // Register the H5P Formatter to the placeholder selector list. + registerPlaceholderSelectors(editor, [classSelector]); // Register the H5P Formatter for use in all buttons. editor.on('PreInit', () => { editor.formatter.register('h5p', { inline: 'div', - classes: 'h5p-placeholder', + classes: className, }); }); @@ -34,7 +40,7 @@ export const setup = async(editor) => { // Listen to the SetContent event on the editor and update any h5p-placeholder to not be editable. // Doing this means that the inner content of the placeholder cannot be changed without using the dialogue. // The SetContent event is called whenever content is changed by actions such as initial load, paste, undo, etc. - editor.getBody().querySelectorAll('.h5p-placeholder:not([contenteditable])').forEach((node) => { + editor.getBody().querySelectorAll(`${classSelector}:not([contenteditable])`).forEach((node) => { node.contentEditable = false; }); }); diff --git a/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature b/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature index a6f48937f4a..d8f419601d4 100644 --- a/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature +++ b/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature @@ -1,4 +1,4 @@ -@editor @editor_tiny @tiny_media @javascript @_file_upload +@editor @editor_tiny @tiny_h5p @javascript @_file_upload Feature: Use the TinyMCE editor to upload an h5p package In order to work with h5p As a content creator