Reputation: 6195
I would like to have a shortcut in my TinyMCE edictor to easily change the size of the text. From TinyMCE Website, there is the command FontSize
with this description
Font size of the text. The value passed in should be the font size 1-7.
I tried adding this command to my list of others custom shortcuts like this
ed.addShortcut('ctrl+shift+w', 'size_desc', FontSize(5));
But it didn't work. I also tried this but without success:
ed.addShortcut('ctrl+shift+w', 'size_desc', '["FontSize", 5]');
Also I am confused about the value: why can we only set 1
to 7
and not let say 12px
?
Upvotes: 0
Views: 375
Reputation: 83
Have you tried this?
ed.addShortcut('ctrl+shift+w', 'size_desc', '["FontSize", !1, "5px"]');
Also you can create a TinyMce plugin:
plugins
add fontsize_plugin
and in the list of toolbar
add fontsizeselect
then add this line juste below toolbar:
fontsize_formats: "8px 10px 12px 14px 16px 18px
open the folder plugins and create in it a folder fontsize_plugin
and in this filder create a file plugin.js
in which you should copy paste this:
tinymce.PluginManager.add('fontsize_plugin', function (editor, url) {
editor.addCommand('fontsize_plugin_command', function () {
var node = tinymce.activeEditor.selection.getNode();
var fontsize = tinymce.activeEditor.dom.getStyle(node, 'font-size', true);
fontsize = fontsize.split("p", 1)
fontsize--;
if (fontsize > 10 && fontsize <= 14) {
fontsize = 10;
} else if (fontsize <= 10) {
fontsize = 18;
} else {
fontsize = 14;
}
fontsize = fontsize + "px";
tinymce.activeEditor.execCommand('fontsize', false, fontsize);
});
editor.addShortcut('ctrl+shift+w', 'fontsize_plugin_desc', 'fontsize_plugin_command');
});
Upvotes: 1