Skip to content

Commit

Permalink
Merge pull request #202 from WordPress/try/tinymce-single/full-bleed
Browse files Browse the repository at this point in the history
Move inserter on the block outline. See #72.
  • Loading branch information
ellatrix authored Mar 7, 2017
2 parents 88f1177 + 35a75d2 commit a0bc319
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
13 changes: 9 additions & 4 deletions tinymce-single/tinymce/block.css
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,14 @@ div.mce-inline-toolbar-grp.block-toolbar > div.mce-stack-layout {
.block-outline:before {
content: '';
position: absolute;
top: -12px;
right: -12px;
bottom: -12px;
left: -12px;
top: -10px;
right: -10px;
bottom: -10px;
left: -10px;
border: 2px solid #e0e5e9;
}

.insert-toolbar svg {
background: #fff;
border-radius: 12px;
}
18 changes: 9 additions & 9 deletions tinymce-single/tinymce/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,28 +226,28 @@

var toolbar = this.getEl();
var block = getSelectedBlock();
var isRightAligned = editor.$( block ).hasClass( 'alignright' );
var isFullBleed = editor.$( block ).hasClass( 'alignfull' );
var toolbarRect = toolbar.getBoundingClientRect();
var blockRect = block.getBoundingClientRect();
var contentRect = editor.getBody().getBoundingClientRect();

if ( isRightAligned ) {
var left = contentRect.right - toolbarRect.width - 50;
} else {
var left = contentRect.left + 50
}

if ( settings.isEmpty ) {
DOM.setStyles( toolbar, {
position: 'absolute',
left: left + 'px',
left: contentRect.left + 50 + 'px',
top: blockRect.top + 3 + window.pageYOffset + 'px'
} );
} else {
if ( isFullBleed ) {
var left = contentRect.left + 50;
} else {
var left = blockRect.left - 6;
}

DOM.setStyles( toolbar, {
position: 'absolute',
left: left + 'px',
top: blockRect.top + Math.max( blockRect.height, 48 ) - 1 + window.pageYOffset + 'px'
top: blockRect.bottom - 3 + window.pageYOffset + 'px'
} );
}

Expand Down

0 comments on commit a0bc319

Please sign in to comment.