Closed nicolapagni closed 4 years ago
Hello @nicolapagni , I encountered the same issue working with the new delete
feature.
After digging into the code, I found that after deleting a block this line is called : this.Editor.Caret.setToBlock(this.Editor.BlockManager.currentBlock, this.Editor.Caret.positions.END);
It's supposed to move the cursor focus after the current block. The issue is that this.Editor.BlockManager.currentBlock
is undefined
. In my case I'm not really surprised because I am adding/removing blocks without the need to interact with the editor manually.
2 options I see to fix this issue :
this.Editor.BlockManager.currentBlock
existselse
condition that moves the cursor after the last block using this.Editor.Caret.setToBlock(this.Editor.BlockManager.lastBlock, this.Editor.Caret.positions.END);
I can submit a PR with those changes any time but I would love some feedbacks from maintainers or other users ✌️
@nicolapagni We followed the steps as you have mentioned but we couldn't able to reproduce the issue. Can you provide any further details regarding this issue, maybe a GIF or a sall video to show the exact process of reproducing the issue?
@ranemihir I reproduce the issue with those steps :
editorInstance.blocks.delete(1)
(I use a button next to the editor to delete a specific blocks)
Note that any valid index triggers the error, an invalid or missing id triggers a simple warning@stephenrichard Thank you for your help. I was able to reproduce the issue.
Resolved by #1218
I've installed the v2.18 to try the new feature about deleting specific block by index. I can notice that now I see a warning if I try to delete a block by an invalid index..ok, but now I see this error:
Instead, if I try to delete though the same code the firt element It seems work fine..
Cannot read property 'lastInput' of undefined
Steps to reproduce:this.api.blocks.getBlockByIndex(1);
Expected behavior: The block should be removed.
Screenshots:
main.js is the file where I call the delete function.
Device, Browser, OS: Chrome v83.0.4103.61, Windows 10
Editor.js version: 2.18