Skip to content

Commit

Permalink
fix: catch navigator clipboard error
Browse files Browse the repository at this point in the history
  • Loading branch information
petersolopov committed Jun 12, 2020
1 parent ec05d8d commit 5a2d029
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/plugins/cutLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const cutLine = (predicate) => (acc, event) => {
const newValue =
value.substring(0, selectionStart) + value.substring(selectionEnd);

navigator.clipboard.writeText(
value.substring(selectionStart, selectionEnd)
);
navigator.clipboard
.writeText(value.substring(selectionStart, selectionEnd))
.catch(() => {}); // prevent any clipboard error. useful for iframe

return {
value: newValue,
Expand Down Expand Up @@ -41,7 +41,9 @@ const cutLine = (predicate) => (acc, event) => {
.filter((line) => line != null)
.join("\n");

navigator.clipboard.writeText(value.split("\n")[currentLineNumber]);
navigator.clipboard
.writeText(value.split("\n")[currentLineNumber])
.catch(() => {}); // prevent any clipboard error. useful for iframe

return {
value: newValue,
Expand Down

0 comments on commit 5a2d029

Please sign in to comment.