Press This: prevent pasting of HTML in the title H2. Insert the clipboard text instead.
Fixes #31768. Built from https://develop.svn.wordpress.org/trunk@31987 git-svn-id: http://core.svn.wordpress.org/trunk@31966 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c691addc73
commit
b98ba09e5b
|
@ -529,12 +529,45 @@
|
||||||
}
|
}
|
||||||
}).on( 'keyup', function() {
|
}).on( 'keyup', function() {
|
||||||
saveAlert = true;
|
saveAlert = true;
|
||||||
}).on( 'paste', function() {
|
}).on( 'paste', function( event ) {
|
||||||
|
var text, range,
|
||||||
|
clipboard = event.originalEvent.clipboardData || window.clipboardData;
|
||||||
|
|
||||||
|
if ( clipboard ) {
|
||||||
|
try{
|
||||||
|
text = clipboard.getData( 'Text' ) || clipboard.getData( 'text/plain' );
|
||||||
|
|
||||||
|
if ( text ) {
|
||||||
|
text = $.trim( text.replace( /\s+/g, ' ' ) );
|
||||||
|
|
||||||
|
if ( window.getSelection ) {
|
||||||
|
range = window.getSelection().getRangeAt(0);
|
||||||
|
|
||||||
|
if ( range ) {
|
||||||
|
if ( ! range.collapsed ) {
|
||||||
|
range.deleteContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
range.insertNode( document.createTextNode( text ) );
|
||||||
|
}
|
||||||
|
} else if ( document.selection ) {
|
||||||
|
range = document.selection.createRange();
|
||||||
|
|
||||||
|
if ( range ) {
|
||||||
|
range.text = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch ( er ) {}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
saveAlert = true;
|
saveAlert = true;
|
||||||
|
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
$titleField.text( getTitleText() );
|
$titleField.text( getTitleText() );
|
||||||
}, 100 );
|
}, 50 );
|
||||||
});
|
});
|
||||||
|
|
||||||
if ( $titleField.text() || $titleField.html() ) {
|
if ( $titleField.text() || $titleField.html() ) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-beta3-31986';
|
$wp_version = '4.2-beta3-31987';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
|
Loading…
Reference in New Issue