fix: cannot copy to clipboard in http or untrused https host(except localhost) (#6744)
What does this PR do?
Fixes # (issue)
https://github.com/langfuse/langfuse/issues/6744
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Chore (refactoring code, technical debt, workflow improvements)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Refactor (does not change functionality, e.g. code style improvements, linting)
- [ ] This change requires a documentation update
Mandatory Tasks
- [x] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.
Checklist
- I haven't read the contributing guide
- My code doesn't follow the style guidelines of this project (
npm run prettier) - I haven't commented my code, particularly in hard-to-understand areas
- I haven't checked if my PR needs changes to the documentation
- I haven't checked if my changes generate no new warnings (
npm run lint) - I haven't added tests that prove my fix is effective or that my feature works
- I haven't checked if new and existing unit tests pass locally with my changes
[!IMPORTANT] Fixes clipboard copy issue in non-secure contexts by introducing a fallback method in
copyToClipboardand updating multiple components to use it.
- Behavior:
- Fixes clipboard copy issue in non-secure contexts by introducing
copyToClipboardinclipboard.ts.- Replaces
navigator.clipboard.writeTextwithcopyToClipboardinpublish-object-switch.tsx,useViewMutations.ts,CopyIdsPopover.tsx,CodeJsonViewer.tsx,Codeblock.tsx,MarkdownViewer.tsx,GenerationOutput.tsx, andPromptSelectionDialog.tsx.- Dependencies:
- Adds
copy-to-clipboardpackage topackage.json.This description was created by
for 5b9adecf42bd0c5186b039b768d7c4aafbf2b653. You can customize this summary. It will automatically update as commits are pushed.
also upgrade react18-json-view version, to active similar funcions in newer version of that repo. see: https://github.com/YYsuni/react18-json-view/commit/0bb956ed7e5fe55053c7abd81bc75f27965c4152
Thanks so much for your contribution @XenoAmess! However, as we prefer to not include new dependencies and this branch was put up before, we accepted this contribution instead. Happy to mention you in release notes regardless if this is something you'd like? Many thanks.