Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to listen to composition events? #1342

Closed
gongzhiq opened this issue Nov 6, 2018 · 2 comments
Closed

How to listen to composition events? #1342

gongzhiq opened this issue Nov 6, 2018 · 2 comments
Labels
type:question This issue asks a question (how to...).

Comments

@gongzhiq
Copy link

gongzhiq commented Nov 6, 2018

$(editor).on({
                    compositionstart: function () {
                    },
                    compositionend: function () {
                    },
                    input: function () {
                   }
 });

How can editor objects be found?

@oleq
Copy link
Member

oleq commented Nov 6, 2018

cc @f1ames

@oleq oleq changed the title Hello, how to add an event to editor in ckeditor5 How to listen to composition events? Nov 6, 2018
@f1ames f1ames added type:question This issue asks a question (how to...). status:confirmed labels Nov 6, 2018
@f1ames
Copy link
Contributor

f1ames commented Nov 6, 2018

There is a special observer for composition events, see CompositionObserver.

Usually you create editor like:

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

and then you can add listeners (in .then callback) like:

editor.editing.view.document.on( 'compositionstart', callback );
editor.editing.view.document.on( 'compositionupdate', callback );
editor.editing.view.document.on( 'compositionend', callback );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question This issue asks a question (how to...).
Projects
None yet
Development

No branches or pull requests

4 participants