Changeset 31786
- Timestamp:
- 03/15/2015 11:15:28 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/common.css
r31747 r31786 678 678 .wp-ui-text-icon { 679 679 color: #999; 680 } 681 682 /* For emoji replacement images */ 683 img.emoji { 684 display: inline !important; 685 border: none !important; 686 height: 1em !important; 687 width: 1em !important; 688 margin: 0 .07em !important; 689 vertical-align: -0.1em !important; 690 background: none !important; 691 padding: 0 !important; 692 -webkit-box-shadow: none !important; 693 box-shadow: none !important; 680 694 } 681 695 -
trunk/src/wp-includes/default-filters.php
r31733 r31786 255 255 add_action( 'admin_print_footer_scripts', '_wp_footer_scripts' ); 256 256 add_action( 'admin_print_styles', 'print_admin_styles', 20 ); 257 add_action( 'admin_print_styles', 'print_emoji_styles' );258 257 add_action( 'init', 'smilies_init', 5 ); 259 258 add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 ); -
trunk/src/wp-includes/formatting.php
r31781 r31786 4047 4047 height: 1em !important; 4048 4048 width: 1em !important; 4049 margin: 0 .0 5em 0 .1em !important;4049 margin: 0 .07em !important; 4050 4050 vertical-align: -0.1em !important; 4051 4051 background: none !important; -
trunk/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js
r31779 r31786 1 ( function( tinymce, wp ) {1 ( function( tinymce, wp, twemoji ) { 2 2 tinymce.PluginManager.add( 'wpemoji', function( editor ) { 3 3 var typing, 4 4 isMacWebKit = tinymce.Env.mac && tinymce.Env.webkit; 5 5 6 if ( ! wp || ! wp.emoji ) {6 if ( ! wp || ! wp.emoji || ! wp.emoji.replaceEmoji ) { 7 7 return; 8 } 9 10 function setImgAttr( image ) { 11 image.className = 'emoji'; 12 image.setAttribute( 'data-mce-resize', 'false' ); 13 image.setAttribute( 'data-mce-placeholder', '1' ); 14 image.setAttribute( 'data-wp-emoji', image.alt ); 15 } 16 17 function replaceEmoji( node ) { 18 wp.emoji.parse( node, { className: 'emoji _inserted-emoji' } ); 19 tinymce.each( editor.dom.$( 'img._inserted-emoji', node ), setImgAttr ); 8 20 } 9 21 … … 12 24 } ); 13 25 14 editor.on( 'input setcontent', function( event ) { 15 var selection, node, bookmark, images; 16 17 if ( typing && event.type === 'input' ) { 26 editor.on( 'input', function( event ) { 27 if ( typing ) { 18 28 return; 19 29 } 20 30 21 selection = editor.selection; 22 node = selection.getNode(); 31 var bookmark, 32 selection = editor.selection, 33 node = selection.getNode(); 23 34 24 if ( isMacWebKit ) { 25 bookmark = selection.getBookmark(); 35 if ( twemoji.test( node.textContent || node.innerText ) ) { 36 if ( isMacWebKit ) { 37 bookmark = selection.getBookmark(); 38 } 39 40 replaceEmoji( node ); 41 42 if ( isMacWebKit ) { 43 selection.moveToBookmark( bookmark ); 44 } 26 45 } 46 }); 27 47 28 wp.emoji.parse( node, { className: 'wp-emoji new-emoji' } ); 48 editor.on( 'setcontent', function( event ) { 49 var selection = editor.selection, 50 node = selection.getNode(); 29 51 30 images = editor.dom.select( 'img.new-emoji', node ); 52 if ( twemoji.test( node.textContent || node.innerText ) ) { 53 replaceEmoji( node ); 31 54 32 tinymce.each( images, function( image ) { 33 image.className = 'wp-emoji'; 34 image.setAttribute( 'data-mce-resize', 'false' ); 35 image.setAttribute( 'data-mce-placeholder', '1' ); 36 image.setAttribute( 'data-wp-emoji', image.alt ); 37 } ); 38 39 // In IE all content in the editor is left selected aftrer wp.emoji.parse()... 40 // Collapse the selection to the beginning. 41 if ( tinymce.Env.ie && node && node.nodeName === 'BODY' ) { 42 selection.collapse( true ); 43 } 44 45 if ( isMacWebKit ) { 46 selection.moveToBookmark( bookmark ); 55 // In IE all content in the editor is left selected aftrer wp.emoji.parse()... 56 // Collapse the selection to the beginning. 57 if ( tinymce.Env.ie && tinymce.Env.ie < 9 && event.load && node && node.nodeName === 'BODY' ) { 58 selection.collapse( true ); 59 } 47 60 } 48 61 } ); 62 63 // Convert Twemoji compatible pasted emoji repacement images into our format. 64 editor.on( 'PastePostProcess', function( event ) { 65 if ( twemoji ) { 66 tinymce.each( editor.dom.$( 'img.emoji', event.node ), function( image ) { 67 if ( image.alt && twemoji.test( image.alt ) ) { 68 setImgAttr( image ); 69 } 70 }); 71 } 72 }); 49 73 50 74 editor.on( 'postprocess', function( event ) { … … 62 86 } ); 63 87 } ); 64 } )( window.tinymce, window.wp );88 } )( window.tinymce, window.wp, window.twemoji ); -
trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css
r31779 r31786 59 59 60 60 /* For emoji replacement images */ 61 img.wp-emoji { 61 img.emoji { 62 display: inline !important; 63 border: none !important; 62 64 height: 1em !important; 63 65 width: 1em !important; 64 margin: 0 0.07em !important;66 margin: 0 .07em !important; 65 67 vertical-align: -0.1em !important; 66 b order: none !important;68 background: none !important; 67 69 padding: 0 !important; 68 70 -webkit-box-shadow: none !important; -
trunk/src/wp-includes/js/wp-emoji.js
r31780 r31786 5 5 6 6 /** 7 * Flag to determine if we should parse all emoji characters into Twemoji images.7 * Flag to determine if the browser and the OS support emoji. 8 8 * 9 9 * @since 4.2.0 … … 11 11 * @var Boolean 12 12 */ 13 parseAllEmoji = false,13 supportsEmoji = false, 14 14 15 15 /** 16 * Flag to determine if we should consider parsing emoji characters into Twemoji images.16 * Flag to determine if the browser and the OS support flag (two character) emoji. 17 17 * 18 18 * @since 4.2.0 … … 20 20 * @var Boolean 21 21 */ 22 parseEmoji = false,22 supportsFlagEmoji = false, 23 23 24 24 /** 25 * Flag to determine if we should parse flag characters into Twemojiimages.25 * Flag to determine if we should replace emoji characters with images. 26 26 * 27 27 * @since 4.2.0 … … 29 29 * @var Boolean 30 30 */ 31 parseFlags= false;31 replaceEmoji = false; 32 32 33 33 /** … … 40 40 new MutationObserver( function( mutationRecords ) { 41 41 var i = mutationRecords.length, 42 ii, 43 node; 42 ii, node; 44 43 45 44 while ( i-- ) { … … 58 57 } 59 58 } 60 } ) 61 62 .observe( document.body, { 59 } ).observe( document.body, { 63 60 childList: true, 64 61 subtree: true … … 75 72 * @since 4.2.0 76 73 * 77 * @param flagEmoji {Boolean} Whether to test for support of flagemoji.74 * @param type {String} Whether to test for support of "simple" or "flag" emoji. 78 75 * @return {Boolean} True if the browser can render emoji, false if it cannot. 79 76 */ … … 118 115 * 119 116 * @param {HTMLElement|String} object The element or string to parse. 117 * @param {Object} args Additional options for Twemoji. 120 118 */ 121 function parse( object, options ) {122 if ( ! parseEmoji ) {119 function parse( object, args ) { 120 if ( ! replaceEmoji ) { 123 121 return object; 124 122 } 125 123 126 var className = ( options && options.className ) || 'emoji';124 var className = ( args && args.className ) || 'emoji'; 127 125 128 126 return twemoji.parse( object, { … … 144 142 } 145 143 146 if ( parseFlags && ! parseAllEmoji &&144 if ( ! supportsFlagEmoji && supportsEmoji && 147 145 ! /^1f1(?:e[6-9a-f]|f[1-9a-f])-1f1(?:e[6-9a-f]|f[1-9a-f])$/.test( icon ) ) { 148 146 … … 159 157 */ 160 158 if ( twemoji && settings ) { 161 parseAllEmoji = !browserSupportsEmoji();162 parseFlags = !browserSupportsEmoji( 'flag' );163 parseEmoji = parseAllEmoji || parseFlags;164 159 supportsEmoji = browserSupportsEmoji(); 160 supportsFlagEmoji = browserSupportsEmoji( 'flag' ); 161 replaceEmoji = ! supportsEmoji || ! supportsFlagEmoji; 162 165 163 if ( window.addEventListener ) { 166 164 window.addEventListener( 'load', load, false ); … … 172 170 return { 173 171 browserSupportsEmoji: browserSupportsEmoji, 172 replaceEmoji: replaceEmoji, 174 173 parse: parse 175 174 };
Note: See TracChangeset
for help on using the changeset viewer.