我为我的tinymce添加了一个自定义快捷方式,但是当我按下快捷键alt + p时,我得到一个错误,看来我的对象在“p.getDoc()上是空的.execCommand()
这是我的初始代码:
page.ClientScript.RegisterStartupScript(
page.GetType(),
"MyKey2" + this.ID, @"<script type=""text/javascript"" >" +
@"tinyMCE.init({" +
@"mode: ""exact""," +
@"elements: """ + this.ID + @"""," +
@"theme: ""advanced""," +
@"theme_advanced_buttons1: ""bold,italic,underline,|,outdent,indent,|,cut,copy,paste,|,undo,redo""," +
@"theme_advanced_toolbar_location: ""top""," +
@"theme_advanced_toolbar_align: ""left""," +
@"theme_advanced_statusbar_location: ""bottom""," +
"custom_shortcuts : true," +
"theme_advanced_path : false," +
"setup : function(ed) {" +
"ed.onInit.add(function(ed) {"+
"ed.addShortcut('alt+p',' ','CutFromJournal();', ' ');"+
"});"+
"}" +
"});" +
"</script>",
false);
我也试过直接在js文件中创建方法
function addKeyboardShortcuts() {
// Add some inline shortcuts
ed.addShortcut('ctrl+b', 'bold_desc', 'Bold');
ed.addShortcut('ctrl+i', 'italic_desc', 'Italic');
ed.addShortcut('ctrl+u', 'underline_desc', 'Underline');
//custom shortcuts -
ed.addShortcut('ctrl+p', 'custom_description', 'CutFromJournal');
// BlockFormat shortcuts keys
for (var i = 1; i <= 6; i++) {
ed.addShortcut('ctrl+' + i, '', ['FormatBlock', false, 'h' + i]);
}
ed.addShortcut('ctrl+7', '', ['FormatBlock', false, 'p']);
ed.addShortcut('ctrl+8', '', ['FormatBlock', false, 'div']);
ed.addShortcut('ctrl+9', '', ['FormatBlock', false, 'address']);
};
(非压缩)