+ editor.addButton( 'wp_view_edit', {
+ tooltip: 'Edit ', // trailing space is needed, used for context
+ icon: 'dashicon dashicons-edit',
+ onclick: function() {
+ selected && wp.mce.views.edit( editor, selected );
+ }
+ } );
+
+ editor.addButton( 'wp_view_remove', {
+ tooltip: 'Remove',
+ icon: 'dashicon dashicons-no',
+ onclick: function() {
+ selected && removeView( selected );
+ }
+ } );
+
+ editor.once( 'preinit', function() {
+ toolbar = editor.wp._createToolbar( [
+ 'wp_view_edit',
+ 'wp_view_remove'
+ ] );
+ } );
+
+ editor.on( 'wptoolbar', function( event ) {
+ if ( selected ) {
+ event.element = selected;
+ event.toolbar = toolbar;
+ }
+ } );
+
+ // Add to editor.wp
+ editor.wp = editor.wp || {};
+ editor.wp.getView = getView;
+
+ // Keep for back-compat.