如何在编辑器中使用快捷键对齐文本,就像在ms office中一样

时间:2015-11-06 04:49:01

标签: javascript jquery ckeditor tinymce

在ms office中为了对齐文本我们首先要选择文本,而不是按ctrl + L,ctrl + r,ctrl + e分别为左,右和中心我们可以对齐文本。

但是对于在线文本编辑器说tinymce和cke编辑器我不知道什么是快捷键,有图标我们可以做到但我想知道是否有快捷键。

2 个答案:

答案 0 :(得分:0)

TinyMCE有一些默认快捷方式,如撤消(Ctrl + Z),粗体(Ctrl + B)等(参见此处:http://www.tinymce.com/forum/viewtopic.php?id=9445),但也可以定义特定按键上发生的功能。

EG。

editor.shortcuts.add('ctrl+a', function() {});
editor.shortcuts.add('meta+a', function() {}); // "meta" maps to Command on Mac and Ctrl on PC
editor.shortcuts.add('ctrl+alt+a', function() {});
editor.shortcuts.add('access+a', function() {}); // "access" maps to ctrl+alt on Mac and shift+alt on PC

http://www.tinymce.com/wiki.php/api4:class.tinymce.Shortcuts

答案 1 :(得分:0)

this is how my code looks   
 where can i add editor.shortcuts.add('ctrl+a', function() {});
    $(document).ready(function()
    {tinymce.init({
      selector: "textarea",
       plugins: [
        "textcolor advlist autolink lists link image charmap print preview anchor",
        "searchreplace visualblocks code fullscreen ",
        "insertdatetime media table contextmenu paste jbimages",
      ],
    relative_urls: false,
    toolbar: "insertfile undo redo | styleselect | fontselect  | forecolor | backcolor | fontsizeselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image jbimages | fullscreen |preview | mybutton",
       setup: function(editor) {
            editor.addButton('mybutton', {
                text: 'Preview it!!!',
                icon: true,
                onclick: function(e) {
                editor.execCommand('mcePreview');
                }
            });
        }
    });

    });