Skip to content

Commit

Permalink
docs: ✏️ changelog update
Browse files Browse the repository at this point in the history
fix: 🐛  copy on file browser
  • Loading branch information
charlzyx committed Mar 7, 2024
1 parent fde0226 commit f9139d8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
## v2.0.1...v2.0.0

[compare changes](https://github.com/charlzyx/bunpkg/compare/v2.0.1...v2.0.0)

### 🩹 Fixes

- 🐛 webpage copy feature ([08ab261](https://github.com/charlzyx/bunpkg/commit/08ab261))

### ❤️ Contributors

- Charlzyx <[email protected]>

## v2.0.0...v1.1.1

[compare changes](https://github.com/charlzyx/bunpkg/compare/v2.0.0...v1.1.1)

### 🔥 Performance

- ⚡️ perfermance, cached visit 100x faster! ([b5c39c5](https://github.com/charlzyx/bunpkg/commit/b5c39c5))

### 🚀 Enhancements

- 🎸 replace http tgz by Bun.gunzipSync, faster! ([3dd9743](https://github.com/charlzyx/bunpkg/commit/3dd9743))
- 🎸 file browser ([2d44710](https://github.com/charlzyx/bunpkg/commit/2d44710))

### 🩹 Fixes

- 🐛 missing docs build, and docs update ([16198f3](https://github.com/charlzyx/bunpkg/commit/16198f3))
- 🐛 cors origin config fix ([663e3b3](https://github.com/charlzyx/bunpkg/commit/663e3b3))

### 💅 Refactors
Expand Down
25 changes: 24 additions & 1 deletion docs/components/MetaBrowser/FilesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,31 @@ import { Icons } from "../Icons";
import toast, { Toaster } from "react-hot-toast";
import { Flex } from "../Flex";

// https://stackoverflow.com/questions/51805395/navigator-clipboard-is-undefined
const copy = (text: string) => {
navigator.clipboard.writeText(text);
// Navigator clipboard api needs a secure context (https)
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(text);
} else {
// Use the 'out of viewport hidden text area' trick
const textArea = document.createElement("textarea");
textArea.value = text;

// Move textarea out of the viewport so it's not visible
textArea.style.position = "absolute";
textArea.style.left = "-999999px";

document.body.prepend(textArea);
textArea.select();

try {
document.execCommand("copy");
} catch (error) {
console.error(error);
} finally {
textArea.remove();
}
}
};

const useLinks = (link: string) => {
Expand Down

0 comments on commit f9139d8

Please sign in to comment.