Text widget: add the Add Media button and enable the `wpview` plugin to show embedded media previews in the editor.

Props westonruter, azaozz.
See #40854.
Built from https://develop.svn.wordpress.org/trunk@41344


git-svn-id: http://core.svn.wordpress.org/trunk@41177 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2017-09-08 10:57:43 +00:00
parent 8cfe233137
commit ffa304135e
5 changed files with 43 additions and 6 deletions

View File

@ -562,18 +562,42 @@ window.wp = window.wp || {};
// Add wrap and the Visual|Text tabs.
if ( settings.tinymce && settings.quicktags ) {
var $textarea = $( '#' + id );
var $wrap = $( '<div>' ).attr( {
'class': 'wp-core-ui wp-editor-wrap tmce-active',
id: 'wp-' + id + '-wrap'
} );
var $editorContainer = $( '<div class="wp-editor-container">' );
var $button = $( '<button>' ).attr( {
type: 'button',
'data-wp-editor-id': id
} );
var $editorTools = $( '<div class="wp-editor-tools">' );
if ( settings.mediaButtons ) {
var buttonText = 'Add Media';
if ( window._wpMediaViewsL10n && window._wpMediaViewsL10n.addMedia ) {
buttonText = window._wpMediaViewsL10n.addMedia;
}
var $addMediaButton = $( '<button type="button" class="button insert-media add_media">' );
$addMediaButton.append( '<span class="wp-media-buttons-icon"></span>' );
$addMediaButton.append( document.createTextNode( ' ' + buttonText ) );
$addMediaButton.data( 'editor', id );
$editorTools.append(
$( '<div class="wp-media-buttons">' )
.append( $addMediaButton )
);
}
$wrap.append(
$( '<div class="wp-editor-tools">' )
$editorTools
.append( $( '<div class="wp-editor-tabs">' )
.append( $button.clone().attr({
id: id + '-tmce',

File diff suppressed because one or more lines are too long

View File

@ -230,7 +230,8 @@ wp.textWidgets = ( function( $ ) {
// The user has disabled TinyMCE.
if ( typeof window.tinymce === 'undefined' ) {
wp.editor.initialize( id, {
quicktags: true
quicktags: true,
mediaButtons: true
});
return;
@ -242,11 +243,23 @@ wp.textWidgets = ( function( $ ) {
wp.editor.remove( id );
}
// Add or enable the `wpview` plugin.
$( document ).one( 'wp-before-tinymce-init.text-widget-init', function( event, init ) {
// If somebody has removed all plugins, they must have a good reason.
// Keep it that way.
if ( ! init.plugins ) {
return;
} else if ( ! /\bwpview\b/.test( init.plugins ) ) {
init.plugins += ',wpview';
}
} );
wp.editor.initialize( id, {
tinymce: {
wpautop: true
},
quicktags: true
quicktags: true,
mediaButtons: true
});
/**

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41343';
$wp_version = '4.9-alpha-41344';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.