mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-19 17:15:16 +01:00
f08c38112b
Fixes #31901. Built from https://develop.svn.wordpress.org/trunk@32142 git-svn-id: http://core.svn.wordpress.org/trunk@32122 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
1.5 KiB
JavaScript
1 line
1.5 KiB
JavaScript
!function(a,b){a.PluginManager.add("wpemoji",function(c){function d(a){a.className="emoji",a.setAttribute("data-mce-resize","false"),a.setAttribute("data-mce-placeholder","1"),a.setAttribute("data-wp-emoji","1")}function e(a){var c={"data-mce-resize":"false","data-mce-placeholder":"1","data-wp-emoji":"1"};b.emoji.parse(a,{imgAttr:c})}function f(a){var b,d;a&&window.twemoji&&window.twemoji.test(a.textContent||a.innerText)&&(h.webkit&&(b=c.selection,d=b.getBookmark()),e(a),h.webkit&&b.moveToBookmark(d))}var g,h=a.Env,i=window.navigator.userAgent,j=i.indexOf("Windows")>-1,k=function(){var a=i.match(/Windows NT 6\.(\d)/);return a&&a[1]>1?!0:!1}();b&&b.emoji&&b.emoji.replaceEmoji&&(k?c.on("keyup",function(a){231===a.keyCode&&f(c.selection.getNode())}):j||(c.on("keydown keyup",function(a){g="keydown"===a.type}),c.on("input",function(){g||f(c.selection.getNode())})),c.on("setcontent",function(a){var b=c.selection,d=b.getNode();window.twemoji&&window.twemoji.test(d.textContent||d.innerText)&&(e(d),h.ie&&h.ie<9&&a.load&&d&&"BODY"===d.nodeName&&b.collapse(!0))}),c.on("PastePostProcess",function(b){window.twemoji&&a.each(c.dom.$("img.emoji",b.node),function(a){a.alt&&window.twemoji.test(a.alt)&&d(a)})}),c.on("postprocess",function(a){a.content&&(a.content=a.content.replace(/<img[^>]+data-wp-emoji="[^>]+>/g,function(a){var b=a.match(/alt="([^"]+)"/);return b&&b[1]?b[1]:a}))}),c.on("resolvename",function(a){"IMG"===a.target.nodeName&&c.dom.getAttrib(a.target,"data-wp-emoji")&&a.preventDefault()}))})}(window.tinymce,window.wp); |