Fork自 GitCode / 1024程序员开源挑战赛(10.23-11.14)
/*! * @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:'<svg t="1610616201691" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="969" width="24" height="24"><path d="M682.666667 704l128 106.666667-128 106.666666v-85.333333H341.333333v85.333333L213.333333 810.666667l128-106.666667v85.333333h341.333334v-85.333333zM170.666667 170.666667v682.666666H85.333333V170.666667h85.333334z m768 0v682.666666h-85.333334V170.666667h85.333334z m-394.666667 0l202.666667 469.333333h-89.6l-38.4-93.866667h-213.333334L366.933333 640H277.333333l202.666667-469.333333h64zM512 255.146667L432.213333 469.333333h159.573334L512 255.146667z" p-id="970" fill="#222f3e"></path></svg>'};x(f);var N={opt:f};return N})();