From c4c195018707b96ec15b68cc76f4abd3f83d5c71 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 2 Mar 2017 11:44:56 -0500 Subject: [PATCH] Revert "Single TinyMCE: Drop window element global" --- shared/tinymce/toolbar.js | 3 +-- tinymce-single/tinymce/block.js | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/shared/tinymce/toolbar.js b/shared/tinymce/toolbar.js index 6b4a4c94b92b5..53a9b0f6837b9 100644 --- a/shared/tinymce/toolbar.js +++ b/shared/tinymce/toolbar.js @@ -75,8 +75,7 @@ function onClick( callback ) { return function() { editor.undoManager.transact( function() { - var element = editor.selection.getSelectedBlocks()[ 0 ]; - callback( editor, element ); + callback( editor, window.element ); } ); } } diff --git a/tinymce-single/tinymce/block.js b/tinymce-single/tinymce/block.js index 494dfd3284c73..713122b6f949b 100644 --- a/tinymce-single/tinymce/block.js +++ b/tinymce-single/tinymce/block.js @@ -4,8 +4,8 @@ // Set focussed block. Global variable for now. Top-level node for now. - editor.on( 'nodechange', function() { - element = editor.selection.getSelectedBlocks()[ 0 ]; + editor.on( 'nodechange', function( event ) { + element = window.element = event.parents[ event.parents.length - 1 ]; } ); // Global controls