/** * PluginsTab.js * * Released under LGPL License. * Copyright (c) 1999-2017 Ephox Corp. All rights reserved * * License: http://www.tinymce.com/license * Contributing: http://www.tinymce.com/contributing */ import { Arr, Fun, Obj, Strings } from '@ephox/katamari'; import I18n from 'tinymce/core/api/util/I18n'; import PluginUrls from '../data/PluginUrls'; const makeLink = Fun.curry(Strings.supplant, '${name}'); const maybeUrlize = function (editor, key) { return Arr.find(PluginUrls.urls, function (x) { return x.key === key; }).fold(function () { const getMetadata = editor.plugins[key].getMetadata; return typeof getMetadata === 'function' ? makeLink(getMetadata()) : key; }, function (x) { return makeLink({ name: x.name, url: 'https://www.tinymce.com/docs/plugins/' + x.key }); }); }; const getPluginKeys = function (editor) { const keys = Obj.keys(editor.plugins); return editor.settings.forced_plugins === undefined ? keys : Arr.filter(keys, Fun.not(Fun.curry(Arr.contains, editor.settings.forced_plugins))); }; const pluginLister = function (editor) { const pluginKeys = getPluginKeys(editor); const pluginLis = Arr.map(pluginKeys, function (key) { return '
  • ' + maybeUrlize(editor, key) + '
  • '; }); const count = pluginLis.length; const pluginsString = pluginLis.join(''); return '

    ' + I18n.translate(['Plugins installed ({0}):', count ]) + '

    ' + ''; }; const installedPlugins = function (editor) { return { type: 'container', html: '
    ' + pluginLister(editor) + '
    ', flex: 1 }; }; const availablePlugins = function () { return { type: 'container', html: '
    ' + '

    ' + I18n.translate('Premium plugins:') + '

    ' + '
    ' + '

    ' + I18n.translate('Learn more...') + '

    ' + '
    ', flex: 1 }; }; const makeTab = function (editor) { return { title: 'Plugins', type: 'container', style: 'overflow-y: auto; overflow-x: hidden;', layout: 'flex', padding: 10, spacing: 10, items: [ installedPlugins(editor), availablePlugins() ] }; }; export default { makeTab };