Skip to content

Commit

Permalink
Merge pull request #774 from tidalcycles/tauri-clipboard
Browse files Browse the repository at this point in the history
fix: share copy to clipboard + alert
  • Loading branch information
felixroos committed Nov 2, 2023
2 parents 1e5edfc + 8d3ba2a commit 9ec5d33
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 2 deletions.
91 changes: 91 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tauri-build = { version = "1.4.0", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.4.0", features = ["fs-all"] }
tauri = { version = "1.4.0", features = [ "dialog-all", "clipboard-write-text", "fs-all"] }
midir = "0.9.1"
tokio = { version = "1.29.0", features = ["full"] }
rosc = "0.10.1"
Expand Down
6 changes: 6 additions & 0 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
},
"tauri": {
"allowlist": {
"dialog": {
"all": true
},
"clipboard": {
"writeText": true
},
"all": false,
"fs": {
"all": true,
Expand Down
7 changes: 6 additions & 1 deletion website/src/repl/Repl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { settingPatterns } from '../settings.mjs';
import { code2hash, hash2code } from './helpers.mjs';
import { isTauri } from '../tauri.mjs';
import { useWidgets } from '@strudel.cycles/react/src/hooks/useWidgets.mjs';
import { writeText } from '@tauri-apps/api/clipboard';

const { latestCode } = settingsMap.get();

Expand Down Expand Up @@ -270,7 +271,11 @@ export function Repl({ embedded = false }) {
if (!error) {
setLastShared(activeCode || code);
// copy shareUrl to clipboard
await navigator.clipboard.writeText(shareUrl);
if (isTauri()) {
await writeText(shareUrl);
} else {
await navigator.clipboard.writeText(shareUrl);
}
const message = `Link copied to clipboard: ${shareUrl}`;
alert(message);
// alert(message);
Expand Down

0 comments on commit 9ec5d33

Please sign in to comment.