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

1 line
1.5 KiB
JavaScript
Raw Normal View History

!function(r){r.PluginManager.add("wpemoji",function(n){var t,e,o=window.wp,i=window._wpemojiSettings,a=r.Env,w=window.navigator.userAgent,d=-1<w.indexOf("Windows"),c=!!((e=w.match(/Windows NT 6\.(\d)/))&&1<e[1]);function m(e){o.emoji.parse(e,{imgAttr:{"data-mce-resize":"false","data-mce-placeholder":"1","data-wp-emoji":"1"}})}function s(e){var t,o;e&&window.twemoji&&window.twemoji.test(e.textContent||e.innerText)&&(a.webkit&&(o=(t=n.selection).getBookmark()),m(e),a.webkit&&t.moveToBookmark(o))}o&&o.emoji&&!i.supports.everything&&(c?n.on("keyup",function(e){231===e.keyCode&&s(n.selection.getNode())}):d||(n.on("keydown keyup",function(e){t="keydown"===e.type}),n.on("input",function(){t||s(n.selection.getNode())})),n.on("setcontent",function(e){var t=n.selection,o=t.getNode();window.twemoji&&window.twemoji.test(o.textContent||o.innerText)&&(m(o),a.ie&&a.ie<9&&e.load&&o&&"BODY"===o.nodeName&&t.collapse(!0))}),n.on("PastePostProcess",function(e){window.twemoji&&r.each(n.dom.$("img.emoji",e.node),function(e){e.alt&&window.twemoji.test(e.alt)&&function(e){e.className="emoji",e.setAttribute("data-mce-resize","false"),e.setAttribute("data-mce-placeholder","1"),e.setAttribute("data-wp-emoji","1")}(e)})}),n.on("postprocess",function(e){e.content&&(e.content=e.content.replace(/<img[^>]+data-wp-emoji="[^>]+>/g,function(e){var t=e.match(/alt="([^"]+)"/);return t&&t[1]?t[1]:e}))}),n.on("resolvename",function(e){"IMG"===e.target.nodeName&&n.dom.getAttrib(e.target,"data-wp-emoji")&&e.preventDefault()}))})}(window.tinymce);