Changeset 31948
- Timestamp:
- 04/01/2015 02:38:25 AM (10 years ago)
- Location:
- trunk/src/wp-includes/js
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js
r31946 r31948 23 23 image.setAttribute( 'data-mce-resize', 'false' ); 24 24 image.setAttribute( 'data-mce-placeholder', '1' ); 25 image.setAttribute( 'data-wp-emoji', image.alt);25 image.setAttribute( 'data-wp-emoji', '1' ); 26 26 } 27 27 28 28 function replaceEmoji( node ) { 29 wp.emoji.parse( node, { className: 'emoji _inserted-emoji' } ); 30 tinymce.each( editor.dom.$( 'img._inserted-emoji', node ), setImgAttr ); 29 var imgAttr = { 30 'data-mce-resize': 'false', 31 'data-mce-placeholder': '1', 32 'data-wp-emoji': '1' 33 }; 34 35 wp.emoji.parse( node, { imgAttr: imgAttr } ); 31 36 } 32 37 … … 103 108 editor.on( 'postprocess', function( event ) { 104 109 if ( event.content ) { 105 event.content = event.content.replace( /<img[^>]+data-wp-emoji="([^"]+)"[^>]*>/g, '$1' ); 110 event.content = event.content.replace( /<img[^>]+data-wp-emoji="[^>]+>/g, function( img ) { 111 var alt = img.match( /alt="([^"]+)"/ ); 112 113 if ( alt && alt[1] ) { 114 return alt[1]; 115 } 116 117 return img; 118 }); 106 119 } 107 120 } ); -
trunk/src/wp-includes/js/twemoji.js
r31779 r31948 338 338 icon, 339 339 variant, 340 src; 340 src, 341 attr; 341 342 while (length--) { 342 343 modified = false; … … 364 365 if (src) { 365 366 img = new Image(); 367 368 // Set additional image attributes. 369 if ( options.imgAttr ) { 370 for ( attr in options.imgAttr ) { 371 img.setAttribute( attr, options.imgAttr[attr] ); 372 } 373 } 374 366 375 img.onerror = twemoji.onerror; 367 376 img.className = options.className; … … 407 416 function parseString(str, options) { 408 417 return replace(str, function (match, icon, variant) { 409 var src ;418 var src, attr, attributes = ''; 410 419 // verify the variant is not the FE0E one 411 420 // this variant means "emoji as text" and should not … … 419 428 ); 420 429 if (src) { 430 // Set additional image attributes. 431 if ( options.imgAttr ) { 432 for ( attr in options.imgAttr ) { 433 if ( ! /draggable|class|alt|src/i.test( attr ) ) { 434 attributes += ' '.concat( attr, '="', options.imgAttr[attr], '"' ); 435 } 436 } 437 } 438 421 439 // recycle the match string replacing the emoji 422 440 // with its image counter part … … 432 450 src, 433 451 '"', 452 attributes, 434 453 '>' 435 454 ); … … 484 503 ext: how.ext || twemoji.ext, 485 504 size: how.folder || toSizeSquaredAsset(how.size || twemoji.size), 486 className:how.className || twemoji.className 505 className:how.className || twemoji.className, 506 imgAttr: how.imgAttr 487 507 }); 488 508 } -
trunk/src/wp-includes/js/wp-emoji.js
r31898 r31948 101 101 } 102 102 103 var className = ( args && args.className ) || 'emoji';103 args = args || {}; 104 104 105 105 return twemoji.parse( object, { 106 106 base: settings.baseUrl, 107 107 ext: settings.ext, 108 className: className, 108 className: args.className || 'emoji', 109 imgAttr: args.imgAttr, 109 110 callback: function( icon, options ) { 110 111 // Ignore some standard characters that TinyMCE recommends in its character map.
Note: See TracChangeset
for help on using the changeset viewer.