Javascript Tinymce为自定义样式添加快捷方式
在tinymce初始化中,我使用预先定义的样式Javascript Tinymce为自定义样式添加快捷方式,javascript,tinymce,Javascript,Tinymce,在tinymce初始化中,我使用预先定义的样式 style_formats : [ {title : 'Date', inline : 'span', classes : 'date'}, {title : 'Trend UP', inline : 'span', classes : 'trend_up'}, {title : 'Trend DOWN', inline : 'span', classes : 'trend_down'}, {title : 'Tr
style_formats : [
{title : 'Date', inline : 'span', classes : 'date'},
{title : 'Trend UP', inline : 'span', classes : 'trend_up'},
{title : 'Trend DOWN', inline : 'span', classes : 'trend_down'},
{title : 'Trend NO', inline : 'span', classes : 'trend_no'}
]
这种预先定义的样式将选定的内容包装到span标记中,并为其添加特定的类;
但现在我需要添加快捷键(热键),以提供相同的功能
为此,我创建了一个插件,可以在其中定义热键
(function(){
tinymce.create('tinymce.plugins.MyShortcuts', {
init : function(ed, url) {
ed.addShortcut('ctrl+e','Format Blockquote', ['FormatBlock', false, 'blockquote'], this);
}
});
// Register plugin with a short name
tinymce.PluginManager.add('my_shortcuts', tinymce.plugins.MyShortcuts);
})();
它对blockquote很有效。但是我在中没有找到任何有用的信息来实现自定义样式的快捷方式
有人能帮我实现这个功能吗?
我试着去做
ed.addShortcut('ctrl+e','Format Trend UP', ['FormatBlock', false, 'Trend UP'], this);
及
但它不起作用。我使用此链接()来找到解决方案
除了
style_formats : [
{title : 'Date', inline : 'span', classes : 'date'}
]
我已将格式添加到初始化:
formats: { mydateformat: {inline: 'span', classes : 'date'}}
之后,插件中的代码非常简单:
ed.addShortcut('ctrl+alt+3', 'Date format', function(){
ed.formatter.apply('mydateformat');
});
还是有所改进
ed.addShortcut('ctrl+alt+3', 'Date format', ['FormatBlock', false, 'mydateformat'], this);
请在Tinymce 3中将该代码粘贴到何处,以便向Blockquote添加快捷码?我将对你的回答表示感谢
ed.addShortcut('ctrl+alt+3', 'Date format', ['FormatBlock', false, 'mydateformat'], this);