简体   繁体   中英

tinyMCE: how to add shortcut Ctrl+Enter

How can I add shortcut Ctrl + Enter to tinyMCE (v4) to make it post the form the editor is used with? I've tried this but doesn't appear to work:

<script><!--
$('#txtField1').tinymce({
script_url:"js/tinymce/tinymce.min.js",
content_css:"css/editor.xxm",
//etc. all of my other config goes here
setup: function(e){
  e.shortcuts.add("ctrl+enter","submit",function(){document.form[0].submit();});}
});
//--></script>

For some reason "enter" isn't one of the "modifier names" that they define. However, you can use key codes. So this works:

e.shortcuts.add("ctrl+13"...

Had to read the code to figure it out https://github.com/tinymce/tinymce/blob/ccff8e084b389fca45399b916261a12cd4418f79/src/core/src/main/js/Shortcuts.js#L50

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM