Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/tinymce single/block ui #183

Merged
merged 3 commits into from
Mar 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions tinymce-single/tinymce/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
tinymce.each( blockToolbars, function( toolbar ) {
toolbar.hide();
} );

DOM.setStyles( blockOutline, {
display: 'none'
} );
}

function focusToolbar( toolbar ) {
Expand Down Expand Up @@ -484,23 +488,17 @@
insert = false;
} );

function getBlockSelection( selection ) {
selection = selection || window.getSelection();

if ( selection.anchorNode.compareDocumentPosition( selection.focusNode ) & Node.DOCUMENT_POSITION_FOLLOWING ) {
var startNode = selection.anchorNode;
var endNode = selection.focusNode;
} else {
var startNode = selection.focusNode;
var endNode = selection.anchorNode;
}
function getBlockSelection() {
var startNode = editor.selection.getStart();
var endNode = editor.selection.getEnd();
var rootNode = editor.getBody();

var $start = editor.$( editor.dom.getParent( startNode, function( element ) {
return element.parentNode === editor.getBody();
return element.parentNode === rootNode;
} ) );

var $end = editor.$( editor.dom.getParent( endNode, function( element ) {
return element.parentNode === editor.getBody();
return element.parentNode === rootNode;
} ) );

return $start.add( $start.nextUntil( $end ) ).add( $end );
Expand Down Expand Up @@ -550,6 +548,7 @@
var endRect = selectedBlocks.last()[0].getBoundingClientRect();

DOM.setStyles( blockOutline, {
display: 'block',
position: 'absolute',
left: Math.min( startRect.left, endRect.left ) + 'px',
top: startRect.top + window.pageYOffset + 'px',
Expand Down Expand Up @@ -641,6 +640,12 @@

editor.on( 'keyup', function( event ) {
if ( metaCount === 1 ) {
var selection = window.getSelection();

if ( selection.isCollapsed && isEmptySlot( selection.anchorNode, true ) ) {
return;
}

showBlockUI( true );
}

Expand Down