From 214ecb5fb4853ced8e6fcfce9be3d62a423e9a8b Mon Sep 17 00:00:00 2001 From: David Anson Date: Thu, 9 Apr 2020 20:35:32 -0700 Subject: [PATCH] Add fallback for demo "Copy Link" functionality on browsers that do not support navigator.clipboard. --- demo/default.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/demo/default.js b/demo/default.js index 7abed3fe..ff9ed192 100644 --- a/demo/default.js +++ b/demo/default.js @@ -143,9 +143,12 @@ // Updates the URL hash and copies the URL to the clipboard function onCopyLinkClick(e) { window.location.hash = encodeURIComponent(hashPrefix + markdown.value); - /* eslint-disable-next-line no-unused-expressions */ - navigator.clipboard && navigator.clipboard.writeText && + if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard.writeText(window.location).then(noop, noop); + } else { + /* eslint-disable-next-line no-alert */ + alert("Document URL updated, select and copy it now."); + } e.preventDefault(); }