From 5ebcd105dadb66aa35f227f62605af06ffffc5e5 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 2 Mar 2017 11:00:09 -0500 Subject: [PATCH] Assign element by TinyMCE selection API --- shared/tinymce/toolbar.js | 3 ++- tinymce-single/tinymce/block.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/shared/tinymce/toolbar.js b/shared/tinymce/toolbar.js index 53a9b0f6837b92..6b4a4c94b92b54 100644 --- a/shared/tinymce/toolbar.js +++ b/shared/tinymce/toolbar.js @@ -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 ); } ); } } diff --git a/tinymce-single/tinymce/block.js b/tinymce-single/tinymce/block.js index 713122b6f949b5..494dfd3284c73b 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( event ) { - element = window.element = event.parents[ event.parents.length - 1 ]; + editor.on( 'nodechange', function() { + element = editor.selection.getSelectedBlocks()[ 0 ]; } ); // Global controls