Make WordPress Core


Ignore:
Timestamp:
04/19/2016 11:23:05 PM (8 years ago)
Author:
azaozz
Message:

TinyMCE:

https://github.com/tinymce/tinymce/commit/5462e3c1ddcc014bcf6d599239465287f1b9bbe3.

Merges [37242] and [37251] to the 4.5 branch.
Fixes #36545 for 4.5.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.5/src/wp-includes/js/tinymce/themes/modern/theme.js

    r37000 r37253  
    392392        }
    393393
     394        function togglePositionClass(panel, relPos, predicate) {
     395            relPos = relPos ? relPos.substr(0, 2) : '';
     396
     397            each({
     398                t: 'down',
     399                b: 'up'
     400            }, function(cls, pos) {
     401                panel.classes.toggle('arrow-' + cls, predicate(pos, relPos.substr(0, 1)));
     402            });
     403
     404            each({
     405                l: 'left',
     406                r: 'right'
     407            }, function(cls, pos) {
     408                panel.classes.toggle('arrow-' + cls, predicate(pos, relPos.substr(1, 1)));
     409            });
     410        }
     411
     412        function toClientRect(geomRect) {
     413            return {
     414                left: geomRect.x,
     415                top: geomRect.y,
     416                width: geomRect.w,
     417                height: geomRect.h,
     418                right: geomRect.x + geomRect.w,
     419                bottom: geomRect.y + geomRect.h
     420            };
     421        }
     422
     423        function userConstrain(x, y, elementRect, contentAreaRect, panelRect) {
     424                panelRect = toClientRect({x: x, y: y, w: panelRect.w, h: panelRect.h});
     425
     426                if (settings.inline_toolbar_position_handler) {
     427                    panelRect = settings.inline_toolbar_position_handler({
     428                        elementRect: toClientRect(elementRect),
     429                        contentAreaRect: toClientRect(contentAreaRect),
     430                        panelRect: panelRect
     431                    });
     432                }
     433
     434                return panelRect;
     435        }
     436
     437        function movePanelTo(panel, pos) {
     438            panel.moveTo(pos.left, pos.top);
     439        }
     440
    394441        function reposition(match) {
    395442            var relPos, panelRect, elementRect, contentAreaRect, panel, relRect, testPositions;
     
    405452
    406453            testPositions = [
    407                 'tc-bc', 'bc-tc',
     454                'bc-tc', 'tc-bc',
    408455                'tl-bl', 'bl-tl',
    409456                'tr-br', 'br-tr'
     
    432479
    433480            relPos = Rect.findBestRelativePosition(panelRect, elementRect, contentAreaRect, testPositions);
     481            elementRect = Rect.clamp(elementRect, contentAreaRect);
    434482
    435483            if (relPos) {
    436                 each(testPositions.concat('inside'), function(pos) {
    437                     panel.classes.toggle('tinymce-inline-' + pos, pos == relPos);
    438                 });
    439 
    440484                relRect = Rect.relativePosition(panelRect, elementRect, relPos);
    441                 panel.moveTo(relRect.x, relRect.y);
     485                movePanelTo(panel, userConstrain(relRect.x, relRect.y, elementRect, contentAreaRect, panelRect));
    442486            } else {
    443                 each(testPositions, function(pos) {
    444                     panel.classes.toggle('tinymce-inline-' + pos, false);
    445                 });
    446 
    447                 panel.classes.toggle('tinymce-inline-inside', true);
     487                // Allow overflow below the editor to avoid placing toolbars ontop of tables
     488                contentAreaRect.h += 40;
    448489
    449490                elementRect = Rect.intersect(contentAreaRect, elementRect);
    450 
    451491                if (elementRect) {
    452492                    relPos = Rect.findBestRelativePosition(panelRect, elementRect, contentAreaRect, [
    453                         'tc-tc', 'tl-tl', 'tr-tr'
     493                        'bc-tc', 'bl-tl', 'br-tr'
    454494                    ]);
    455495
    456496                    if (relPos) {
    457497                        relRect = Rect.relativePosition(panelRect, elementRect, relPos);
    458                         panel.moveTo(relRect.x, relRect.y);
     498                        movePanelTo(panel, userConstrain(relRect.x, relRect.y, elementRect, contentAreaRect, panelRect));
    459499                    } else {
    460                         panel.moveTo(elementRect.x, elementRect.y);
     500                        movePanelTo(panel, userConstrain(elementRect.x, elementRect.y, elementRect, contentAreaRect, panelRect));
    461501                    }
    462502                } else {
     
    464504                }
    465505            }
     506
     507            togglePositionClass(panel, relPos, function(pos1, pos2) {
     508                return (!elementRect || elementRect.w > 40) && pos1 === pos2;
     509            });
    466510
    467511            //drawRect(contentAreaRect, 'blue');
     
    504548            panel = Factory.create({
    505549                type: 'floatpanel',
    506                 role: 'application',
    507                 classes: 'tinymce tinymce-inline',
     550                role: 'dialog',
     551                classes: 'tinymce tinymce-inline arrow',
     552                ariaLabel: 'Inline toolbar',
    508553                layout: 'flex',
    509554                direction: 'column',
     
    513558                fixed: true,
    514559                border: 1,
    515                 items: createToolbar(match.toolbar.items)
     560                items: createToolbar(match.toolbar.items),
     561                oncancel: function() {
     562                    editor.focus();
     563                }
    516564            });
    517565
     
    587635
    588636            editor.contextToolbars = {};
     637        });
     638
     639        editor.shortcuts.add('ctrl+shift+e > ctrl+shift+p', '', function() {
     640            var match = findFrontMostMatch(editor.selection.getNode());
     641            if (match && match.toolbar.panel) {
     642                match.toolbar.panel.items()[0].focus();
     643            }
    589644        });
    590645    }
Note: See TracChangeset for help on using the changeset viewer.