Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): global copy paste #6856

Merged
merged 96 commits into from
Jul 11, 2024
Merged

feat(core): global copy paste #6856

merged 96 commits into from
Jul 11, 2024

Conversation

sjelfull
Copy link
Member

@sjelfull sjelfull commented Jun 5, 2024

Description

This PR introduces global copy & pasting of fields and documents. You can copy and paste either through Ctrl-C/Ctrl-V when focused on a field, or by using the Field Action / Document Context Action menu (the one in the right corner, where Inspect and Review Changes.

CleanShot.2024-07-01.at.16.00.45.mp4

We have included a global keydown event listener that handles copy and paste events. They will not trigger if any of these is true:

  • focus is inside an input/textarea/contenteditable element - this to not interfere with native functionality / undo stack
  • you have an active selection (checking window.getSelection())
  • you haven't focused any inputs (the focus path is empty, aka [])

Keyboard shortcuts
The keyboard shortcuts is limited to these fields:

  • Arrays
  • Objects either on level 1 or deeper relative to the root - the root being either the document or inside a array.
  • Reference and Cross dataset reference previews

Field actions
Using fields actions you can copy and paste from any field that has a field action menu available. This currently excludes:

  • Booleans - they lack a FormField wrapper and field actions

What to review

  • Are we happy with the global event listener on Ctrl-C & Ctrl-V? We have added exceptions so that it should not interfere with any known scenarios

Testing

  • We have added unit tests for the utilities that resolves schema types based on the path you want to copy or paste, as well as validates source and target schema compatibility
  • We have also added E2E component tests, but there seems to be flake in these and other tests currently, so we can't trust them completely. We won't have time to resolve these until after the holidays, but we have done manual testing to make sure these are as solid as possible
  • There is link to the testing manuscript in the project channel where we list all the combinations of source -> target we have tried

Notes for release

  • Added copy and paste for individual fields in deeply nested structures

@sjelfull sjelfull requested a review from skogsmaskin June 5, 2024 12:08
@sjelfull sjelfull self-assigned this Jun 5, 2024
Copy link

vercel bot commented Jun 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2024 7:21pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2024 7:21pm
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2024 7:21pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2024 7:21pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 11, 2024 7:21pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jul 11, 2024 7:21pm

Copy link
Contributor

github-actions bot commented Jun 5, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented Jun 5, 2024

Component Testing Report Updated Jul 11, 2024 7:30 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 42s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 30s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 36s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 2m 33s 1 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 44s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 44s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 14s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 9s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 25s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 14s 21 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 1m 47s 30 0 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 19s 3 0 0

Copy link
Member

@cngonzalez cngonzalez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, all!!

@ricokahler ricokahler added this pull request to the merge queue Jul 11, 2024
Merged via the queue into next with commit 53aa46b Jul 11, 2024
39 of 41 checks passed
@ricokahler ricokahler deleted the feat/global-copy-paste branch July 11, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants