/*! * @plugin @tinymce-plugin/tp-letterspacing * @version 0.0.9 (2022-4-19) * @description 字母间距 * @copyright (2022) Five(Li Hailong) https://github.com/tinymce-plugin/tp-letterspacing */(function(){"use strict";var m=function(t){return t.getParam("tp-letterspacing","0px 1px 2px 4px 6px 8px 10px 20px 40px")},g=function(t,e){t.undoManager.transact(function(){t.focus(),t.execCommand("tpLetterspacing",!1,e)})},h=function(t,e){t.ui.registry.getAll().icons[e.registryName]||t.ui.registry.addIcon(e.registryName,e.icon);var l=tinymce.util.Tools.resolve("tinymce.util.Tools"),o=t.tp$.Tools,L=function(n){var r=n,i=n,a=function(){return r},c=function(){return i},b=function(M,p){r=M,p&&(i=p)};return{get:a,set:b,getAction:c}},v=function(n){return n.length>0?n[0]:""},u=m(t).split(" "),s=L(v(u));t.ui.registry.addSplitButton(e.registryName,{icon:e.registryName,tooltip:e.title,select:function(n){return n===s.get()},fetch:function(n){var r=t.selection.getStart(),i=-1;if(i==-1){var a=o.getCurrentValue(r,"letter-spacing");i=a||v(u)}n(l.map(u,function(c){return i==c&&s.set(c),{type:"choiceitem",text:c,value:c}}))},onAction:function(){g(t,s.getAction())},onItemAction:function(n,r){s.set(r,r),g(t,r)}}),t.ui.registry.addNestedMenuItem(e.registryName,{text:e.title,icon:e.registryName,getSubmenuItems:function(){var n=t.selection.getStart(),r=-1;if(r==-1){var i=o.getCurrentValue(n,"letter-spacing");r=i||v(u)}return l.map(u,function(a){return{type:"togglemenuitem",text:a,active:r===a,onAction:function(){s.set(a,a),g(t,a)}}})}})},y=function(t,e){t.addCommand("mce".concat(e.registryName.substring(0,1).toUpperCase()+e.registryName.substring(1)),function(l,o){g(t,o)})},x=function(t){tinymce.PluginManager.add(t.registryName,function(e,l){return h(e,t),y(e,t),{getMetadata:function(){return{name:t.name,url:t.repo}}}})},f={name:"Letterspacing",registryName:"tpLetterspacing",title:"Letter Spacing",repo:"https://github.com/tinymce-plugin/tp-letterspacing",icon:''};x(f);var N={opt:f};return N})();