tinymce富文本行高插件
直接引入,在plugins和toolbar中添加 lineheight
tinymce.PluginManager.add('lineheight', function(editor, url) { var pluginName='设置行高'; var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); var lineheight_val = editor.getParam('lineheight_val', '1 1.5 1.6 1.75 1.8 2 3 4 5'); editor.on('init', function() { editor.formatter.register({ lineheight: { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table', styles: { 'line-height': '%value' } } }); }); var doAct = function (value) { editor.formatter.apply('lineheight', { value: value }); editor.fire('change', {}); }; editor.ui.registry.getAll().icons.lineheight || editor.ui.registry.addIcon('lineheight','<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>'); editor.ui.registry.addMenuButton('lineheight', { icon: 'lineheight', tooltip: pluginName, fetch: function(callback) { var dom = editor.dom; var blocks = editor.selection.getSelectedBlocks(); var lhv = 0; global$1.each(blocks, function(block) { if(lhv==0){ lhv = dom.getStyle(block,'line-height') ? dom.getStyle(block,'line-height') : 0; } }); var items = lineheight_val.split(' ').map(function(item){ var text = item; var value = item; return { type: 'togglemenuitem', text: text, active : lhv==value ? true :false, onAction: function() { doAct(value); } }; }); callback(items); } }); return { getMetadata: function () { return { name: pluginName, url: "http://tinymce.ax-z.cn/more-plugins/lineheight.php", }; } }; });
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通