MDL-75261 tiny_h5p: Add the Tiny H5P plugin

Part of MDL-75966

AMOS BEGIN
 CPY [browserepositories,atto_h5p],[browserepositories,tiny_h5p]
 CPY [copyrightbutton,atto_h5p],[bcopyrightbutton,tiny_h5p]
 CPY [downloadbutton,atto_h5p],[downloadbutton,tiny_h5p]
 CPY [embedbutton,atto_h5p],[embedbutton,tiny_h5p]
 CPY [h5p:addembed,atto_h5p],[h5p:addembed,tiny_h5p]
 CPY [h5pfile,atto_h5p],[h5pfile,tiny_h5p]
 CPY [h5pfileorurl,atto_h5p],[h5pfileorurl,tiny_h5p]
 CPY [h5poptions,atto_h5p],[h5poptions,tiny_h5p]
 CPY [h5purl,atto_h5p],[h5purl,tiny_h5p]
 CPY [invalidh5purl,atto_h5p],[invalidh5purl,tiny_h5p]
 CPY [instructions,atto_h5p],[instructions,tiny_h5p]
 CPY [noh5pcontent,atto_h5p],[noh5pcontent,tiny_h5p]
AMOS END
This commit is contained in:
Andrew Nicols
2022-11-10 19:53:36 +08:00
parent c4a0896134
commit a6032854bf
37 changed files with 1045 additions and 0 deletions
+1
View File
@@ -2029,6 +2029,7 @@ class core_plugin_manager {
),
'tiny' => [
'h5p',
],
'tinymce' => array(
+3
View File
@@ -0,0 +1,3 @@
define("tiny_h5p/commands",["exports","editor_tiny/utils","./ui","core/str","./common"],(function(_exports,_utils,_ui,_str,_common){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.getSetup=void 0;_exports.getSetup=async()=>{const[buttonText,buttonImage]=await Promise.all([(0,_str.get_string)("buttontitle",_common.component),(0,_utils.getButtonImage)("icon",_common.component)]);return editor=>{editor.ui.registry.addIcon(_common.icon,buttonImage.html),editor.ui.registry.addToggleButton(_common.buttonName,{icon:_common.icon,tooltip:buttonText,onAction:()=>(0,_ui.handleAction)(editor),onSetup:api=>{api.setActive(editor.formatter.match("h5p"));const changed=editor.formatter.formatChanged("h5p",(state=>api.setActive(state)));return()=>changed.unbind()}}),editor.ui.registry.addMenuItem(_common.buttonName,{icon:_common.icon,text:buttonText,onAction:()=>(0,_ui.handleAction)(editor)})}}}));
//# sourceMappingURL=commands.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"commands.min.js","sources":["../src/commands.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Tiny H5P Content configuration.\n *\n * @module tiny_h5p/commands\n * @copyright 2022 Andrew Lyons <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {getButtonImage} from 'editor_tiny/utils';\nimport {handleAction} from './ui';\nimport {get_string as getString} from 'core/str';\nimport {\n component,\n buttonName,\n icon,\n} from './common';\n\nexport const getSetup = async() => {\n const [\n buttonText,\n buttonImage,\n ] = await Promise.all([\n getString('buttontitle', component),\n getButtonImage('icon', component),\n ]);\n\n return (editor) => {\n // Register the H5P Icon.\n editor.ui.registry.addIcon(icon, buttonImage.html);\n\n // Register the Menu Button as a toggle.\n // This means that when highlighted over an existing H5P element it will show as toggled on.\n editor.ui.registry.addToggleButton(buttonName, {\n icon,\n tooltip: buttonText,\n onAction: () => handleAction(editor),\n onSetup: (api) => {\n // Set the button to be active if the current selection matches the h5p formatter registered above during PreInit.\n api.setActive(editor.formatter.match('h5p'));\n const changed = editor.formatter.formatChanged('h5p', (state) => api.setActive(state));\n return () => changed.unbind();\n },\n });\n\n // Add the H5P Menu Item.\n // This allows it to be added to a standard menu, or a context menu.\n editor.ui.registry.addMenuItem(buttonName, {\n icon,\n text: buttonText,\n onAction: () => handleAction(editor),\n });\n };\n};\n"],"names":["async","buttonText","buttonImage","Promise","all","component","editor","ui","registry","addIcon","icon","html","addToggleButton","buttonName","tooltip","onAction","onSetup","api","setActive","formatter","match","changed","formatChanged","state","unbind","addMenuItem","text"],"mappings":"uOAgCwBA,gBAEhBC,WACAC,mBACMC,QAAQC,IAAI,EAClB,mBAAU,cAAeC,oBACzB,yBAAe,OAAQA,4BAGnBC,SAEJA,OAAOC,GAAGC,SAASC,QAAQC,aAAMR,YAAYS,MAI7CL,OAAOC,GAAGC,SAASI,gBAAgBC,mBAAY,CAC3CH,KAAAA,aACAI,QAASb,WACTc,SAAU,KAAM,oBAAaT,QAC7BU,QAAUC,MAENA,IAAIC,UAAUZ,OAAOa,UAAUC,MAAM,cAC/BC,QAAUf,OAAOa,UAAUG,cAAc,OAAQC,OAAUN,IAAIC,UAAUK,eACxE,IAAMF,QAAQG,YAM7BlB,OAAOC,GAAGC,SAASiB,YAAYZ,mBAAY,CACvCH,KAAAA,aACAgB,KAAMzB,WACNc,SAAU,KAAM,oBAAaT"}
+3
View File
@@ -0,0 +1,3 @@
define("tiny_h5p/common",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={pluginName:"tiny_h5p/plugin",component:"tiny_h5p",buttonName:"tiny_h5p",icon:"tiny_h5p"},_exports.default}));
//# sourceMappingURL=common.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"common.min.js","sources":["../src/common.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Tiny H5P Common values.\n *\n * @module tiny_h5p/common\n * @copyright 2022 Andrew Lyons <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport default {\n pluginName: 'tiny_h5p/plugin',\n component: 'tiny_h5p',\n buttonName: 'tiny_h5p',\n icon: 'tiny_h5p',\n};\n"],"names":["pluginName","component","buttonName","icon"],"mappings":"iKAuBe,CACXA,WAAY,kBACZC,UAAW,WACXC,WAAY,WACZC,KAAM"}
@@ -0,0 +1,3 @@
define("tiny_h5p/configuration",["exports","./common","editor_tiny/utils"],(function(_exports,_common,_utils){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.configure=void 0;_exports.configure=instanceConfig=>({toolbar:(0,_utils.addToolbarButton)(instanceConfig.toolbar,"content",_common.component),menu:(0,_utils.addMenubarItem)(instanceConfig.menu,"insert",_common.component)})}));
//# sourceMappingURL=configuration.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"configuration.min.js","sources":["../src/configuration.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Tiny H5P Content configuration.\n *\n * @module tiny_h5p/configuration\n * @copyright 2022 Andrew Lyons <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {component as buttonName} from './common';\nimport {\n addMenubarItem,\n addToolbarButton,\n} from 'editor_tiny/utils';\n\nexport const configure = (instanceConfig) => {\n // Update the instance configuration to add the H5P menu option to the menus and toolbars.\n return {\n toolbar: addToolbarButton(instanceConfig.toolbar, 'content', buttonName),\n menu: addMenubarItem(instanceConfig.menu, 'insert', buttonName),\n };\n};\n"],"names":["instanceConfig","toolbar","buttonName","menu"],"mappings":"mNA6B0BA,iBAEf,CACHC,SAAS,2BAAiBD,eAAeC,QAAS,UAAWC,mBAC7DC,MAAM,yBAAeH,eAAeG,KAAM,SAAUD"}
@@ -0,0 +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}))}))}}));
//# sourceMappingURL=filtercontent.min.js.map
@@ -0,0 +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 <http://www.gnu.org/licenses/>.\n\n/**\n * Tiny H5P Content configuration.\n *\n * @module tiny_h5p/filtercontent\n * @copyright 2022 Andrew Lyons <[email protected]>\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"}
+3
View File
@@ -0,0 +1,3 @@
define("tiny_h5p/modal",["exports","core/modal","core/modal_registry"],(function(_exports,_modal,_modal_registry){var _class;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_modal=_interopRequireDefault(_modal),_modal_registry=_interopRequireDefault(_modal_registry);const H5PModal=(_defineProperty(_class=class extends _modal.default{registerEventListeners(){super.registerEventListeners(),this.registerCloseOnSave(),this.registerCloseOnCancel()}},"TYPE","tiny_h5p/modal"),_defineProperty(_class,"TEMPLATE","tiny_h5p/modal"),_class);_modal_registry.default.register(H5PModal.TYPE,H5PModal,H5PModal.TEMPLATE);var _default=H5PModal;return _exports.default=_default,_exports.default}));
//# sourceMappingURL=modal.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"modal.min.js","sources":["../src/modal.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 <http://www.gnu.org/licenses/>.\n\n/**\n * H5P Management Modal for Tiny.\n *\n * @module tiny_h5p/modal\n * @copyright 2022 Andrew Lyons <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport ModalRegistry from 'core/modal_registry';\n\nconst H5PModal = class extends Modal {\n static TYPE = 'tiny_h5p/modal';\n\n static TEMPLATE = 'tiny_h5p/modal';\n\n registerEventListeners() {\n // Call the parent registration.\n super.registerEventListeners();\n\n // Register to close on save/cancel.\n this.registerCloseOnSave();\n this.registerCloseOnCancel();\n }\n};\n\nModalRegistry.register(H5PModal.TYPE, H5PModal, H5PModal.TEMPLATE);\n\nexport default H5PModal;\n"],"names":["H5PModal","Modal","registerEventListeners","registerCloseOnSave","registerCloseOnCancel","register","TYPE","TEMPLATE"],"mappings":"uiBA0BMA,iCAAW,cAAcC,eAK3BC,+BAEUA,8BAGDC,2BACAC,iCAVK,oDAEI,kDAYRC,SAASL,SAASM,KAAMN,SAAUA,SAASO,uBAE1CP"}
+11
View File
@@ -0,0 +1,11 @@
define("tiny_h5p/options",["exports","editor_tiny/options","./common"],(function(_exports,_options,_common){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.register=_exports.getPermissions=void 0;
/**
* Options helper for Tiny H5P plugin.
*
* @module tiny_h5p/options
* @copyright 2022 Andrew Lyons <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
const permissionsName=(0,_options.getPluginOptionName)(_common.pluginName,"permissions");_exports.register=editor=>{(0,editor.options.register)(permissionsName,{processor:"object",default:{upload:!1,embed:!1}})};_exports.getPermissions=editor=>editor.options.get(permissionsName)}));
//# sourceMappingURL=options.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"options.min.js","sources":["../src/options.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Options helper for Tiny H5P plugin.\n *\n * @module tiny_h5p/options\n * @copyright 2022 Andrew Lyons <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {getPluginOptionName} from 'editor_tiny/options';\nimport {pluginName} from './common';\n\nconst permissionsName = getPluginOptionName(pluginName, 'permissions');\n\n/**\n * Register the options for the Tiny H5P plugin.\n *\n * @param {TinyMCE} editor\n */\nexport const register = (editor) => {\n const registerOption = editor.options.register;\n\n registerOption(permissionsName, {\n processor: 'object',\n \"default\": {\n upload: false,\n embed: false,\n },\n });\n};\n\n/**\n * Get the permissions configuration for the Tiny H5P plugin.\n *\n * @param {TinyMCE} editor\n * @returns {object}\n */\nexport const getPermissions = (editor) => editor.options.get(permissionsName);\n"],"names":["permissionsName","pluginName","editor","registerOption","options","register","processor","upload","embed","get"],"mappings":";;;;;;;;MA0BMA,iBAAkB,gCAAoBC,mBAAY,iCAO/BC,UAGrBC,EAFuBD,OAAOE,QAAQC,UAEvBL,gBAAiB,CAC5BM,UAAW,iBACA,CACPC,QAAQ,EACRC,OAAO,8BAWYN,QAAWA,OAAOE,QAAQK,IAAIT"}
+10
View File
@@ -0,0 +1,10 @@
define("tiny_h5p/plugin",["exports","editor_tiny/loader","editor_tiny/utils","./common","./filtercontent","./commands","./configuration","./options"],(function(_exports,_loader,_utils,_common,FilterContent,Commands,Configuration,Options){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}
/**
* Tiny H5P plugin for Moodle.
*
* @module tiny_h5p/plugin
* @copyright 2022 Andrew Lyons <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,FilterContent=_interopRequireWildcard(FilterContent),Commands=_interopRequireWildcard(Commands),Configuration=_interopRequireWildcard(Configuration),Options=_interopRequireWildcard(Options);var _default=new Promise((async resolve=>{const[tinyMCE,setupCommands,pluginMetadata]=await Promise.all([(0,_loader.getTinyMCE)(),Commands.getSetup(),(0,_utils.getPluginMetadata)(_common.component,_common.pluginName)]);tinyMCE.PluginManager.add("".concat(_common.component,"/plugin"),(editor=>(Options.register(editor),FilterContent.setup(editor),setupCommands(editor),pluginMetadata))),resolve(["".concat(_common.component,"/plugin"),Configuration])}));return _exports.default=_default,_exports.default}));
//# sourceMappingURL=plugin.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"plugin.min.js","sources":["../src/plugin.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Tiny H5P plugin for Moodle.\n *\n * @module tiny_h5p/plugin\n * @copyright 2022 Andrew Lyons <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport {getTinyMCE} from 'editor_tiny/loader';\nimport {getPluginMetadata} from 'editor_tiny/utils';\n\nimport {component, pluginName} from './common';\nimport * as FilterContent from './filtercontent';\nimport * as Commands from './commands';\nimport * as Configuration from './configuration';\nimport * as Options from './options';\n\n// Setup the H5P Plugin to add a button and menu option.\nexport default new Promise(async(resolve) => {\n const [\n tinyMCE,\n setupCommands,\n pluginMetadata,\n ] = await Promise.all([\n getTinyMCE(),\n Commands.getSetup(),\n getPluginMetadata(component, pluginName),\n ]);\n\n // Note: The PluginManager.add function does not accept a Promise.\n // Any asynchronous code must be run before this point.\n tinyMCE.PluginManager.add(`${component}/plugin`, (editor) => {\n // Register options.\n Options.register(editor);\n\n // Setup the Formatter.\n FilterContent.setup(editor);\n\n // Setup the Commands (buttons, menu items, and so on).\n setupCommands(editor);\n\n return pluginMetadata;\n });\n\n // Resolve the H5P Plugin and include configuration.\n resolve([`${component}/plugin`, Configuration]);\n});\n"],"names":["Promise","async","tinyMCE","setupCommands","pluginMetadata","all","Commands","getSetup","component","pluginName","PluginManager","add","editor","Options","register","FilterContent","setup","resolve","Configuration"],"mappings":";;;;;;;gSAgCe,IAAIA,SAAQC,MAAAA,gBAEnBC,QACAC,cACAC,sBACMJ,QAAQK,IAAI,EAClB,wBACAC,SAASC,YACT,4BAAkBC,kBAAWC,sBAKjCP,QAAQQ,cAAcC,cAAOH,8BAAqBI,SAE9CC,QAAQC,SAASF,QAGjBG,cAAcC,MAAMJ,QAGpBT,cAAcS,QAEPR,kBAIXa,QAAQ,WAAIT,6BAAoBU"}
+10
View File
@@ -0,0 +1,10 @@
define("tiny_h5p/ui",["exports","editor_tiny/utils","./common","./options","core/normalise","core/templates","tiny_h5p/modal","core/modal_events","core/modal_factory"],(function(_exports,_utils,_common,_options,_normalise,_templates,_modal,_modal_events,_modal_factory){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
/**
* Tiny H5P Content configuration.
*
* @module tiny_h5p/commands
* @copyright 2022 Andrew Lyons <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.handleAction=void 0,_modal=_interopRequireDefault(_modal),_modal_events=_interopRequireDefault(_modal_events),_modal_factory=_interopRequireDefault(_modal_factory);let openingSelection=null;_exports.handleAction=editor=>{openingSelection=editor.selection.getBookmark(),displayDialogue(editor)};const getTemplateContext=(editor,data)=>{var _permissions$upload,_permissions$embed,_data$url;const permissions=(0,_options.getPermissions)(editor),canUpload=null!==(_permissions$upload=permissions.upload)&&void 0!==_permissions$upload&&_permissions$upload,canEmbed=null!==(_permissions$embed=permissions.embed)&&void 0!==_permissions$embed&&_permissions$embed,canUploadAndEmbed=canUpload&&canEmbed;return Object.assign({},{elementid:editor.id,canUpload:canUpload,canEmbed:canEmbed,canUploadAndEmbed:canUploadAndEmbed,showOptions:!1,fileURL:null!==(_data$url=null==data?void 0:data.url)&&void 0!==_data$url?_data$url:""},data)},handleDialogueSubmission=async(editor,modal,data)=>{const form=(0,_normalise.getList)(modal.getRoot())[0].querySelector("form");if(!form)return void displayDialogue(editor,Object.assign({},data));const submittedUrl=form.querySelector('input[name="url"]').value,url=((form,submittedUrl,permissions)=>{if(!submittedUrl)return null;const url=new URL(submittedUrl);return null!=permissions&&permissions.upload&&form.querySelector('[name="download"]').checked&&url.searchParams.append("export",1),null!=permissions&&permissions.embed&&form.querySelector('[name="embed"]').checked&&url.searchParams.append("embed",1),form.querySelector('[name="copyright"]').checked&&url.searchParams.append("copyright",1),url})(form,submittedUrl,(0,_options.getPermissions)(editor));if(!url)return void displayDialogue(editor,Object.assign({},data,{url:submittedUrl,invalidUrl:!0}));const content=await(0,_templates.renderForPromise)("".concat(_common.component,"/content"),{url:url.toString()});editor.selection.moveToBookmark(openingSelection),editor.execCommand("mceInsertContent",!1,content.html),editor.selection.moveToBookmark(openingSelection)},getCurrentH5PData=currentH5P=>{const data={};let url;try{url=new URL(currentH5P.textContent)}catch(error){return data}return url.searchParams.has("export")&&(data.download=!0,data.showOptions=!0,url.searchParams.delete("export")),url.searchParams.has("embed")&&(data.embed=!0,data.showOptions=!0,url.searchParams.delete("embed")),url.searchParams.has("copyright")&&(data.copyright=!0,data.showOptions=!0,url.searchParams.delete("copyright")),data.url=url.toString(),data},displayDialogue=async function(editor){let data=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const selection=editor.selection.getNode(),currentH5P=selection.closest(".h5p-placeholder");currentH5P&&Object.assign(data,getCurrentH5PData(currentH5P));const modal=await _modal_factory.default.create({type:_modal.default.TYPE,templateContext:getTemplateContext(editor,data),large:!0});modal.show();const $root=modal.getRoot(),root=$root[0];$root.on(_modal_events.default.save,((event,modal)=>{handleDialogueSubmission(editor,modal,data)})),root.addEventListener("click",(e=>{e.target.closest('[data-target="filepicker"]')&&(0,_utils.displayFilepicker)(editor,"h5p").then((params=>{if(""!==params.url){root.querySelector('form input[name="url"]').value=params.url}return params})).catch()}))}}));
//# sourceMappingURL=ui.min.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,68 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tiny H5P Content configuration.
*
* @module tiny_h5p/commands
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import {getButtonImage} from 'editor_tiny/utils';
import {handleAction} from './ui';
import {get_string as getString} from 'core/str';
import {
component,
buttonName,
icon,
} from './common';
export const getSetup = async() => {
const [
buttonText,
buttonImage,
] = await Promise.all([
getString('buttontitle', component),
getButtonImage('icon', component),
]);
return (editor) => {
// Register the H5P Icon.
editor.ui.registry.addIcon(icon, buttonImage.html);
// Register the Menu Button as a toggle.
// This means that when highlighted over an existing H5P element it will show as toggled on.
editor.ui.registry.addToggleButton(buttonName, {
icon,
tooltip: buttonText,
onAction: () => handleAction(editor),
onSetup: (api) => {
// Set the button to be active if the current selection matches the h5p formatter registered above during PreInit.
api.setActive(editor.formatter.match('h5p'));
const changed = editor.formatter.formatChanged('h5p', (state) => api.setActive(state));
return () => changed.unbind();
},
});
// Add the H5P Menu Item.
// This allows it to be added to a standard menu, or a context menu.
editor.ui.registry.addMenuItem(buttonName, {
icon,
text: buttonText,
onAction: () => handleAction(editor),
});
};
};
@@ -0,0 +1,29 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tiny H5P Common values.
*
* @module tiny_h5p/common
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
export default {
pluginName: 'tiny_h5p/plugin',
component: 'tiny_h5p',
buttonName: 'tiny_h5p',
icon: 'tiny_h5p',
};
@@ -0,0 +1,36 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tiny H5P Content configuration.
*
* @module tiny_h5p/configuration
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import {component as buttonName} from './common';
import {
addMenubarItem,
addToolbarButton,
} from 'editor_tiny/utils';
export const configure = (instanceConfig) => {
// Update the instance configuration to add the H5P menu option to the menus and toolbars.
return {
toolbar: addToolbarButton(instanceConfig.toolbar, 'content', buttonName),
menu: addMenubarItem(instanceConfig.menu, 'insert', buttonName),
};
};
@@ -0,0 +1,41 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tiny H5P Content configuration.
*
* @module tiny_h5p/filtercontent
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
export const setup = async(editor) => {
// Register the H5P Formatter for use in all buttons.
editor.on('PreInit', () => {
editor.formatter.register('h5p', {
inline: 'div',
classes: 'h5p-placeholder',
});
});
editor.on('SetContent', () => {
// 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) => {
node.contentEditable = false;
});
});
};
@@ -0,0 +1,44 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* H5P Management Modal for Tiny.
*
* @module tiny_h5p/modal
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import Modal from 'core/modal';
import ModalRegistry from 'core/modal_registry';
const H5PModal = class extends Modal {
static TYPE = 'tiny_h5p/modal';
static TEMPLATE = 'tiny_h5p/modal';
registerEventListeners() {
// Call the parent registration.
super.registerEventListeners();
// Register to close on save/cancel.
this.registerCloseOnSave();
this.registerCloseOnCancel();
}
};
ModalRegistry.register(H5PModal.TYPE, H5PModal, H5PModal.TEMPLATE);
export default H5PModal;
@@ -0,0 +1,52 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Options helper for Tiny H5P plugin.
*
* @module tiny_h5p/options
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import {getPluginOptionName} from 'editor_tiny/options';
import {pluginName} from './common';
const permissionsName = getPluginOptionName(pluginName, 'permissions');
/**
* Register the options for the Tiny H5P plugin.
*
* @param {TinyMCE} editor
*/
export const register = (editor) => {
const registerOption = editor.options.register;
registerOption(permissionsName, {
processor: 'object',
"default": {
upload: false,
embed: false,
},
});
};
/**
* Get the permissions configuration for the Tiny H5P plugin.
*
* @param {TinyMCE} editor
* @returns {object}
*/
export const getPermissions = (editor) => editor.options.get(permissionsName);
@@ -0,0 +1,61 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tiny H5P plugin for Moodle.
*
* @module tiny_h5p/plugin
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import {getTinyMCE} from 'editor_tiny/loader';
import {getPluginMetadata} from 'editor_tiny/utils';
import {component, pluginName} from './common';
import * as FilterContent from './filtercontent';
import * as Commands from './commands';
import * as Configuration from './configuration';
import * as Options from './options';
// Setup the H5P Plugin to add a button and menu option.
export default new Promise(async(resolve) => {
const [
tinyMCE,
setupCommands,
pluginMetadata,
] = await Promise.all([
getTinyMCE(),
Commands.getSetup(),
getPluginMetadata(component, pluginName),
]);
// Note: The PluginManager.add function does not accept a Promise.
// Any asynchronous code must be run before this point.
tinyMCE.PluginManager.add(`${component}/plugin`, (editor) => {
// Register options.
Options.register(editor);
// Setup the Formatter.
FilterContent.setup(editor);
// Setup the Commands (buttons, menu items, and so on).
setupCommands(editor);
return pluginMetadata;
});
// Resolve the H5P Plugin and include configuration.
resolve([`${component}/plugin`, Configuration]);
});
+198
View File
@@ -0,0 +1,198 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tiny H5P Content configuration.
*
* @module tiny_h5p/commands
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import {displayFilepicker} from 'editor_tiny/utils';
import {component} from './common';
import {getPermissions} from './options';
import {getList} from 'core/normalise';
import {renderForPromise} from 'core/templates';
import Modal from 'tiny_h5p/modal';
import ModalEvents from 'core/modal_events';
import ModalFactory from 'core/modal_factory';
let openingSelection = null;
export const handleAction = (editor) => {
openingSelection = editor.selection.getBookmark();
displayDialogue(editor);
};
/**
* Get the template context for the dialogue.
*
* @param {Editor} editor
* @param {object} data
* @returns {object} data
*/
const getTemplateContext = (editor, data) => {
const permissions = getPermissions(editor);
const canUpload = permissions.upload ?? false;
const canEmbed = permissions.embed ?? false;
const canUploadAndEmbed = canUpload && canEmbed;
return Object.assign({}, {
elementid: editor.id,
canUpload,
canEmbed,
canUploadAndEmbed,
showOptions: false,
fileURL: data?.url ?? '',
}, data);
};
/**
* Get the URL from the submitted form.
*
* @param {FormNode} form
* @param {string} submittedUrl
* @param {object} permissions
* @returns {URL|null}
*/
const getUrlFromSubmission = (form, submittedUrl, permissions) => {
if (!submittedUrl) {
return null;
}
// Generate a URL Object for the submitted URL.
const url = new URL(submittedUrl);
if (permissions?.upload) {
if (form.querySelector('[name="download"]').checked) {
url.searchParams.append('export', 1);
}
}
if (permissions?.embed) {
if (form.querySelector('[name="embed"]').checked) {
url.searchParams.append('embed', 1);
}
}
if (form.querySelector('[name="copyright"]').checked) {
url.searchParams.append('copyright', 1);
}
return url;
};
const handleDialogueSubmission = async(editor, modal, data) => {
const form = getList(modal.getRoot())[0].querySelector('form');
if (!form) {
// The form couldn't be found, which is weird.
// This should not happen.
// Display the dialogue again
displayDialogue(editor, Object.assign({}, data));
return;
}
// Get the URL from the submitted form.
const submittedUrl = form.querySelector('input[name="url"]').value;
const url = getUrlFromSubmission(form, submittedUrl, getPermissions(editor));
if (!url) {
// The URL is invalid.
// Fill it in and represent the dialogue with an error.
displayDialogue(editor, Object.assign({}, data, {
url: submittedUrl,
invalidUrl: true,
}));
return;
}
const content = await renderForPromise(`${component}/content`, {
url: url.toString(),
});
editor.selection.moveToBookmark(openingSelection);
editor.execCommand('mceInsertContent', false, content.html);
editor.selection.moveToBookmark(openingSelection);
};
const getCurrentH5PData = (currentH5P) => {
const data = {};
let url;
try {
url = new URL(currentH5P.textContent);
} catch (error) {
return data;
}
if (url.searchParams.has('export')) {
data.download = true;
data.showOptions = true;
url.searchParams.delete('export');
}
if (url.searchParams.has('embed')) {
data.embed = true;
data.showOptions = true;
url.searchParams.delete('embed');
}
if (url.searchParams.has('copyright')) {
data.copyright = true;
data.showOptions = true;
url.searchParams.delete('copyright');
}
data.url = url.toString();
return data;
};
const displayDialogue = async(editor, data = {}) => {
const selection = editor.selection.getNode();
const currentH5P = selection.closest('.h5p-placeholder');
if (currentH5P) {
Object.assign(data, getCurrentH5PData(currentH5P));
}
const modal = await ModalFactory.create({
type: Modal.TYPE,
templateContext: getTemplateContext(editor, data),
large: true,
});
modal.show();
const $root = modal.getRoot();
const root = $root[0];
$root.on(ModalEvents.save, (event, modal) => {
handleDialogueSubmission(editor, modal, data);
});
root.addEventListener('click', (e) => {
const filepickerButton = e.target.closest('[data-target="filepicker"]');
if (filepickerButton) {
displayFilepicker(editor, 'h5p').then((params) => {
if (params.url !== '') {
const input = root.querySelector('form input[name="url"]');
input.value = params.url;
}
return params;
})
.catch();
}
});
};
@@ -0,0 +1,76 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tiny_h5p;
use context;
use editor_tiny\plugin;
use editor_tiny\plugin_with_buttons;
use editor_tiny\plugin_with_menuitems;
use editor_tiny\plugin_with_configuration;
/**
* Tiny H5P plugin for Moodle.
*
* @package tiny_h5p
* @copyright 2021 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class plugininfo extends plugin implements
plugin_with_buttons,
plugin_with_menuitems,
plugin_with_configuration {
public static function is_enabled(
context $context,
array $options,
array $fpoptions,
?\editor_tiny\editor $editor = null
): bool {
// Users must have permission to embed content.
return has_capability('atto/h5p:addembed', $context);
}
public static function get_available_buttons(): array {
return [
'tiny_h5p/h5p',
];
}
public static function get_available_menuitems(): array {
return [
'tiny_h5p/h5p',
];
}
public static function get_plugin_configuration_for_context(
context $context,
array $options,
array $fpoptions,
?\editor_tiny\editor $editor = null
): array {
$permissions = [
'embed' => has_capability('tiny/h5p:addembed', $context),
'upload' => has_capability('moodle/h5p:deploy', $context),
];
$permissions['uploadandembed'] = $permissions['embed'] && $permissions['upload'];
return [
'permissions' => $permissions,
'storeinrepo' => true,
];
}
}
@@ -0,0 +1,30 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tiny_h5p\privacy;
/**
* Privacy Subsystem implementation for the H5P plugin for TinyMCE.
*
* @package tiny_h5p
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Capabilities for the tiny_h5p plugin.
*
* @package tiny_h5p
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = [
'tiny/h5p:addembed' => [
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => [
'editingteacher' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'atto/h5p:addembed',
]
];
@@ -0,0 +1,11 @@
.mce-content-body .h5p-placeholder + br {
display: none;
}
.mce-content-body .h5p-placeholder {
color: #6c757d;
width: 100%;
word-break: break-all;
height: 260px;
cursor: pointer;
background: url([[pix:tiny_h5p|icon-white]]) center center / 100px auto no-repeat #6c757d;
}
@@ -0,0 +1,42 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'tiny_h5p', language 'en'.
*
* @package tiny_h5p
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['helplinktext'] = 'Moodle H5P Helper';
$string['modaltitle'] = 'Insert H5P content';
$string['buttontitle'] = 'Configure H5P content';
$string['insert'] = 'Insert H5P content';
$string['pluginname'] = 'Tiny H5P plugin for Moodle';
$string['browserepositories'] = 'Browse repositories...';
$string['copyrightbutton'] = 'Copyright button';
$string['downloadbutton'] = 'Allow download';
$string['embedbutton'] = 'Embed button';
$string['h5p:addembed'] = 'Add embedded H5P';
$string['h5pfile'] = 'H5P file upload';
$string['h5pfileorurl'] = 'H5P URL or file upload';
$string['h5poptions'] = 'H5P options';
$string['h5purl'] = 'H5P URL';
$string['invalidh5purl'] = 'Invalid URL';
$string['instructions'] = 'You can insert H5P content by <strong>either</strong> entering a URL <strong>or</strong> by uploading an H5P file.';
$string['noh5pcontent'] = 'No H5P content added';
$string['privacy:metadata'] = 'The H5P plugin for TinyMCE does not store any personal data.';
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 345 150" style="enable-background:new 0 0 345 150;" xml:space="preserve" preserveAspectRatio="xMinYMid meet">
<style type="text/css">
.st0{fill:#FFFFFF;}
</style>
<g>
<path class="st0" d="M325.7,14.7C317.6,6.9,305.3,3,289,3h-43.5H234v31h-66l-5.4,22.2c4.5-2.1,10.9-4.2,15.3-5.3
c4.4-1.1,8.8-0.9,13.1-0.9c14.6,0,26.5,4.5,35.6,13.3c9.1,8.8,13.6,20,13.6,33.4c0,9.4-2.3,18.5-7,27.2s-11.3,15.4-19.9,20
c-3.1,1.6-6.5,3.1-10.2,4.1h42.4H259V95h25c18.2,0,31.7-4.2,40.6-12.5s13.3-19.9,13.3-34.6C337.9,33.6,333.8,22.5,325.7,14.7z
M288.7,60.6c-3.5,3-9.6,4.4-18.3,4.4H259V33h13.2c8.4,0,14.2,1.5,17.2,4.7c3.1,3.2,4.6,6.9,4.6,11.5
C294,53.9,292.2,57.6,288.7,60.6z"/>
<path class="st0" d="M176.5,76.3c-7.9,0-14.7,4.6-18,11.2L119,81.9L136.8,3h-23.6H101v62H51V3H7v145h44V95h50v53h12.2h42
c-6.7-2-12.5-4.6-17.2-8.1c-4.8-3.6-8.7-7.7-11.7-12.3c-3-4.6-5.3-9.7-7.3-16.5l39.6-5.7c3.3,6.6,10.1,11.1,17.9,11.1
c11.1,0,20.1-9,20.1-20.1S187.5,76.3,176.5,76.3z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 345 150" style="enable-background:new 0 0 345 150;" xml:space="preserve" preserveAspectRatio="xMinYMid meet">
<g>
<path d="M325.7,14.7C317.6,6.9,305.3,3,289,3h-43.5H234v31h-66l-5.4,22.2c4.5-2.1,10.9-4.2,15.3-5.3c4.4-1.1,8.8-0.9,13.1-0.9
c14.6,0,26.5,4.5,35.6,13.3c9.1,8.8,13.6,20,13.6,33.4c0,9.4-2.3,18.5-7,27.2s-11.3,15.4-19.9,20c-3.1,1.6-6.5,3.1-10.2,4.1h42.4
H259V95h25c18.2,0,31.7-4.2,40.6-12.5s13.3-19.9,13.3-34.6C337.9,33.6,333.8,22.5,325.7,14.7z M288.7,60.6c-3.5,3-9.6,4.4-18.3,4.4
H259V33h13.2c8.4,0,14.2,1.5,17.2,4.7c3.1,3.2,4.6,6.9,4.6,11.5C294,53.9,292.2,57.6,288.7,60.6z"/>
<path d="M176.5,76.3c-7.9,0-14.7,4.6-18,11.2L119,81.9L136.8,3h-23.6H101v62H51V3H7v145h44V95h50v53h12.2h42
c-6.7-2-12.5-4.6-17.2-8.1c-4.8-3.6-8.7-7.7-11.7-12.3c-3-4.6-5.3-9.7-7.3-16.5l39.6-5.7c3.3,6.6,10.1,11.1,17.9,11.1
c11.1,0,20.1-9,20.1-20.1S187.5,76.3,176.5,76.3z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,38 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template tiny_h5p/content
Templated used when inserting H5P Placeholder content into the text.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
Example context (json):
{
"url": "https://moodle.h5p.com/content/1290772960722742119"
}
}}
<div class="h5p-placeholder" contenteditable="false">
{{ url }}
</div>
@@ -0,0 +1,167 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template tiny_h5p/modal
Modal to manage an H5P activity within the Tiny Edigtor.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
Example context (json):
{
"elementid": "exampleId"
}
}}
{{< core/modal }}
{{$title}}
{{#str}} modaltitle, tiny_h5p {{/str}}
{{/title}}
{{$body}}
<form class="mform">
{{# noh5pcontent }}
<div role="alert" class="alert alert-warning mb-1">
{{#str}} noh5pcontent, tiny_h5p{{/str}}
</div>
{{/ noh5pcontent }}
{{# invalidUrl }}
<div role="alert" class="alert alert-warning mb-1">
{{#str}} invalidh5purl, tiny_h5p{{/str}}
</div>
{{/ invalidUrl }}
{{#canUploadAndEmbed}}
<div class="mt-2 mb-4">{{#str}} instructions, tiny_h5p{{/str}}</div>
{{/canUploadAndEmbed}}
<div class="mb-4">
<label for="{{elementid}}-{{uniqid}}-filepath">
{{#canUploadAndEmbed}}
{{#str}} h5pfileorurl, tiny_h5p{{/str}}
{{/canUploadAndEmbed}}
{{^canUploadAndEmbed}}
{{#canUpload}}
{{#str}} h5pfile, tiny_h5p{{/str}}
{{/canUpload}}
{{#canEmbed}}
{{#str}} h5purl, tiny_h5p{{/str}}
{{/canEmbed}}
{{/canUploadAndEmbed}}
</label>
<div class="input-group input-append w-100">
<input name="url" class="form-control" type="url" value="{{fileURL}}"{{!
}} id="{{elementid}}-{{uniqid}}-filepath"{{!
}} size="32"{{!
}} />
{{#canUpload}}
<span class="input-group-append">
<button class="btn btn-secondary" type="button" data-target="filepicker">
{{#str}} browserepositories, tiny_h5p{{/str}}</button>
</span>
{{/canUpload}}
</div>
{{#canUpload}}
<fieldset class="mt-2 collapsible" id="{{elementid}}-{{uniqid}}-options">
<legend class="d-flex align-items-center px-1">
<div class="position-relative d-flex ftoggler align-items-center position-relative mr-1">
<a role="button" data-toggle="collapse"{{!
}} href="#h5poptions"{{!
}} aria-expanded="{{#showOptions}}true{{/showOptions}}{{^showOptions}}false{{/showOptions}}"{{!
}} aria-controls="h5poptions"{{!
}} class="btn btn-icon mr-1 icons-collapse-expand stretched-link fheader {{^showOptions}}collapsed{{/showOptions}}"{{!
}}>
<span class="expanded-icon icon-no-margin p-2"
title="{{#str}} collapse, moodle {{/str}}">
<i class="icon fa fa-chevron-down fa-fw " aria-hidden="true"></i>
</span>
<span class="collapsed-icon icon-no-margin p-2"
title="{{#str}} expand, moodle {{/str}}">
<span class="dir-rtl-hide">
<i class="icon fa fa-chevron-right fa-fw " aria-hidden="true"></i>
</span>
<span class="dir-ltr-hide">
<i class="icon fa fa-chevron-left fa-fw " aria-hidden="true"></i>
</span>
</span>
<span class="sr-only">{{#str}} h5poptions, tiny_h5p{{/str}}</span>
</a>
<h3 class="d-flex align-self-stretch align-items-center mb-0" aria-hidden="true">
{{#str}} h5poptions, tiny_h5p{{/str}}
</h3>
</div>
</legend>
<div id="h5poptions" class="fcontainer collapseable collapse px-1 {{#showOptions}}show{{/showOptions}}">
<div class="form-check">
<input type="checkbox" {{!
}} name="download"{{!
}} {{# download }}checked{{/ download }}{{!
}} class="form-check-input"{{!
}} aria-label="{{#str}} downloadbutton, tiny_h5p{{/str}}"{{!
}} id="{{elementid}}-{{uniqid}}_h5p-option-allow-download"{{!
}} />
<label class="form-check-label" for="{{elementid}}-{{uniqid}}_h5p-option-allow-download">
{{#str}} downloadbutton, tiny_h5p{{/str}}
</label>
</div>
<div class="form-check">
<input type="checkbox"{{!
}} name="embed"{{!
}} {{# embed }}checked{{/ embed }}{{!
}} class="form-check-input"{{!
}} aria-label="{{#str}} embedbutton, tiny_h5p{{/str}}"{{!
}} id="{{elementid}}-{{uniqid}}_h5p-option-embed-button"{{!
}} />
<label class="form-check-label" for="{{elementid}}-{{uniqid}}_h5p-option-embed-button">
{{#str}} embedbutton, tiny_h5p{{/str}}
</label>
</div>
<div class="form-check mb-2">
<input type="checkbox"{{!
}} name="copyright"{{!
}} {{# copyright }}checked{{/ copyright }}{{!
}} class="form-check-input"{{!
}} aria-label="{{#str}} copyrightbutton, tiny_h5p{{/str}}"{{!
}} id="{{elementid}}-{{uniqid}}_h5p-option-copyright-button" {{!
}}/>
<label class="form-check-label" for="{{elementid}}-{{uniqid}}_h5p-option-copyright-button">
{{#str}} copyrightbutton, tiny_h5p{{/str}}
</label>
</div>
</div>
</fieldset>
{{/canUpload}}
</div>
</form>
{{/body}}
{{$footer}}
<button type="button" class="btn btn-secondary" data-action="cancel">{{#str}} cancel, moodle {{/str}}</button>
<button type="button" class="btn btn-primary" data-action="save">{{#str}} insert, tiny_h5p{{/str}}</button>
{{/footer}}
{{/ core/modal }}
+29
View File
@@ -0,0 +1,29 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tiny text editor H5P Plugin version file.
*
* @package tiny_h5p
* @copyright 2022 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2022101700;
$plugin->requires = 2020061500;
$plugin->component = 'tiny_h5p';