简体   繁体   English

如何使用 jQuery 将焦点设置为 CKEditor 5?

[英]How can I set focus to CKEditor 5 with jQuery?

I've created a CKEditor field and initialized it like this:我创建了一个 CKEditor 字段并像这样初始化它:

            ClassicEditor
                .create(document.querySelector('#note}'))
                .then(editor => {
                    noteEditor = editor;
                })
                .catch( error => {
                    console.error( error );
                });

All I want to do is either:我想做的就是:

  1. Set focus to the editor using JS/Jquery.使用 JS/Jquery 将焦点设置到编辑器。
  2. Or get the actual input control's element ID to just make it focus (likely a bad idea).或者获取实际输入控件的元素 ID 以使其成为焦点(可能是个坏主意)。

If I cannot set focus to it anytime (not just at start-up) can someone suggest a nice looking editor?如果我不能在任何时候(不仅仅是在启动时)设置焦点,有人可以推荐一个漂亮的编辑器吗?

To set focus at the beginning of the text editor is as follows:在文本编辑器的开头设置焦点如下:

 ClassicEditor
                .create(document.querySelector('#note}'))
                .then(editor => {                        
 editor.editing.view.focus();
                })
                .catch( error => {
                    console.error( error );
                });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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