fix(paste): replace selected blocks on pasting#1996
fix(paste): replace selected blocks on pasting#1996kaaaaaaaaaaai wants to merge 22 commits intocodex-team:nextfrom
Conversation
|
hello, anybody here? |
|
@kaaaaaaaaaaai, Thanks for creating the PR for the issue and sorry for the late response. |
| BlockManager.setCurrentBlockByChildNode(block.holder); | ||
| BlockManager.currentBlock.currentInput = element; | ||
|
|
||
| return new Promise<void>((resolve) => { |
There was a problem hiding this comment.
why do we need the delay and the Promise?
There was a problem hiding this comment.
this moment still looks like a not ideal solution. Please, describe the problem you are solving
|
@robonetphy @neSpecc i try! I'll do my best to contribute! |
| BlockManager.setCurrentBlockByChildNode(block.holder); | ||
| BlockManager.currentBlock.currentInput = element; | ||
|
|
||
| return new Promise<void>((resolve) => { |
There was a problem hiding this comment.
this moment still looks like a not ideal solution. Please, describe the problem you are solving
| */ | ||
| private setCallback(): void { | ||
| this.listeners.on(this.Editor.UI.nodes.holder, 'paste', this.handlePasteEvent); | ||
| this.listeners.on(document, 'paste', this.handlePasteEvent); |
There was a problem hiding this comment.
Have you tested pasting on a page that has several editor instances? You can test on the example-multiple.html page
There was a problem hiding this comment.
Yup it's not working but then we need to think about it
|
@neSpecc about the promise we added into the
|
|
That's right! That's what I wanted to say :))))) |
| if (!BlockSelection.anyBlockSelected) { | ||
| return; |
There was a problem hiding this comment.
seems like the previous behavior is disabled at all.
| /** | ||
| * process multi-block selection paste. | ||
| */ | ||
| dataTransfer = await this.processMultiBlockSelection(dataTransfer); |
There was a problem hiding this comment.
anyBlockSelected does not guarantee that there are several blocks. There could be the single block selected.
| const { BlockManager, Caret } = this.Editor; | ||
|
|
||
| /** Remove all the selected blocks */ | ||
| const nextBlockIndex = BlockManager.removeSelectedBlocks(); |
There was a problem hiding this comment.
i think it should be somewhere inside processDataTransfer
| /** Create copy of the clipboard since new default block insertion change the event.*/ | ||
| const clipboard = _.copyClipboard(dataTransfer); |
There was a problem hiding this comment.
it is not clear. how adding a new block affects data in a clipboard?
|
Lack of tests |
Resolves #1705
I always use products. And I was stressed about this issue, so I tried a fix. And I'm here to discuss solutions.
Maybe a caret issue...? and it did not work without
_deleyIf you think you can figure out the cause, please let me know and I will fix it.
Tasks