CKEDITOR, AutoFocus on the text editor onLoad
Asked Answered
B

5

12

Anyone know how to autofocus on the CKEDITOR text area on 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

Buyse answered 22/12, 2009 at 4:39 Comment(0)
A
23

Perhaps the startupFocus config option?

CKEDITOR.replace( 'meeting_notes',
    {
        startupFocus : true,
        toolbar :
...
Amabelle answered 22/12, 2009 at 4:47 Comment(1)
this config was removed from ckeditor 5, don't know what to use to avoid autofocus.Chromatics
S
2

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.

Stater answered 22/12, 2009 at 4:52 Comment(0)
S
2

In your config simply do this:

    config.startupFocus = true;
Salome answered 9/5, 2014 at 3:57 Comment(0)
I
1

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(); }} />
Imperception answered 12/11, 2021 at 13:0 Comment(0)
C
0

from CKEditor 5 docs: The simplest way to focus the editor is to call the editor.focus() method.

Chromatics answered 5/6, 2023 at 16:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.