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 - https://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 <https://www.gnu.org/licenses/>.\n\n/**\n * Tiny tiny_aiplacement for Moodle.\n *\n * @module      tiny_aiplacement/configuration\n * @copyright   2024 Matt Porritt <matt.porritt@moodle.com>\n * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {\n    contextMenuName,\n    generateImageName,\n    generateTextName\n} from './common';\nimport {\n    addMenubarItem,\n} from 'editor_tiny/utils';\n\nconst configureMenu = (menu) => {\n    const items = menu.insert.items.split(' ');\n    const inserted = items.some((item, index) => {\n        // Append after the media or video button.\n        if (item.match(/(media)\\b/)) {\n            items.splice(index + 1, 0, generateImageName, generateTextName);\n            return true;\n        }\n\n        return false;\n    });\n\n    if (inserted) {\n        menu.insert.items = items.join(' ');\n    } else {\n        addMenubarItem(menu, 'insert', `${generateImageName} ${generateTextName}`);\n    }\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            const inserted = section.items.some((item, index) => {\n                // Append after the media or video button.\n                if (item.match(/(media)\\b/)) {\n                    section.items.splice(index + 1, 0, contextMenuName, generateImageName, generateTextName);\n                    return true;\n                }\n                return false;\n            });\n\n            if (!inserted) {\n                section.items.unshift(contextMenuName, generateImageName, generateTextName);\n            }\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        toolbar: configureToolbar(instanceConfig.toolbar),\n        menu: configureMenu(instanceConfig.menu),\n    };\n};\n"],"names":["configureMenu","menu","items","insert","split","some","item","index","match","splice","generateImageName","generateTextName","join","instanceConfig","toolbar","map","section","name","contextMenuName","unshift"],"mappings":";;;;;;;;MAgCMA,cAAiBC,aACbC,MAAQD,KAAKE,OAAOD,MAAME,MAAM,YACrBF,MAAMG,MAAK,CAACC,KAAMC,UAE3BD,KAAKE,MAAM,eACXN,MAAMO,OAAOF,MAAQ,EAAG,EAAGG,0BAAmBC,2BACvC,KAOXV,KAAKE,OAAOD,MAAQA,MAAMU,KAAK,+BAEhBX,KAAM,mBAAaS,sCAAqBC,2BAGpDV,yBA2BeY,uBAEf,CACHC,SA3BkBA,QA2BQD,eAAeC,QAvBtCA,QAAQC,KAAKC,UACK,YAAjBA,QAAQC,OACSD,QAAQd,MAAMG,MAAK,CAACC,KAAMC,UAEnCD,KAAKE,MAAM,eACXQ,QAAQd,MAAMO,OAAOF,MAAQ,EAAG,EAAGW,wBAAiBR,0BAAmBC,2BAChE,MAMXK,QAAQd,MAAMiB,QAAQD,wBAAiBR,0BAAmBC,2BAI3DK,YAQPf,KAAMD,cAAca,eAAeZ,OA5BjBa,IAAAA"}