Implementation of Cell Copy/Paste Events Using Clipboard Events#3462
Closed
naoki-tateyama wants to merge 1 commit intoComcast:mainfrom
Closed
Implementation of Cell Copy/Paste Events Using Clipboard Events#3462naoki-tateyama wants to merge 1 commit intoComcast:mainfrom
naoki-tateyama wants to merge 1 commit intoComcast:mainfrom
Conversation
naoki-tateyama
commented
Feb 24, 2024
|
|
||
| ###### `onCopy?: Maybe<(args: CellCopyArgs<R>, event: CellClipboardEvent) => void>` | ||
|
|
||
| ###### `onPaste?: Maybe<(args: CellPasteArgs<R>, event: CellClipboardEvent) => R>` |
Author
There was a problem hiding this comment.
There are two things to consider.
- It might be more appropriate to name each handler
onCellCopy/onCellPaste onPastemight not need to returnR.
However, above changes will be breaking changes for some developers.
I leave them as they are without making any changes for now.
naoki-tateyama
commented
Feb 24, 2024
Comment on lines
+637
to
639
| if (cellEvent.isGridDefaultPrevented()) return; | ||
|
|
||
| updateRow(targetColumn, rowIdx, updatedTargetRow); |
Author
There was a problem hiding this comment.
if developers use event.preventGridDefault() in onPaste handler, the default behavior to update the row would be prevented.
Comment on lines
+607
to
609
| if (cellEvent.isGridDefaultPrevented()) return; | ||
|
|
||
| setCopiedCell({ row: sourceRow, columnKey: sourceColumnKey }); |
Author
There was a problem hiding this comment.
if developers use event.preventGridDefault() in onCopy handler, the default behavior to set the copied cell internally would be prevented.
|
Would love to see this feature added! |
Collaborator
|
Thank you for the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, maintainers!
This PR implements onCopy/onPaste events as Cell Clipboard Events not parts of keydown events.
Previously, copy and paste events were implemented as part of keydown events.
This could be slightly confusing for developers. For example,
preventGridDefaultmethod cannot be used to prevent the default onCopy behavior.With this PR, developers can now utilize Clipboard events, allowing for development with natural APIs without the need to use
navigator.clipboard.writeText.Additionally, by separating the processes that were aggregated under keydown events into onCopy and onPaste events, it is possible to reduce the complexity of the implementation.
I believe this feature is in high demand among many developers.
I hope you will consider it.
Related PRs
Related issues