Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 84... Línea 84...
84
 * @param {String} url URL the link will point to.
84
 * @param {String} url URL the link will point to.
85
 */
85
 */
86
const setLinkOnSelection = async(currentForm, editor, url) => {
86
const setLinkOnSelection = async(currentForm, editor, url) => {
87
    const urlText = currentForm.querySelector(Selectors.elements.urlText);
87
    const urlText = currentForm.querySelector(Selectors.elements.urlText);
88
    const target = currentForm.querySelector(Selectors.elements.openInNewWindow);
88
    const target = currentForm.querySelector(Selectors.elements.openInNewWindow);
-
 
89
    const selectedNode = editor.selection.getNode();
-
 
90
    const isImage = selectedNode && selectedNode.nodeName.toLowerCase() === 'img';
89
    let textToDisplay = urlText.value.replace(/(<([^>]+)>)/gi, "").trim();
91
    let textToDisplay = urlText.value.replace(/(<([^>]+)>)/gi, "").trim();
Línea 90... Línea 92...
90
 
92
 
91
    if (textToDisplay === '') {
93
    if (textToDisplay === '') {
92
        textToDisplay = url;
94
        textToDisplay = url;
Línea 93... Línea 95...
93
    }
95
    }
94
 
96
 
95
    const context = {
97
    const context = {
96
        url: url,
98
        url: url,
97
        newwindow: target.checked,
99
        newwindow: target.checked,
98
    };
100
    };
99
    if (urlText.getAttribute('data-link-on-element')) {
101
    if (urlText.getAttribute('data-link-on-element') || isImage) {
100
        context.title = textToDisplay;
102
        context.title = textToDisplay;
101
        context.name = editor.selection.getNode().outerHTML;
103
        context.name = selectedNode.outerHTML;
102
    } else {
104
    } else {
103
        context.name = textToDisplay;
105
        context.name = textToDisplay;
104
    }
106
    }