Fork自 GitCode / 1024程序员开源挑战赛(10.23-11.14)
/*! * @plugin @tinymce-plugin/tp-lineheight * @version 0.0.9 (2022-5-5) * @description 行间距 * @copyright (2022) Five(Li Hailong) https://github.com/tinymce-plugin/tp-lineheight */(function(){"use strict";var v=function(e){return e.getParam("tp_lineheight_value","1 1.5 1.6 1.75 1.8 2 3 4 5")},g=function(e,t){e.undoManager.transact(function(){e.focus(),e.execCommand("tpLineHeight",!1,t)})},m=function(e,t){e.ui.registry.getAll().icons[t.registryName]||e.ui.registry.addIcon(t.registryName,t.icon);var l=tinymce.util.Tools.resolve("tinymce.util.Tools"),s=e.tp$.Tools,N=function(n){return n.length>0?n[0]:""},h=v(e).split(" "),c=s.selection.cell(N(h));e.ui.registry.addSplitButton(t.registryName,{icon:t.registryName,tooltip:t.title,select:function(n){return n===c.get()},fetch:function(n){var i=e.dom,a=e.selection.getSelectedBlocks(),r=-1;r==-1&&(r=i.getStyle(a,"line-height")?i.getStyle(a,"line-height"):""),n(l.map(h,function(u){return r==u&&c.set(u),{type:"choiceitem",text:u,value:u}}))},onAction:function(){g(e,c.getAction())},onItemAction:function(n,i){c.set(i,i),g(e,i)}}),e.ui.registry.addNestedMenuItem(t.registryName,{text:t.title,icon:t.registryName,getSubmenuItems:function(){var n=e.dom,i=e.selection.getSelectedBlocks(),a=-1;return a==-1&&(a=n.getStyle(i,"line-height")?n.getStyle(i,"line-height"):""),l.map(h,function(r){return{type:"togglemenuitem",text:r,active:a===r,onAction:function(){c.set(r,r),g(e,r)}}})}})},f=function(e,t){e.addCommand("mce".concat(t.registryName.substring(0,1).toUpperCase()+t.registryName.substring(1)),function(l,s){g(e,s)})},y=function(e){tinymce.PluginManager.add(e.registryName,function(t,l){return m(t,e),f(t,e),{getMetadata:function(){return{name:e.name,url:e.repo}}}})},o={name:"Lineheight",registryName:"tpLineheight",title:"Line Height",repo:"https://github.com/tinymce-plugin/tp-lineheight",icon:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M9.984 12.984v-1.969h12v1.969h-12zM9.984 18.984v-1.969h12v1.969h-12zM9.984 5.016h12v1.969h-12v-1.969zM6 6.984v10.031h2.484l-3.469 3.469-3.516-3.469h2.484v-10.031h-2.484l3.516-3.469 3.469 3.469h-2.484z"></path></svg>'};y(o);var p={opt:o};return p})();