Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 43... Línea 43...
43
    const configuration = getFilePicker(editor, filetype);
43
    const configuration = getFilePicker(editor, filetype);
44
    if (configuration) {
44
    if (configuration) {
45
        const options = {
45
        const options = {
46
            ...configuration,
46
            ...configuration,
47
            formcallback: resolve,
47
            formcallback: resolve,
-
 
48
            previousActiveElement: document.activeElement,
48
        };
49
        };
49
        M.core_filepicker.show(Y, options);
50
        M.core_filepicker.show(Y, options);
50
        return;
51
        return;
51
    }
52
    }
52
    reject(`Unknown filetype ${filetype}`);
53
    reject(`Unknown filetype ${filetype}`);
Línea 196... Línea 197...
196
 * @param {string} contextmenu
197
 * @param {string} contextmenu
197
 * @param {string[]} menuitems
198
 * @param {string[]} menuitems
198
 * @returns {string}
199
 * @returns {string}
199
 */
200
 */
200
export const addContextmenuItem = (contextmenu, ...menuitems) => {
201
export const addContextmenuItem = (contextmenu, ...menuitems) => {
201
    const contextmenuItems = (contextmenu ?? '').split(' ');
202
    const contextmenuItems = (contextmenu || '').split(' ');
Línea 202... Línea 203...
202
 
203
 
203
    return contextmenuItems
204
    return contextmenuItems
204
        .concat(menuitems)
205
        .concat(menuitems)
205
        .filter((item) => item !== '')
206
        .filter((item) => item !== '')
Línea 212... Línea 213...
212
 * @param {string} quicktoolbar
213
 * @param {string} quicktoolbar
213
 * @param {string[]} toolbaritems
214
 * @param {string[]} toolbaritems
214
 * @returns {string}
215
 * @returns {string}
215
 */
216
 */
216
export const addQuickbarsToolbarItem = (quicktoolbar, ...toolbaritems) => {
217
export const addQuickbarsToolbarItem = (quicktoolbar, ...toolbaritems) => {
217
    const quicktoolbarItems = (quicktoolbar ?? '').split(' ');
218
    const quicktoolbarItems = (quicktoolbar || '').split(' ');
Línea 218... Línea 219...
218
 
219
 
219
    return quicktoolbarItems
220
    return quicktoolbarItems
220
        .concat(toolbaritems)
221
        .concat(toolbaritems)
221
        .filter((item) => item !== '')
222
        .filter((item) => item !== '')
222
        .join(' ');
223
        .join(' ');
Línea 223... Línea 224...
223
};
224
};
-
 
225
 
-
 
226
/**
-
 
227
 * This function will calculate and add items to toolbar with below logic:
-
 
228
 * 1. If the number of the items is larger than one, it will add all the items to a menu button.
-
 
229
 * 2. If the number of the items is one, it will add the item directly to the toolbar.
-
 
230
 *
-
 
231
 * @param {TinyMCE} editor
-
 
232
 * @param {Array} items
-
 
233
 * @param {String} menuName
-
 
234
 * @param {String} menuIcon
-
 
235
 * @param {String} menuIconText
-
 
236
 * @param {String} singleIcon
-
 
237
 * @param {String} singleIconText
-
 
238
 * @param {String} singleAction
-
 
239
 */
-
 
240
export const addDynamicToolbarMenu = (editor, items, menuName, menuIcon,
-
 
241
        menuIconText, singleIcon, singleIconText, singleAction) => {
-
 
242
    if (items.length > 1) {
-
 
243
        // Use context menu.
-
 
244
        editor.ui.registry.addMenuButton(menuName, {
-
 
245
            icon: menuIcon,
-
 
246
            tooltip: menuIconText,
-
 
247
            fetch: callback => callback(`${items.join(' ')}`),
-
 
248
        });
-
 
249
    } else {
-
 
250
        // Use single button.
-
 
251
        editor.ui.registry.addButton(menuName, {
-
 
252
            icon: singleIcon,
-
 
253
            tooltip: singleIconText,
-
 
254
            onAction: singleAction,
-
 
255
        });
-
 
256
    }
-
 
257
};
224
 
258
 
225
/**
259
/**
226
 * Get the link to the user documentation for the named plugin.
260
 * Get the link to the user documentation for the named plugin.
227
 *
261
 *
228
 * @param {string} pluginName
262
 * @param {string} pluginName
Línea 238... Línea 272...
238
 * @param {string} pluginName The plugin name
272
 * @param {string} pluginName The plugin name
239
 * @param {string|null} [url=null] An optional URL to the plugin documentation
273
 * @param {string|null} [url=null] An optional URL to the plugin documentation
240
 * @returns {object}
274
 * @returns {object}
241
 */
275
 */
242
export const getPluginMetadata = async(component, pluginName, url = null) => {
276
export const getPluginMetadata = async(component, pluginName, url = null) => {
243
    const name = await getString('helplinktext', component);
277
    const name = await getString('pluginname', component);
244
    return {
278
    return {
245
        getMetadata: () => ({
279
        getMetadata: () => ({
246
            name,
280
            name,
247
            url: url ?? getDocumentationLink(pluginName),
281
            url: url ?? getDocumentationLink(pluginName),
248
        }),
282
        }),