-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Feature Request: beforeCopy Prop for Custom Clipboard Content
Summary:
When using the copy feature, allow developers to intercept and modify the copied content before it is sent to the clipboard, by introducing a beforeCopy function prop.
Motivation:
Currently, the copied value (copyText) is determined internally and cannot be changed by the consumer. In some cases, developers may want to format, sanitize, or otherwise modify the value before it is copied. Providing a hook/prop for this increases flexibility and control for library users.
Proposed API:
Add a new optional prop beforeCopy to the relevant component (e.g., <Copied /> or main JsonView), which receives the computed copyText and returns the new string to be copied. For example:
copyText = beforeCopy ? beforeCopy(copyText) : copyTextExample Usage:
<JsonView.Copied beforeCopy={(text) => text.replace(/\"/g, '')} />Benefits:
- Allows custom transformations on copied content
- Backwards compatible (default: no change)
- Simple implementation
Labels:
- enhancement
Metadata
Metadata
Assignees
Labels
No labels