question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prevent new block when user press Enter

See original GitHub issue

I have to prevent when the users press Enter, and instead of create a new paragraph, it should just return a break line <br />. But when the users type enter only

The enter key should be equal Shift+Enter

Here’s my editor: https://staging.leorad.com.br/laudador/63

There are a bunch of pre set sentences there. If the user wants to improve that, they can continue writing, but when the user types enter, it must continue in the same block, it can not create a new block.

How can I do that?

Something around this class

https://github.com/codex-team/editor.js/blob/43032ebaac6a8b9a67c9bf2ada5adc0f8592d546/src/components/modules/blockEvents.ts#L208

By using

  static get enableLineBreaks() {
    return true
  }

It continues in the same block, but it creates extra divs inside my current block, wrapping the sentence by divs, and i need to just add <br />

Press Enter Key should work exactly like when press Shift+Enter Keys

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
paridigmcommented, Oct 24, 2021

@neSpecc @gohabereg I feel as tough the answer here is a bit open ended,

you can add your own listeners on enter press in your tool and manage this behaviour on your own

Can you show, or at least guide in the right direction, how one might actually go about implementing that in the tool?

I think that anybody reading this can understand the logic/idea behind that as it seems to make a lot of sense, but I don’t think anyone looking at this can easily connect the dots in order to implement it into editor.js like you guys can.

PS Amazing library btw! I just found it today, and Editor.js looks really impressive so far!

Thanks! Tom

0reactions
CavalcanteLeocommented, Nov 23, 2020

@neSpecc could you please reopen? since there is no answer Or should I create a new issue?

i really need to do this.

I can even pay if anyone give me a hand with this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable New Line in Textarea when Pressed ENTER
Below code is to prevent to getting resize the "textarea", avoid scroll bar inside textarea, and also prevent to get into next line...
Read more >
2.1 Why you should not press Enter at the end of every line
When typing in a Word document, don't press the Enter key at the end of every line. This page explains why.
Read more >
Stop Submiting form when Press Enter - Laracasts
The problem Is when I press enter the form submit. I tried to fix it by using wire:keydown.enter.stop but the problem is not...
Read more >
Disabling the Enter Key - OutSystems
Has anybody ever needed to disable the Enter key for one screen? ... I'm asking because some users are complaining that when they...
Read more >
Press Shift and Enter for a new line - HTML DOM
In some cases such as an inline editable element, or a messaging application, you would like to submit the data when user presses...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found