- Timestamp:
- 04/19/2016 11:23:05 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.5/src/wp-includes/js/tinymce/themes/modern/theme.js
r37000 r37253 392 392 } 393 393 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 394 441 function reposition(match) { 395 442 var relPos, panelRect, elementRect, contentAreaRect, panel, relRect, testPositions; … … 405 452 406 453 testPositions = [ 407 ' tc-bc', 'bc-tc',454 'bc-tc', 'tc-bc', 408 455 'tl-bl', 'bl-tl', 409 456 'tr-br', 'br-tr' … … 432 479 433 480 relPos = Rect.findBestRelativePosition(panelRect, elementRect, contentAreaRect, testPositions); 481 elementRect = Rect.clamp(elementRect, contentAreaRect); 434 482 435 483 if (relPos) { 436 each(testPositions.concat('inside'), function(pos) {437 panel.classes.toggle('tinymce-inline-' + pos, pos == relPos);438 });439 440 484 relRect = Rect.relativePosition(panelRect, elementRect, relPos); 441 panel.moveTo(relRect.x, relRect.y);485 movePanelTo(panel, userConstrain(relRect.x, relRect.y, elementRect, contentAreaRect, panelRect)); 442 486 } 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; 448 489 449 490 elementRect = Rect.intersect(contentAreaRect, elementRect); 450 451 491 if (elementRect) { 452 492 relPos = Rect.findBestRelativePosition(panelRect, elementRect, contentAreaRect, [ 453 ' tc-tc', 'tl-tl', 'tr-tr'493 'bc-tc', 'bl-tl', 'br-tr' 454 494 ]); 455 495 456 496 if (relPos) { 457 497 relRect = Rect.relativePosition(panelRect, elementRect, relPos); 458 panel.moveTo(relRect.x, relRect.y);498 movePanelTo(panel, userConstrain(relRect.x, relRect.y, elementRect, contentAreaRect, panelRect)); 459 499 } else { 460 panel.moveTo(elementRect.x, elementRect.y);500 movePanelTo(panel, userConstrain(elementRect.x, elementRect.y, elementRect, contentAreaRect, panelRect)); 461 501 } 462 502 } else { … … 464 504 } 465 505 } 506 507 togglePositionClass(panel, relPos, function(pos1, pos2) { 508 return (!elementRect || elementRect.w > 40) && pos1 === pos2; 509 }); 466 510 467 511 //drawRect(contentAreaRect, 'blue'); … … 504 548 panel = Factory.create({ 505 549 type: 'floatpanel', 506 role: 'application', 507 classes: 'tinymce tinymce-inline', 550 role: 'dialog', 551 classes: 'tinymce tinymce-inline arrow', 552 ariaLabel: 'Inline toolbar', 508 553 layout: 'flex', 509 554 direction: 'column', … … 513 558 fixed: true, 514 559 border: 1, 515 items: createToolbar(match.toolbar.items) 560 items: createToolbar(match.toolbar.items), 561 oncancel: function() { 562 editor.focus(); 563 } 516 564 }); 517 565 … … 587 635 588 636 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 } 589 644 }); 590 645 }
Note: See TracChangeset
for help on using the changeset viewer.