-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Feature: Clipboard #17820
Merged
Merged
Feature: Clipboard #17820
Conversation
This file contains 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
# Conflicts: # src/Umbraco.Web.UI.Client/src/packages/block/block/context/block-entries.context.ts
nielslyngsoe
approved these changes
Jan 16, 2025
This was referenced Jan 16, 2025
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.
Clipboard
Fixes: #16383
Fixes: #16898
The clipboard is a way to temporarily store property values that can later be pasted into other properties.
The first version of the Clipboard enables copying and pasting values between different block editors.
General Implementation
The clipboard is implemented like any other entity in the system with its own "clipboardEntry" entity type. The implementation includes repositories for data consumption (item, detail, collection) and a picker that makes it possible to interact with the clipboard in the same way as any other entity in the system. The main difference for the clipboard data is that it is stored in local storage instead of a server database. Doing it this way makes it possible for us to do a proper clipboard management UI following the same conventions as the rest of the codebase later.
The feature has a few "moving parts," including new extension points to aim for a flexible solution.
Copy/Pasting
The backbone of the feature is the Property Value copy and paste translators. These allow any property value to be translated into a more generic clipboard entry model when inserted into the clipboard and again translated from a generic clipboard entry model to any property value retrieved from the clipboard.
This PR introduces the first two clipboard entry value types:
When adding RTE support, we will also see a rteBlock/htmlBlock that includes the markup.
A Clipboard Entry will have a data model that looks like this. The example shows a value copied from a Block Grid:
Any Property Editor with a paste translator that can translate either a block or gridBlock value will be able to paste this entry.
Enabling the feature for a Property Editor
Depending on what kind of support you are looking for in a Property Editor there are different needs for manifests.
Clipboard Property Context
To enable an API with helpers to copy/paste property values including value translation register a Clipboard Property Action extension:
Property Context Manifest
The context will be available on any property with the given Property Editor UIs.
Property Actions:
The quickest way to implement the clipboard copy/paste actions is through property actions. The actions will copy the entire Property Value to the clipboard and replace the value when pasting. Sometimes this is not the UX you are looking for, and you might need to implement a custom button in your Property Editor UI. The Property Actions are using the above Clipboard Property Context, so any custom button implementation will be able to do the same without the need for a lot of clipboard logic.
Copy Property Action Manifest:
Paste Property Action Manifest:
With these enabled for a Property Editor UI the copy and paste Property Actions are available in the UI.
Copy/Paste Translators
Copy
To insert a value into the clipboard, you need a Property Value Copy translator. This ensures that your Property Value gets translated into a Clipboard Entry Value type. You can either copy as one of the already supported types, which will enable existing paste functionality to support pasting from your property editor, or create your own type:
Here is an example of a property editor copying to the block entry value type:
Manifest
Implementation
Paste
To paste a value from the clipboard, you need a Property Value Paste translator. This ensures that the clipboard entry value gets translated into your property value format.
Manifest
implementation
Complex Property Values:
For complex nested property values, we have also introduced a property value resolver concept to traverse the property value and a property value cloner concept to clone and update any parts of the value along the way - like uniques. If any of these are registered they will be included when pasting a value.
More in-depth descriptions will be added to the documentation.