Proyectos de Subversion Moodle

Rev

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

{"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 Media configuration.\n *\n * @module      tiny_media/configuration\n * @copyright   2022 Huong Nguyen <huongnv13@gmail.com>\n * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {\n    imageButtonName,\n    videoButtonName,\n    mediaManagerButtonName,\n} from './common';\nimport uploadFile from 'editor_tiny/uploader';\nimport {\n    addContextmenuItem,\n} from 'editor_tiny/utils';\n\nconst configureMenu = (menu) => {\n    // Replace the standard Media plugin with the Moodle embed.\n    if (menu.insert.items.match(/\\bmedia\\b/)) {\n        menu.insert.items = menu.insert.items.replace(/\\bmedia\\b/, videoButtonName);\n    } else {\n        menu.insert.items = `${videoButtonName} ${menu.insert.items}`;\n    }\n\n    // Replace the standard image plugin with the Moodle image.\n    if (menu.insert.items.match(/\\bimage\\b/)) {\n        menu.insert.items = menu.insert.items.replace(/\\bimage\\b/, imageButtonName);\n    } else {\n        menu.insert.items = `${imageButtonName} ${menu.insert.items}`;\n    }\n\n    // Add the Media Manager to the end of the Tools menu.\n    menu.tools.items += ` ${mediaManagerButtonName}`;\n\n    return menu;\n};\n\nconst configureToolbar = (toolbar) => {\n    // The toolbar contains an array of named sections.\n    // The Moodle integration ensures that there is a section called 'content'.\n\n    return toolbar.map((section) => {\n        if (section.name === 'content') {\n            // Insert the image, and embed, buttons at the start of it.\n            section.items.unshift(imageButtonName, videoButtonName);\n        }\n\n        return section;\n    });\n};\n\nexport const configure = (instanceConfig) => {\n    // Update the instance configuration to add the Media menu option to the menus and toolbars and upload_handler.\n    return {\n        contextmenu: addContextmenuItem(instanceConfig.contextmenu, imageButtonName, videoButtonName),\n        menu: configureMenu(instanceConfig.menu),\n        toolbar: configureToolbar(instanceConfig.toolbar),\n\n        // eslint-disable-next-line camelcase\n        images_upload_handler: (blobInfo, progress) => uploadFile(\n            window.tinymce.activeEditor,\n            'image',\n            blobInfo.blob(),\n            blobInfo.filename(),\n            progress\n        ),\n\n        // eslint-disable-next-line camelcase\n        images_reuse_filename: true,\n    };\n};\n"],"names":["instanceConfig","contextmenu","imageButtonName","videoButtonName","menu","insert","items","match","replace","tools","mediaManagerButtonName","toolbar","map","section","name","unshift","images_upload_handler","blobInfo","progress","window","tinymce","activeEditor","blob","filename","images_reuse_filename"],"mappings":";;;;;;;sKAoE0BA,uBAEf,CACHC,aAAa,6BAAmBD,eAAeC,YAAaC,wBAAiBC,yBAC7EC,MAvCeA,KAuCKJ,eAAeI,KArCnCA,KAAKC,OAAOC,MAAMC,MAAM,aACxBH,KAAKC,OAAOC,MAAQF,KAAKC,OAAOC,MAAME,QAAQ,YAAaL,yBAE3DC,KAAKC,OAAOC,gBAAWH,oCAAmBC,KAAKC,OAAOC,OAItDF,KAAKC,OAAOC,MAAMC,MAAM,aACxBH,KAAKC,OAAOC,MAAQF,KAAKC,OAAOC,MAAME,QAAQ,YAAaN,yBAE3DE,KAAKC,OAAOC,gBAAWJ,oCAAmBE,KAAKC,OAAOC,OAI1DF,KAAKK,MAAMH,kBAAaI,gCAEjBN,MAsBHO,SAnBkBA,QAmBQX,eAAeW,QAftCA,QAAQC,KAAKC,UACK,YAAjBA,QAAQC,MAERD,QAAQP,MAAMS,QAAQb,wBAAiBC,yBAGpCU,YAYPG,sBAAuB,CAACC,SAAUC,YAAa,qBAC3CC,OAAOC,QAAQC,aACf,QACAJ,SAASK,OACTL,SAASM,WACTL,UAIJM,uBAAuB,GA/BLb,IAAAA,QArBHP"}