如何在 TinyMCE 4 中创建一个增加字体大小的按钮
How to create a button in TinyMCE 4 that increments font size
有没有人设法在 TinyMCE 4 中创建一个按钮,将所选文本的字体大小增加 1px?
我遇到的问题是获取所选文本,无论它是否已经在一个范围内。
我愿意修改TinyMCE源。
感谢任何想法。
无需修改源码,创建插件即可。
这里是关于如何为 TinyMCE 创建插件的文档:
http://www.tinymce.com/wiki.php/Tutorials:Creating_a_plugin
在此基础上您可以创建自己的按钮 (see working example)
这是代码的一部分:
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
有没有人设法在 TinyMCE 4 中创建一个按钮,将所选文本的字体大小增加 1px?
我遇到的问题是获取所选文本,无论它是否已经在一个范围内。 我愿意修改TinyMCE源。
感谢任何想法。
无需修改源码,创建插件即可。
这里是关于如何为 TinyMCE 创建插件的文档: http://www.tinymce.com/wiki.php/Tutorials:Creating_a_plugin
在此基础上您可以创建自己的按钮 (see working example) 这是代码的一部分:
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