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 Premium configuration.\n *\n * @module      tiny_premium/configuration\n * @copyright   2023 David Woloszyn <david.woloszyn@moodle.com>\n * @license     https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {\n    addToolbarButton,\n    addMenubarItem,\n    addToolbarSection,\n    addContextmenuItem\n} from 'editor_tiny/utils';\nimport {\n    getInitialPluginConfiguration,\n    getPluginOptionName\n} from 'editor_tiny/options';\n\nconst configureToolbar = (toolbar) => {\n    // Add premium toolbar sections to house all the plugins with no natural home.\n    toolbar = addToolbarSection(toolbar, 'premium_a', 'advanced', true);\n    toolbar = addToolbarSection(toolbar, 'premium_b', 'formatting', true);\n    return toolbar;\n};\n\nexport const configure = (instanceConfig, options) => {\n    // Get the namespaced options for Tiny Premium before they are officially initialised.\n    // Due to the timing the plugin options are available, we need to get at the options in this slightly unconventional way.\n    const pluginOptions = getInitialPluginConfiguration(options);\n    const enabledPremiumPlugins = pluginOptions[getPluginOptionName('tiny_premium/plugin', 'premiumplugins')].split(',');\n\n    let plugins = instanceConfig.plugins;\n    let menu = instanceConfig.menu;\n    let toolbar = configureToolbar(instanceConfig.toolbar);\n    let contextmenu = instanceConfig.contextmenu;\n    let pluginsettings = {};\n\n    // Advanced Table.\n    if (enabledPremiumPlugins.indexOf('advtable') !== -1) {\n        plugins += ` advtable`;\n        menu = addMenubarItem(menu, 'table', '| advtablerownumbering', 'advtablesort');\n    }\n    // Enhanced Image Editing.\n    if (enabledPremiumPlugins.indexOf('editimage') !== -1) {\n        plugins += ` editimage`;\n        toolbar = addToolbarButton(toolbar, 'content', 'editimage', 'tiny_media_image');\n        // Remove the duplicate image button from the quickbar toolbar by redefining the values without 'imageoptions'.\n        // eslint-disable-next-line camelcase\n        instanceConfig.editimage_toolbar = 'rotateleft rotateright flipv fliph editimage';\n    }\n    // Export.\n    if (enabledPremiumPlugins.indexOf('export') !== -1) {\n        plugins += ` export`;\n        menu = addMenubarItem(menu, 'tools', '| export');\n    }\n    // Page Embed.\n    if (enabledPremiumPlugins.indexOf('pageembed') !== -1) {\n        plugins += ` pageembed`;\n        toolbar = addToolbarButton(toolbar, 'content', 'pageembed', 'tiny_media_video');\n    }\n    // Advanced Typography.\n    if (enabledPremiumPlugins.indexOf('typography') !== -1) {\n        plugins += ` typography`;\n        toolbar = addToolbarButton(toolbar, 'premium_b', 'typography');\n    }\n    // Case Change.\n    if (enabledPremiumPlugins.indexOf('casechange') !== -1) {\n        plugins += ` casechange`;\n        toolbar = addToolbarButton(toolbar, 'premium_a', 'casechange');\n    }\n    // Checklist.\n    if (enabledPremiumPlugins.indexOf('checklist') !== -1) {\n        plugins += ` checklist`;\n        toolbar = addToolbarButton(toolbar, 'lists', 'checklist');\n    }\n    // Spell Checker Pro.\n    if (enabledPremiumPlugins.indexOf('tinymcespellchecker') !== -1) {\n        plugins += ` tinymcespellchecker`;\n        menu = addMenubarItem(menu, 'tools', 'spellcheckdialog', 'spellcheckerlanguage');\n        contextmenu = addContextmenuItem(contextmenu, 'spellchecker');\n        toolbar = addToolbarButton(toolbar, 'premium_a', 'spellcheckdialog');\n    }\n    // Spelling Autocorrect.\n    if (enabledPremiumPlugins.indexOf('autocorrect') !== -1) {\n        plugins += ` autocorrect`;\n        menu = addMenubarItem(menu, 'tools', '| autocorrect capitalization', 'spellcheckdialog');\n    }\n    // Permanent Pen.\n    if (enabledPremiumPlugins.indexOf('permanentpen') !== -1) {\n        plugins += ` permanentpen`;\n        menu = addMenubarItem(menu, 'format', '| permanentpen configurepermanentpen');\n        toolbar = addToolbarButton(toolbar, 'premium_a', 'permanentpen');\n        contextmenu = addContextmenuItem(contextmenu, 'configurepermanentpen');\n    }\n    // Format Painter.\n    if (enabledPremiumPlugins.indexOf('formatpainter') !== -1) {\n        plugins += ` formatpainter`;\n        toolbar = addToolbarButton(toolbar, 'premium_a', 'formatpainter');\n    }\n    // Link Checker.\n    if (enabledPremiumPlugins.indexOf('linkchecker') !== -1) {\n        plugins += ` linkchecker`;\n        contextmenu = addContextmenuItem(contextmenu, 'linkchecker');\n    }\n    // Table of Contents.\n    if (enabledPremiumPlugins.indexOf('tableofcontents') !== -1) {\n        plugins += ` tableofcontents`;\n        toolbar = addToolbarButton(toolbar, 'premium_a', 'tableofcontents');\n    }\n    // Footnotes.\n    if (enabledPremiumPlugins.indexOf('footnotes') !== -1) {\n        plugins += ` footnotes`;\n        toolbar = addToolbarButton(toolbar, 'premium_a', 'footnotes');\n        menu = addMenubarItem(menu, 'insert', 'footnotes', 'tableofcontents');\n    }\n    // Powerpaste.\n    if (enabledPremiumPlugins.indexOf('powerpaste') !== -1) {\n        plugins += ` powerpaste`;\n    }\n\n    return {\n        plugins,\n        toolbar,\n        menu,\n        contextmenu,\n        ...pluginsettings\n    };\n};\n"],"names":["instanceConfig","options","enabledPremiumPlugins","split","plugins","menu","toolbar","configureToolbar","contextmenu","indexOf","editimage_toolbar"],"mappings":"mOAyCyB,CAACA,eAAgBC,iBAIhCC,uBADgB,0CAA8BD,UACR,gCAAoB,sBAAuB,mBAAmBE,MAAM,SAE5GC,QAAUJ,eAAeI,QACzBC,KAAOL,eAAeK,KACtBC,QAfkBA,CAAAA,UAEtBA,SAAU,4BAAkBA,QAAS,YAAa,YAAY,IACpD,4BAAkBA,QAAS,YAAa,cAAc,IAYlDC,CAAiBP,eAAeM,SAC1CE,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