TinyMCE, inline link:
- Fix applying the changes when pressing the Enter key in Firefox. No longer inserts new paragraph in the editor. - Fix empty check when getting text from the dialog. - Always focus the URL field when opening the dialog. - Add back the keydown events in the modal. See #33301. git-svn-id: https://develop.svn.wordpress.org/trunk@36743 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
be3ba15eec
commit
d8c52aba85
|
@ -68,7 +68,13 @@
|
||||||
return tinymce.trim( this.getEl().firstChild.value );
|
return tinymce.trim( this.getEl().firstChild.value );
|
||||||
},
|
},
|
||||||
getLinkText: function() {
|
getLinkText: function() {
|
||||||
return tinymce.trim( this.getEl().firstChild.nextSibling.value );
|
var text = this.getEl().firstChild.nextSibling.value;
|
||||||
|
|
||||||
|
if ( ! tinymce.trim( text ) ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return text.replace( /[\r\n\t ]+/g, ' ' );
|
||||||
},
|
},
|
||||||
reset: function() {
|
reset: function() {
|
||||||
var urlInput = this.getEl().firstChild;
|
var urlInput = this.getEl().firstChild;
|
||||||
|
@ -144,12 +150,15 @@
|
||||||
], true );
|
], true );
|
||||||
|
|
||||||
editToolbar.on( 'show', function() {
|
editToolbar.on( 'show', function() {
|
||||||
var inputNode = editToolbar.find( 'toolbar' )[0];
|
if ( ! tinymce.$( document.body ).hasClass( 'modal-open' ) ) {
|
||||||
|
|
||||||
if ( inputNode && ! tinymce.$( document.body ).hasClass( 'modal-open' ) ) {
|
|
||||||
window.setTimeout( function() {
|
window.setTimeout( function() {
|
||||||
inputNode.focus( true );
|
var element = editToolbar.$el.find( 'input.ui-autocomplete-input' )[0];
|
||||||
});
|
|
||||||
|
if ( element ) {
|
||||||
|
element.focus();
|
||||||
|
element.select();
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -172,6 +181,8 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editToolbar.tempHide = false;
|
||||||
|
|
||||||
if ( link ) {
|
if ( link ) {
|
||||||
editor.dom.setAttribs( link, { 'data-wplink-edit': true } );
|
editor.dom.setAttribs( link, { 'data-wplink-edit': true } );
|
||||||
} else {
|
} else {
|
||||||
|
@ -181,6 +192,8 @@
|
||||||
if ( tinymce.Env.ie ) {
|
if ( tinymce.Env.ie ) {
|
||||||
editor.windowManager.wplinkBookmark = editor.selection.getBookmark();
|
editor.windowManager.wplinkBookmark = editor.selection.getBookmark();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editor.nodeChanged();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -227,12 +240,12 @@
|
||||||
inputInstance.reset();
|
inputInstance.reset();
|
||||||
removePlaceholders();
|
removePlaceholders();
|
||||||
editor.focus();
|
editor.focus();
|
||||||
|
|
||||||
if ( tinymce.isIE ) {
|
if ( tinymce.isIE ) {
|
||||||
editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
|
editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
|
||||||
editor.windowManager.wplinkBookmark = null;
|
editor.windowManager.wplinkBookmark = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
editToolbar.tempHide = false;
|
editToolbar.tempHide = false;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
@ -384,6 +397,7 @@
|
||||||
tinymce.$( input ).on( 'keydown', function( event ) {
|
tinymce.$( input ).on( 'keydown', function( event ) {
|
||||||
if ( event.keyCode === 13 ) {
|
if ( event.keyCode === 13 ) {
|
||||||
editor.execCommand( 'wp_link_apply' );
|
editor.execCommand( 'wp_link_apply' );
|
||||||
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ var wpLink;
|
||||||
wpLink.setAutocomplete();
|
wpLink.setAutocomplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
inputs.submit.click( function( event ) {
|
inputs.dialog.on( 'keydown', wpLink.keydown );
|
||||||
|
inputs.submit.on( 'click', function( event ) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
wpLink.update();
|
wpLink.update();
|
||||||
});
|
});
|
||||||
|
@ -210,7 +211,7 @@ var wpLink;
|
||||||
// IE will show a flashing cursor over the dialog.
|
// IE will show a flashing cursor over the dialog.
|
||||||
window.setTimeout( function() {
|
window.setTimeout( function() {
|
||||||
inputs.url.focus()[0].select();
|
inputs.url.focus()[0].select();
|
||||||
}, 100 );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
correctedURL = inputs.url.val().replace( /^http:\/\//, '' );
|
correctedURL = inputs.url.val().replace( /^http:\/\//, '' );
|
||||||
|
@ -431,6 +432,29 @@ var wpLink;
|
||||||
editor.nodeChanged();
|
editor.nodeChanged();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
keydown: function( event ) {
|
||||||
|
var id;
|
||||||
|
|
||||||
|
// Escape key.
|
||||||
|
if ( 27 === event.keyCode ) {
|
||||||
|
wpLink.close();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
// Tab key.
|
||||||
|
} else if ( 9 === event.keyCode ) {
|
||||||
|
id = event.target.id;
|
||||||
|
|
||||||
|
// wp-link-submit must always be the last focusable element in the dialog.
|
||||||
|
// following focusable elements will be skipped on keyboard navigation.
|
||||||
|
if ( id === 'wp-link-submit' && ! event.shiftKey ) {
|
||||||
|
inputs.close.focus();
|
||||||
|
event.preventDefault();
|
||||||
|
} else if ( id === 'wp-link-close' && event.shiftKey ) {
|
||||||
|
inputs.submit.focus();
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
setDefaultValues: function() {
|
setDefaultValues: function() {
|
||||||
var selection,
|
var selection,
|
||||||
emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
|
emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
|
||||||
|
|
Loading…
Reference in New Issue