Skip to content

Commit

Permalink
Assign element by TinyMCE selection API
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Mar 2, 2017
1 parent b942bb4 commit 5ebcd10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion shared/tinymce/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
function onClick( callback ) {
return function() {
editor.undoManager.transact( function() {
callback( editor, window.element );
var element = editor.selection.getSelectedBlocks()[ 0 ];
callback( editor, element );
} );
}
}
Expand Down
4 changes: 2 additions & 2 deletions tinymce-single/tinymce/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

// Set focussed block. Global variable for now. Top-level node for now.

editor.on( 'nodechange', function( event ) {
element = window.element = event.parents[ event.parents.length - 1 ];
editor.on( 'nodechange', function() {
element = editor.selection.getSelectedBlocks()[ 0 ];
} );

// Global controls
Expand Down

0 comments on commit 5ebcd10

Please sign in to comment.