TinyMCE, inline link:

- Fix running wpLink without tinymce.js and the TinyMCE plugin without wplink.js.
- Do not show the Advanced button in the inline link dialog when wpLink is not loaded.

See #33301.
Built from https://develop.svn.wordpress.org/trunk@36777


git-svn-id: http://core.svn.wordpress.org/trunk@36744 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2016-02-29 19:38:27 +00:00
parent 53493af312
commit b8d5769726
6 changed files with 25 additions and 23 deletions

View File

@ -144,11 +144,16 @@
'wp_link_remove' 'wp_link_remove'
], true ); ], true );
editToolbar = editor.wp._createToolbar( [ var editButtons = [
'wp_link_input', 'wp_link_input',
'wp_link_apply', 'wp_link_apply'
'wp_link_advanced' ];
], true );
if ( typeof window.wpLink !== 'undefined' ) {
editButtons.push( 'wp_link_advanced' );
}
editToolbar = editor.wp._createToolbar( editButtons, true );
editToolbar.on( 'show', function() { editToolbar.on( 'show', function() {
if ( ! tinymce.$( document.body ).hasClass( 'modal-open' ) ) { if ( ! tinymce.$( document.body ).hasClass( 'modal-open' ) ) {
@ -177,11 +182,8 @@
} ); } );
editor.addCommand( 'WP_Link', function() { editor.addCommand( 'WP_Link', function() {
if ( tinymce.Env.ie && tinymce.Env.ie < 10 ) { if ( tinymce.Env.ie && tinymce.Env.ie < 10 && typeof window.wpLink !== 'undefined' ) {
if ( typeof window.wpLink !== 'undefined' ) { window.wpLink.open( editor.id );
window.wpLink.open( editor.id );
}
return; return;
} }

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
/* global tinymce, wpLinkL10n, wpActiveEditor */
var wpLink; var wpLink;
( function( $ ) { ( function( $, wpLinkL10n ) {
var editor, correctedURL, linkNode, var editor, correctedURL, linkNode,
inputs = {}, inputs = {},
isTouch = ( 'ontouchend' in document ); isTouch = ( 'ontouchend' in document );
@ -80,7 +80,7 @@ var wpLink;
select: function( event, ui ) { select: function( event, ui ) {
$input.val( ui.item.permalink ); $input.val( ui.item.permalink );
if ( inputs.wrap.hasClass( 'has-text-field' ) && tinymce.trim( inputs.text.val() ) === '' ) { if ( inputs.wrap.hasClass( 'has-text-field' ) && $.trim( inputs.text.val() ) === '' ) {
inputs.text.val( ui.item.title ); inputs.text.val( ui.item.title );
} }
@ -144,12 +144,12 @@ var wpLink;
this.textarea = $( '#' + window.wpActiveEditor ).get( 0 ); this.textarea = $( '#' + window.wpActiveEditor ).get( 0 );
if ( typeof tinymce !== 'undefined' ) { if ( typeof window.tinymce !== 'undefined' ) {
// Make sure the link wrapper is the last element in the body, // Make sure the link wrapper is the last element in the body,
// or the inline editor toolbar may show above the backdrop. // or the inline editor toolbar may show above the backdrop.
$body.append( inputs.backdrop, inputs.wrap ); $body.append( inputs.backdrop, inputs.wrap );
ed = tinymce.get( wpActiveEditor ); ed = window.tinymce.get( window.wpActiveEditor );
if ( ed && ! ed.isHidden() ) { if ( ed && ! ed.isHidden() ) {
editor = ed; editor = ed;
@ -157,7 +157,7 @@ var wpLink;
editor = null; editor = null;
} }
if ( editor && tinymce.isIE && ! editor.windowManager.wplinkBookmark ) { if ( editor && window.tinymce.isIE && ! editor.windowManager.wplinkBookmark ) {
editor.windowManager.wplinkBookmark = editor.selection.getBookmark(); editor.windowManager.wplinkBookmark = editor.selection.getBookmark();
} }
} }
@ -236,7 +236,7 @@ var wpLink;
for ( i = nodes.length - 1; i >= 0; i-- ) { for ( i = nodes.length - 1; i >= 0; i-- ) {
node = nodes[i]; node = nodes[i];
if ( node.nodeType != 3 && ! tinymce.dom.BookmarkManager.isBookmarkNode( node ) ) { if ( node.nodeType != 3 && ! window.tinymce.dom.BookmarkManager.isBookmarkNode( node ) ) {
return false; return false;
} }
} }
@ -253,7 +253,7 @@ var wpLink;
if ( linkNode ) { if ( linkNode ) {
linkText = linkNode.innerText || linkNode.textContent; linkText = linkNode.innerText || linkNode.textContent;
if ( ! tinymce.trim( linkText ) ) { if ( ! $.trim( linkText ) ) {
linkText = text || ''; linkText = text || '';
} }
@ -397,7 +397,7 @@ var wpLink;
editor.focus(); editor.focus();
if ( tinymce.isIE && editor.windowManager.wplinkBookmark ) { if ( window.tinymce.isIE && editor.windowManager.wplinkBookmark ) {
editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark ); editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
editor.windowManager.wplinkBookmark = null; editor.windowManager.wplinkBookmark = null;
} }
@ -474,7 +474,7 @@ var wpLink;
} }
} }
selection = tinymce.trim( selection ); selection = $.trim( selection );
if ( selection && emailRegexp.test( selection ) ) { if ( selection && emailRegexp.test( selection ) ) {
// Selection is email address // Selection is email address
@ -496,4 +496,4 @@ var wpLink;
}; };
$( document ).ready( wpLink.init ); $( document ).ready( wpLink.init );
})( jQuery ); })( jQuery, window.wpLinkL10n );

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.5-beta1-36776'; $wp_version = '4.5-beta1-36777';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.