Make WordPress Core


Ignore:
Timestamp:
10/23/2014 02:07:15 AM (10 years ago)
Author:
azaozz
Message:

TinyMCE: update to 4.1.6+. Adds support for cache-busting when auto-loading JS and CSS. Change the tests to run in /build. Changelog: https://github.com/tinymce/tinymce/blob/master/changelog.txt.
Fixes #30079

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/paste/plugin.js

    r29570 r29994  
    346346            }
    347347
     348            /**
     349             * Returns the rect of the current caret if the caret is in an empty block before a
     350             * BR we insert a temporary invisible character that we get the rect this way we always get a proper rect.
     351             *
     352             * TODO: This might be useful in core.
     353             */
     354            function getCaretRect(rng) {
     355                var rects, textNode, node, container = rng.startContainer;
     356
     357                rects = rng.getClientRects();
     358                if (rects.length) {
     359                    return rects[0];
     360                }
     361
     362                if (!rng.collapsed || container.nodeType != 1) {
     363                    return;
     364                }
     365
     366                node = container.childNodes[lastRng.startOffset];
     367
     368                // Skip empty whitespace nodes
     369                while (node && node.nodeType == 3 && !node.data.length) {
     370                    node = node.nextSibling;
     371                }
     372
     373                if (!node) {
     374                    return;
     375                }
     376
     377                // Check if the location is |<br>
     378                // TODO: Might need to expand this to say |<table>
     379                if (node.tagName == 'BR') {
     380                    textNode = dom.doc.createTextNode('\uFEFF');
     381                    node.parentNode.insertBefore(textNode, node);
     382
     383                    rng = dom.createRng();
     384                    rng.setStartBefore(textNode);
     385                    rng.setEndAfter(textNode);
     386
     387                    rects = rng.getClientRects();
     388                    dom.remove(textNode);
     389                }
     390
     391                if (rects.length) {
     392                    return rects[0];
     393                }
     394            }
     395
    348396            // Calculate top cordinate this is needed to avoid scrolling to top of document
    349397            // We want the paste bin to be as close to the caret as possible to avoid scrolling
    350398            if (lastRng.getClientRects) {
    351                 var rects = lastRng.getClientRects();
    352 
    353                 if (rects.length) {
     399                var rect = getCaretRect(lastRng);
     400
     401                if (rect) {
    354402                    // Client rects gets us closes to the actual
    355403                    // caret location in for example a wrapped paragraph block
    356                     top = scrollTop + (rects[0].top - dom.getPos(body).y);
     404                    top = scrollTop + (rect.top - dom.getPos(body).y);
    357405                } else {
    358406                    top = scrollTop;
     
    532580
    533581        /**
    534          * Chrome on Andoid doesn't support proper clipboard access so we have no choice but to allow the browser default behavior.
     582         * Chrome on Android doesn't support proper clipboard access so we have no choice but to allow the browser default behavior.
    535583         *
    536584         * @param {Event} e Paste event object to check if it contains any data.
    537585         * @return {Boolean} true/false if the clipboard is empty or not.
    538586         */
    539         function isBrokenAndoidClipboardEvent(e) {
     587        function isBrokenAndroidClipboardEvent(e) {
    540588            var clipboardData = e.clipboardData;
    541589
     
    631679                keyboardPastePlainTextState = false;
    632680
    633                 if (e.isDefaultPrevented() || isBrokenAndoidClipboardEvent(e)) {
     681                if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) {
    634682                    removePasteBin();
    635683                    return;
     
    9851033                }
    9861034
    987                 var paragraphs = node.getAll('p');
    988 
    989                 for (var i = 0; i < paragraphs.length; i++) {
    990                     node = paragraphs[i];
     1035                // Build a list of all root level elements before we start
     1036                // altering them in the loop below.
     1037                var elements = [], child = node.firstChild;
     1038                while (typeof child !== 'undefined' && child !== null) {
     1039                    elements.push(child);
     1040
     1041                    child = child.walk();
     1042                    if (child !== null) {
     1043                        while (typeof child !== 'undefined' && child.parent !== node) {
     1044                            child = child.walk();
     1045                        }
     1046                    }
     1047                }
     1048
     1049                for (var i = 0; i < elements.length; i++) {
     1050                    node = elements[i];
    9911051
    9921052                    if (node.name == 'p' && node.firstChild) {
     
    10031063                        if (isNumericList(nodeText)) {
    10041064                            // Parse OL start number
    1005                             var matches = /([0-9])\./.exec(nodeText);
     1065                            var matches = /([0-9]+)\./.exec(nodeText);
    10061066                            var start = 1;
    10071067                            if (matches) {
     
    10191079                        }
    10201080
     1081                        currentListNode = null;
     1082                    } else {
     1083                        // If the root level element isn't a p tag which can be
     1084                        // processed by convertParagraphToLi, it interrupts the
     1085                        // lists, causing a new list to start instead of having
     1086                        // elements from the next list inserted above this tag.
     1087                        prevListNode = currentListNode;
    10211088                        currentListNode = null;
    10221089                    }
     
    11531220                var validElements = settings.paste_word_valid_elements;
    11541221                if (!validElements) {
    1155                     validElements = '-strong/b,-em/i,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-p/div,' +
    1156                         '-table[width],-tr,-td[colspan|rowspan|width],-th,-thead,-tfoot,-tbody,-a[href|name],sub,sup,strike,br,del';
     1222                    validElements = (
     1223                        '-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' +
     1224                        '-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,' +
     1225                        'td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody'
     1226                    );
    11571227                }
    11581228
Note: See TracChangeset for help on using the changeset viewer.