Editor.js: Feature Request (Tool-Setting): add option to not delete selected block on backspace or enter keydown

Created on 1 Apr 2020  路  2Comments  路  Source: codex-team/editor.js

Scenario

A block's tool setting opens a modal (or any other new view outside of editorjs). Whenever the user hits backspace _or_ enter in the new view though, the block - which is still selected (.ce-block--selected) - gets deleted.

There is currently _no way_ to remove the selection from the block, when a tune was toggled/clicked.

Example

Screen Capture on 2020-04-01 at 16-40-17

Example Codepen

https://codepen.io/natterstefan/pen/PoqLVJr?editors=0110

Research

There is a enableLineBreaks setting, managing how blocks behave when enter is pressed. In the example it still looks like this is not working properly.

https://github.com/codex-team/editor.js/blob/be6f9b78f265c3d553c799c99e59c9916bf29e17/src/components/modules/blockEvents.ts#L257-L263

Same goes for backspace, but here we never reach this part of the code:

https://github.com/codex-team/editor.js/blob/be6f9b78f265c3d553c799c99e59c9916bf29e17/src/components/modules/blockEvents.ts#L353-L361

Because the block is still selected and results to true in this if.

Feature request

Enable developers to unselect a block when a tune was toggled. Means, a new method is added to the blocks API (https://editorjs.io/api#blocks).

Current Workaround (not 100% tested tough)

When the toggle is clicked, we remove the selected class from the block. This should help us to pass the if`s in the keydown handlers.

But this is kinda hacky IMHO.

Additional questions

(Possible) related Issues

viewed

Most helpful comment

Hi @m-alzam,
Wouldn't you mind if I assign you to this issue?

All 2 comments

Hi,

I'm having the same problem with an input element inside the block settings. I can't press the backspace key while editing it or the whole block get removed. As a proposal, there's not documentation available for how to manage other types of inputs (apart of buttons) in the block settings. Simple blocks doesn't require it, but more complex ones requires that type of settings.

This can be considered as a bug, because while block settings is opened we usually don't might want to remove the block.

Regards

Hi @m-alzam,
Wouldn't you mind if I assign you to this issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

neSpecc picture neSpecc  路  4Comments

Someskumarasamy picture Someskumarasamy  路  4Comments

oknoorap picture oknoorap  路  4Comments

talyguryn picture talyguryn  路  3Comments

vincentdesmares picture vincentdesmares  路  3Comments