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

Can't prevent "Enter" event #4873

Open
CorentinAT opened this issue Feb 5, 2025 · 0 comments
Open

Can't prevent "Enter" event #4873

CorentinAT opened this issue Feb 5, 2025 · 0 comments

Comments

@CorentinAT
Copy link

I'm currently trying to trigger an event when the 'Enter' key is pressed on a froala editor, but I don't want to have a carriage return at the end of the editor.

I have this code in the froala config :

const froalaConfig = {
        placeholderText: 'Start writing here...',
        toolbarInline: true,
        events: {
            initialized: () => {
                setInitialized(true)
            },
            focus: () => {
                return
            },
            keydown: (e: KeyboardEvent) => {
                if (!e.shiftKey && e.key === 'Enter' && props.onEnter) {
                    e.preventDefault()
                    e.stopPropagation()
                    if (parent) props.onEnter(parent, id)
                }
            }
        },
}

I tried to use event.preventDefault() and event.stopPropagation() but no effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant