Drag and drop files on the editor to upload: add new argument to wp_editor() to enable, fixes #27465
Built from https://develop.svn.wordpress.org/trunk@27901 git-svn-id: http://core.svn.wordpress.org/trunk@27732 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
08770f6b88
commit
668235fb42
|
@ -479,6 +479,7 @@ if ( post_type_supports($post_type, 'editor') ) {
|
|||
|
||||
<?php wp_editor( $post->post_content, 'content', array(
|
||||
'dfw' => true,
|
||||
'drag_drop_upload' => true,
|
||||
'tabfocus_elements' => 'insert-media-button,save-post',
|
||||
'editor_height' => 360,
|
||||
'tinymce' => array(
|
||||
|
|
|
@ -24,6 +24,7 @@ final class _WP_Editors {
|
|||
private static $has_quicktags = false;
|
||||
private static $has_medialib = false;
|
||||
private static $editor_buttons_css = true;
|
||||
private static $drag_drop_upload = false;
|
||||
|
||||
private function __construct() {}
|
||||
|
||||
|
@ -38,6 +39,8 @@ final class _WP_Editors {
|
|||
* @type bool $media_buttons Whether to show the Add Media/other media buttons.
|
||||
* @type string $default_editor When both TinyMCE and Quicktags are used, set which
|
||||
* editor is shown on page load. Default empty.
|
||||
* @type bool $drag_drop_upload Whether to enable drag & drop on the editor uploading. Default false.
|
||||
* Requires the media modal.
|
||||
* @type string $textarea_name Give the textarea a unique name here. Square brackets
|
||||
* can be used here. Default $editor_id.
|
||||
* @type int $textarea_rows Number rows in the editor textarea. Default 20.
|
||||
|
@ -63,6 +66,7 @@ final class _WP_Editors {
|
|||
'wpautop' => true,
|
||||
'media_buttons' => true,
|
||||
'default_editor' => '',
|
||||
'drag_drop_upload' => false,
|
||||
'textarea_name' => $editor_id,
|
||||
'textarea_rows' => 20,
|
||||
'tabindex' => '',
|
||||
|
@ -124,6 +128,10 @@ final class _WP_Editors {
|
|||
$switch_class = 'html-active';
|
||||
$toolbar = $buttons = $autocomplete = '';
|
||||
|
||||
if ( $set['drag_drop_upload'] ) {
|
||||
self::$drag_drop_upload = true;
|
||||
}
|
||||
|
||||
if ( ! empty( $set['editor_height'] ) )
|
||||
$height = ' style="height: ' . $set['editor_height'] . 'px"';
|
||||
else
|
||||
|
@ -980,6 +988,13 @@ final class _WP_Editors {
|
|||
tinyMCEPreInit = {
|
||||
baseURL: "<?php echo self::$baseurl; ?>",
|
||||
suffix: "<?php echo $suffix; ?>",
|
||||
<?php
|
||||
|
||||
if ( self::$drag_drop_upload ) {
|
||||
echo 'dragDropUpload: true,';
|
||||
}
|
||||
|
||||
?>
|
||||
mceInit: <?php echo $mceInit; ?>,
|
||||
qtInit: <?php echo $qtInit; ?>,
|
||||
ref: <?php echo self::_parse_init( $ref ); ?>,
|
||||
|
|
|
@ -3131,8 +3131,8 @@
|
|||
|
||||
this.initialized = false;
|
||||
|
||||
// Bail if UA does not support drag'n'drop or File API.
|
||||
if ( ! this.browserSupport() ) {
|
||||
// Bail if not enabled or UA does not support drag'n'drop or File API.
|
||||
if ( ! window.tinyMCEPreInit || ! window.tinyMCEPreInit.dragDropUpload || ! this.browserSupport() ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -311,12 +311,14 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
|||
window.jQuery( document ).triggerHandler( 'tinymce-editor-init', [editor] );
|
||||
}
|
||||
|
||||
dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
|
||||
if ( typeof window.jQuery !== 'undefined' ) {
|
||||
// Trigger the jQuery handlers.
|
||||
window.jQuery( document ).triggerHandler( event.type );
|
||||
}
|
||||
});
|
||||
if ( window.tinyMCEPreInit && window.tinyMCEPreInit.dragDropUpload ) {
|
||||
dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
|
||||
if ( typeof window.jQuery !== 'undefined' ) {
|
||||
// Trigger the jQuery handlers.
|
||||
window.jQuery( document ).triggerHandler( event.type );
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Word count
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in New Issue