mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[windows copy link fix]
This commit is contained in:
1 parent
484eca5548
commit
935bde4bba
1 file changed
+26
-6
@@ -1,7 +1,13 @@
|
|||||||
import { useToast } from 'vue-toast-notification';
|
import { useToast } from 'vue-toast-notification';
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
window.toast = toast
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
toast: typeof toast;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.toast = toast;
|
||||||
|
|
||||||
export function detectOS() {
|
export function detectOS() {
|
||||||
const platform = window.navigator.platform
|
const platform = window.navigator.platform
|
||||||
@@ -18,7 +24,7 @@ export function detectOS() {
|
|||||||
|
|
||||||
export function prepareHTMLDescription(description) {
|
export function prepareHTMLDescription(description) {
|
||||||
if (!description) return description
|
if (!description) return description
|
||||||
|
|
||||||
const os = detectOS()
|
const os = detectOS()
|
||||||
|
|
||||||
// make an array from the description of strings from between <p> and </p> tags
|
// make an array from the description of strings from between <p> and </p> tags
|
||||||
@@ -57,10 +63,24 @@ export function prepareHTMLDescription(description) {
|
|||||||
|
|
||||||
function getCopyFunction(text) {
|
function getCopyFunction(text) {
|
||||||
return `
|
return `
|
||||||
navigator.clipboard.writeText('${text}').then(() => {
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
|
navigator.clipboard.writeText('${text}').then(() => {
|
||||||
|
window.toast.success('Link copied to clipboard!')
|
||||||
|
}).catch(err => {
|
||||||
|
window.toast.error('Failed to copy link to clipboard!')
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const input = document.createElement('input');
|
||||||
|
input.style.position = 'fixed';
|
||||||
|
input.style.opacity = 0;
|
||||||
|
input.style.pointerEvents = 'none';
|
||||||
|
input.value = '\\\\${text}';
|
||||||
|
document.body.appendChild(input);
|
||||||
|
input.select();
|
||||||
|
input.focus();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(input);
|
||||||
window.toast.success('Link copied to clipboard!')
|
window.toast.success('Link copied to clipboard!')
|
||||||
}).catch(err => {
|
}
|
||||||
window.toast.error('Failed to copy link to clipboard!')
|
|
||||||
});
|
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user