2015-01-09 80 views

回答

4

你不需要修改源代码,你可以创建一个插件。

下面是如何创建TinyMCE的插件文件:根据您可以创建自己的按钮(see working examplehttp://www.tinymce.com/wiki.php/Tutorials:Creating_a_plugin

这里是代码的一部分:

var currentFontSize = new Number($(tinyMCE.activeEditor.selection.getNode()).css('font-size').replace('px','')); //remove the px part 
     currentFontSize = currentFontSize + 1; //increase font by one 

     tinymce.activeEditor.formatter.register('mycustomformat', { 
     inline : 'span', 
     styles : {'font-size' : currentFontSize + 'px'} //this is the font size incremented by one 
}); 

tinymce.activeEditor.formatter.apply('mycustomformat'); //apply the format to the selected text 
+0

非常感谢,何塞! – Steve 2015-01-19 16:18:25

+0

我不确定_why_此解决方案的工作原理。第一行获取包含选择的_node_的字体大小,可能是'p'。但是选择本身可能有不同的字体大小,并且肯定会在第一次通过单击按钮来运行该功能之后。然而,下一次读取的字体大小是凸起的字体大小。奇怪的是,如果您尝试以字母间距来执行此操作,则此解决方案不起作用,即,使按钮将选区的字母间距增加1px。我希望你仍然关注这个问题,并且有时间来澄清这个问题。谢谢。 – Steve 2015-01-24 01:27:18