开发者

CKEDITOR, AutoFocus on the text editor onLoad

开发者 https://www.devze.com 2022-12-14 10:16 出处:网络
Anyone know how to autofocus on the CKEDITOR text area on开发者_Go百科 page load? Currently the user has to click in the text area before they can start typing. Like Google, I\'d like the page to loa

Anyone know how to autofocus on the CKEDITOR text area on开发者_Go百科 page load?

Currently the user has to click in the text area before they can start typing. Like Google, I'd like the page to load and the user can immediately start typing w/o having to click the text area.

Here is the current code that initiated CKEDITOR

<script type="text/javascript">
CKEDITOR.replace( 'meeting_notes',
    {
        toolbar :
        [
            [ 'Bold', 'Italic', 'Underline', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink' ],
            ['Cut','Copy','Paste','PasteText'],
            ['Undo','Redo','-','RemoveFormat'],
            ['TextColor','BGColor'],
            ['Maximize']
        ]
    });
</script>

Thanks


Perhaps the startupFocus config option?

CKEDITOR.replace( 'meeting_notes',
    {
        startupFocus : true,
        toolbar :
...


I've not tried it myself, but check out the CKEDITOR.config.startupFocus.

Definition: Sets whether the editor should have the focus when the page loads.


In your config simply do this:

    config.startupFocus = true;


set focus to the editor on load by passing a callback to the onReady prop that sets focus to the editor

<CKEditor ... onReady={(editor) => { editor.focus(); }} />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号