WordPress/wp-includes/js/tinymce/plugins/wpemoji/plugin.min.js

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);