Skip to content

Commit

Permalink
Make the code simpler using modern js
Browse files Browse the repository at this point in the history
Co-authored-by: Tomas Chmelevskij <[email protected]>
  • Loading branch information
McGiverGim and chmelevskij committed Apr 11, 2024
1 parent 4f77c85 commit 8786553
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/js/Clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,16 @@ Clipboard._configureClipboardAsWeb = function() {
this.writeText = function(text, onSuccess, onError) {

navigator.clipboard.writeText(text).then(
function() {
if (onSuccess) {
onSuccess(text);
}
}, function(err) {
if (onError) {
onError(err);
}
},
() => onSuccess?.(text),
onError,
);
};

this.readText = function(onSuccess, onError) {

navigator.clipboard.readText().then(
function(text) {
if (onSuccess) {
onSuccess(text);
}
}, function(err) {
if (onError) {
onError(err);
}
},
() => onSuccess?.(text),
onError,
);
};
};
Expand Down

0 comments on commit 8786553

Please sign in to comment.