Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"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 <andrew@nicols.co.uk>\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 {getString} from 'core/str';\nimport {\n    component,\n    buttonName,\n    icon,\n} from './common';\nimport {hasAnyH5PPermission} from './options';\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        if (!hasAnyH5PPermission(editor)) {\n            return;\n        }\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":"4PAiCwBA,gBAEhBC,WACAC,mBACMC,QAAQC,IAAI,EAClB,kBAAU,cAAeC,oBACzB,yBAAe,OAAQA,4BAGnBC,UACC,gCAAoBA,UAIzBA,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"}