TinyMCE: use window.twemoji directly in the `wpemoji` plugin. Gives a chance to the browser to lazy load twemoji.js when reloading the page.
Fixes #31901. git-svn-id: https://develop.svn.wordpress.org/trunk@32142 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ab5685e6ad
commit
b7817247c5
|
@ -1,4 +1,4 @@
|
||||||
( function( tinymce, wp, twemoji ) {
|
( function( tinymce, wp ) {
|
||||||
tinymce.PluginManager.add( 'wpemoji', function( editor ) {
|
tinymce.PluginManager.add( 'wpemoji', function( editor ) {
|
||||||
var typing,
|
var typing,
|
||||||
env = tinymce.Env,
|
env = tinymce.Env,
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
function parseNode( node ) {
|
function parseNode( node ) {
|
||||||
var selection, bookmark;
|
var selection, bookmark;
|
||||||
|
|
||||||
if ( node && twemoji.test( node.textContent || node.innerText ) ) {
|
if ( node && window.twemoji && window.twemoji.test( node.textContent || node.innerText ) ) {
|
||||||
if ( env.webkit ) {
|
if ( env.webkit ) {
|
||||||
selection = editor.selection;
|
selection = editor.selection;
|
||||||
bookmark = selection.getBookmark();
|
bookmark = selection.getBookmark();
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
var selection = editor.selection,
|
var selection = editor.selection,
|
||||||
node = selection.getNode();
|
node = selection.getNode();
|
||||||
|
|
||||||
if ( twemoji.test( node.textContent || node.innerText ) ) {
|
if ( window.twemoji && window.twemoji.test( node.textContent || node.innerText ) ) {
|
||||||
replaceEmoji( node );
|
replaceEmoji( node );
|
||||||
|
|
||||||
// In IE all content in the editor is left selected after wp.emoji.parse()...
|
// In IE all content in the editor is left selected after wp.emoji.parse()...
|
||||||
|
@ -96,9 +96,9 @@
|
||||||
|
|
||||||
// Convert Twemoji compatible pasted emoji replacement images into our format.
|
// Convert Twemoji compatible pasted emoji replacement images into our format.
|
||||||
editor.on( 'PastePostProcess', function( event ) {
|
editor.on( 'PastePostProcess', function( event ) {
|
||||||
if ( twemoji ) {
|
if ( window.twemoji ) {
|
||||||
tinymce.each( editor.dom.$( 'img.emoji', event.node ), function( image ) {
|
tinymce.each( editor.dom.$( 'img.emoji', event.node ), function( image ) {
|
||||||
if ( image.alt && twemoji.test( image.alt ) ) {
|
if ( image.alt && window.twemoji.test( image.alt ) ) {
|
||||||
setImgAttr( image );
|
setImgAttr( image );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -125,4 +125,4 @@
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
} )( window.tinymce, window.wp, window.twemoji );
|
} )( window.tinymce, window.wp );
|
||||||
|
|
Loading…
Reference in New Issue