Editor: manually trigger `change` event when text is modified from JS.
Props westonruter. Fixes #40726. git-svn-id: https://develop.svn.wordpress.org/trunk@40615 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ab5cd5011f
commit
0c63472b68
|
@ -406,7 +406,7 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
||||||
};
|
};
|
||||||
|
|
||||||
qt.insertContent = function(content) {
|
qt.insertContent = function(content) {
|
||||||
var sel, startPos, endPos, scrollTop, text, canvas = document.getElementById(wpActiveEditor);
|
var sel, startPos, endPos, scrollTop, text, canvas = document.getElementById(wpActiveEditor), event;
|
||||||
|
|
||||||
if ( !canvas ) {
|
if ( !canvas ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -433,6 +433,15 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
||||||
canvas.value += content;
|
canvas.value += content;
|
||||||
canvas.focus();
|
canvas.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( document.createEvent ) {
|
||||||
|
event = document.createEvent( 'HTMLEvents' );
|
||||||
|
event.initEvent( 'change', false, true );
|
||||||
|
canvas.dispatchEvent( event );
|
||||||
|
} else if ( canvas.fireEvent ) {
|
||||||
|
canvas.fireEvent( 'onchange' );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -515,7 +524,7 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
qt.TagButton.prototype.callback = function(element, canvas, ed) {
|
qt.TagButton.prototype.callback = function(element, canvas, ed) {
|
||||||
var t = this, startPos, endPos, cursorPos, scrollTop, v = canvas.value, l, r, i, sel, endTag = v ? t.tagEnd : '';
|
var t = this, startPos, endPos, cursorPos, scrollTop, v = canvas.value, l, r, i, sel, endTag = v ? t.tagEnd : '', event;
|
||||||
|
|
||||||
if ( document.selection ) { // IE
|
if ( document.selection ) { // IE
|
||||||
canvas.focus();
|
canvas.focus();
|
||||||
|
@ -590,6 +599,14 @@ function edButton(id, display, tagStart, tagEnd, access) {
|
||||||
}
|
}
|
||||||
canvas.focus();
|
canvas.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( document.createEvent ) {
|
||||||
|
event = document.createEvent( 'HTMLEvents' );
|
||||||
|
event.initEvent( 'change', false, true );
|
||||||
|
canvas.dispatchEvent( event );
|
||||||
|
} else if ( canvas.fireEvent ) {
|
||||||
|
canvas.fireEvent( 'onchange' );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// removed
|
// removed
|
||||||
|
|
|
@ -380,6 +380,7 @@ var wpLink;
|
||||||
|
|
||||||
wpLink.close();
|
wpLink.close();
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
|
$( textarea ).trigger( 'change' );
|
||||||
|
|
||||||
// Audible confirmation message when a link has been inserted in the Editor.
|
// Audible confirmation message when a link has been inserted in the Editor.
|
||||||
wp.a11y.speak( wpLinkL10n.linkInserted );
|
wp.a11y.speak( wpLinkL10n.linkInserted );
|
||||||
|
|
Loading…
Reference in New Issue