heynote icon indicating copy to clipboard operation
heynote copied to clipboard

Cell corruption when deleting block contents

Open JMSS-Unknown opened this issue 8 months ago • 3 comments

Selecting the contents of an entire block and pressing CTRL + SHIFT + K (on windows) causes the block separator and language type (e.g. ∞∞∞markdown) to become text inside the next block and the next block's type becomes the previous block's type. See the following video:

https://github.com/heyman/heynote/assets/31131631/1d50b926-a780-4a75-9b0c-0d7fa905348b

JMSS-Unknown avatar Dec 23 '23 01:12 JMSS-Unknown

Thanks for the report!

Note: Cmd + Shift + K causes the same bug on MacOS

heyman avatar Dec 23 '23 11:12 heyman

As I analyzed the issue, the bug doesn't occur when deleting the first block, but it arises when attempting to delete the second block. The reason it doesn't happen when deleting the first block is that 'block.js' contains a function called preventFirstBlockFromBeingDeleted that prevents this bug. If my understanding is correct, should we extend this solution to the remaining blocks or concentrate on improving how the editor handles Ctrl+Shift+K in keymaps?

@heyman, could you please guide me on resolving this issue?

Maran1947 avatar Jan 01 '24 16:01 Maran1947

Hey, saw your description of the problem a few days before and tried to implement your other solution as well. Didnt see you already had solved it lol. #118

feh-pined0 avatar Jan 03 '24 14:01 feh-pined0

Codemirror bindsCtrl/Cmd-Shift-K to deleteLine which will result in broken block syntax when performed either in a block with just a single line, or when all of the content of a block is selected.

I think the proper solution is to implement a custom deleteLine that is block-aware (running deleteLine on a single-line block, should probably just remove the whole block).

heyman avatar Jan 04 '24 14:01 heyman

hmm, @Maran1947 maybe adjust your commit then...? Since it's the closest to the desired solution, i think it would be easier that way.

feh-pined0 avatar Jan 04 '24 15:01 feh-pined0

#134 In this PR, is this the correct way?

Maran1947 avatar Jan 05 '24 13:01 Maran1947

As far as I can tell, #134 deletes a whole block and is not a block-aware equivalent to the deleteLine command in Codemirror.

heyman avatar Jan 07 '24 16:01 heyman

I've updated PR #134. I checked CodeMirror's deleteLine implementation and added a condition to fix the problem. Could you please check if this is correct or suggest any improvements?

Maran1947 avatar Jan 07 '24 18:01 Maran1947