Skip to content

Commit

Permalink
Move inline toolbar next to block toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Mar 1, 2017
1 parent 7e6d178 commit f687176
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions tinymce-single/tinymce/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,25 +217,20 @@
blockToolbar.$el.addClass( 'block-toolbar' );

var range;
var blockToolbarWidth = 0;

toolbarInline.reposition = function () {
if ( ! range ) {
if ( ! element ) {
return;
}

var toolbar = this.getEl();
var toolbarRect = toolbar.getBoundingClientRect();
var elementRect = range.getClientRects();

if ( ! elementRect.length ) {
return;
}

elementRect = elementRect[0];
var elementRect = element.getBoundingClientRect();

DOM.setStyles( toolbar, {
position: 'absolute',
left: elementRect.left + 'px',
left: elementRect.left + 8 + blockToolbarWidth + 'px',
top: elementRect.top + window.pageYOffset - toolbarRect.height - 8 + 'px'
} );

Expand Down Expand Up @@ -366,6 +361,8 @@
top: elementRect.top + window.pageYOffset - toolbarRect.height - 8 + 'px'
} );

blockToolbarWidth = toolbarRect.width;

this.show();
}

Expand Down Expand Up @@ -487,26 +484,16 @@
} else {
toolbarCaret.hide();

if ( ! isCollapsed && anchorNode.nodeType === 3 ) {
hidden = true;
hideBlockUI();

if ( anchorNode.parentNode.nodeName === 'A' ) {
toolbarInline.hide();
} else {
range = document.createRange();
range.setStart( selection.anchorNode, selection.anchorOffset );
range.setEnd( selection.anchorNode, selection.anchorOffset );
toolbarInline.reposition();
}
if ( anchorNode.nodeType === 3 ) {
toolbarInline.reposition();
} else {
toolbarInline.hide();
}

if ( isBlockUIVisible ) {
showBlockUI();
} else {
hideBlockUI();
}
if ( isBlockUIVisible ) {
showBlockUI();
} else {
hideBlockUI();
}
}
} );
Expand Down

0 comments on commit f687176

Please sign in to comment.