cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x] Ability to cut/copy/paste replicator sets

Open jacksleight opened this issue 1 year ago • 0 comments

This PR adds the ability to cut/copy/paste sets between different replicators/pages/tabs:

https://github.com/user-attachments/assets/1b76411a-5df7-4c6d-b2a0-34bb171c26c1

Notes

  • Replicators use a list of set config hashes to decide whether the set being copied is compatible with the target replicator.
  • Due to its limitations this does not use the Clipboard API. Instead, within the current page the data is stored in a vue component (for reactivity), and local storage is used to persist it between pages/tabs (session storage isn’t suitable as it doesn’t work between tabs).
  • Since local storage has no expiry but you don’t want copied values hanging around forever a unique ID stored in a session cookie is attached to the data, so it can be cleared when a new session is started.
  • There's a new $clipboard object that takes care of all the data storage and tracking, this means it should be fairly straightforward to add the same feature to other fieldtypes in the future (if wanted).
  • I don't really like the fact that the paste buttons hang around (and have taken the steps above to ensure they don't stay there forever). It wouldn't make sense to clear the data on paste since you might want to paste multiple times. Maybe the paste option shouldn't be a button at all, it could be in the https://github.com/statamic/cms/pull/10352 menu. That would also simplify adding the same feature to other fieldtypes since there's no longer any replicator specific UI.
  • If the button does stay it needs a better icon, hopefully there's a good one in the streamline set.
  • I would like to add Cut/Copy All Sets options, but I'm going to wait for https://github.com/statamic/cms/pull/10352 before looking at that.

Other Changes

This PR includes the same "Other Changes" as https://github.com/statamic/cms/pull/10361, since they're related and using the same hashes.

Closes https://github.com/statamic/ideas/issues/748

jacksleight avatar Jun 24 '24 14:06 jacksleight