Editor: Add init and remove methods to Quicktags.

Props helgatheviking azaozz.
Fixes #26183 #40708.
Built from https://develop.svn.wordpress.org/trunk@40598


git-svn-id: http://core.svn.wordpress.org/trunk@40468 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2017-05-10 02:47:42 +00:00
parent 391145df30
commit 0b2f789e93
3 changed files with 42 additions and 24 deletions

View File

@ -243,14 +243,22 @@ function edButton(id, display, tagStart, tagEnd, access) {
return document.getElementById(name + '_' + id);
};
qt.instances[id] = t;
t.init = function() {
_domReady( function(){ qt._buttonsInit( id ); } );
};
if ( ! qt.instances['0'] ) {
qt.instances['0'] = qt.instances[id];
_domReady( function(){ qt._buttonsInit(); } );
t.remove = function() {
delete qt.instances[id];
if ( tb && tb.parentNode ) {
tb.parentNode.removeChild( tb );
}
};
qt.instances[id] = t;
t.init();
};
function _escape( text ) {
text = text || '';
text = text.replace( /&([^#])(?![a-z1-4]{1,8};)/gi, '&$1' );
@ -263,16 +271,14 @@ function edButton(id, display, tagStart, tagEnd, access) {
return qt.instances[id];
};
qt._buttonsInit = function() {
var t = this, canvas, name, settings, theButtons, html, inst, ed, id, i, use,
qt._buttonsInit = function( id ) {
var t = this;
function _init( instanceId ) {
var canvas, name, settings, theButtons, html, ed, id, i, use,
defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,';
for ( inst in t.instances ) {
if ( '0' === inst ) {
continue;
}
ed = t.instances[inst];
ed = t.instances[instanceId];
canvas = ed.canvas;
name = ed.name;
settings = ed.settings;
@ -295,7 +301,7 @@ function edButton(id, display, tagStart, tagEnd, access) {
continue;
}
if ( !edButtons[i].instance || edButtons[i].instance === inst ) {
if ( ! edButtons[i].instance || edButtons[i].instance === instanceId ) {
theButtons[id] = edButtons[i];
if ( edButtons[i].html ) {
@ -321,6 +327,15 @@ function edButton(id, display, tagStart, tagEnd, access) {
jQuery( document ).triggerHandler( 'quicktags-init', [ ed ] );
}
}
if ( id ) {
_init( id );
} else {
for ( id in t.instances ) {
_init( id );
}
}
t.buttonsInitDone = true;
};
@ -608,7 +623,10 @@ function edButton(id, display, tagStart, tagEnd, access) {
qt.closeAllTags = function( editor_id ) {
var ed = this.getInstance( editor_id );
if ( ed ) {
qt._close( '', ed.canvas, ed );
}
};
// the link button

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40597';
$wp_version = '4.8-alpha-40598';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.