mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Add fallback for demo "Copy Link" functionality on browsers that do not support navigator.clipboard.
This commit is contained in:
parent
678597485b
commit
214ecb5fb4
1 changed files with 5 additions and 2 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue