editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

Prevent click on redactor from inserting new block

Open cossssmin opened this issue 6 years ago • 7 comments

I have a situation where the codex-editor__redactor div is full width, and I center its contents (this is so that I can stretch contents to the edges of the screen).

However, when clicking 'outside' blocks (in order to blur the current selected block), I am basically still clicking on the redactor, which inserts an empty new block at the end.

How can I prevent editor.js from doing this? (without preventing clicks on the redactor - obviously)

cossssmin avatar Oct 30 '19 19:10 cossssmin

@cossssmin can you provide screenshots or video describing your case?

neSpecc avatar Dec 02 '19 09:12 neSpecc

Yes, here you go.

As you can see, depending on where I click outside (top half or bottom half of a block), it adds a new block at the top or bottom. This happens with any block, be it default or custom.

cossssmin avatar Dec 02 '19 12:12 cossssmin

Sorry, I still can not clearly understand the problem. Maybe you can provide steps to reproduce it using the example/example.html file so we can repeat it?

neSpecc avatar Dec 09 '19 06:12 neSpecc

Been a while, but I need to get back to this, so... 😊

Here's a more visual representation:

image

I've highlighted the ce-block element with a dark gray (centered), and the editor with a lighter gray (added lighter gray to codex-editor__redactor). The editor (lighter gray) goes from edge to edge in the browser (I have it at full width so I can do full width blocks).

If I click the lighter gray area - so, if I click the editor but outside of a block - a new empty (paragraph) block is added:

image

I wonder, could it be the stub mentioned in this function?

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

Because I do get this line in the console:

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

image

... so my understanding is that it fails to find a block type when I click the editor area, and it falls back to inserting an empty paragraph.

If this is the case, how can I prevent it from adding an empty paragraph like that, without modifying my editor's width?

cossssmin avatar Nov 04 '20 23:11 cossssmin

Hi @cossssmin, have you found a solution? tackling the same specific behavior on my project.

eyalcohen4 avatar Dec 13 '21 09:12 eyalcohen4

Any solution? I have a similar problem, when some block does not pass the check, the default block is added

waitstop avatar Sep 19 '24 12:09 waitstop

Any update?

jirisykora83 avatar Oct 14 '25 12:10 jirisykora83