diff --git a/package-lock.json b/package-lock.json index 3938f26..347adc7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lindsvg-pwa", - "version": "2.5.2", + "version": "2.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lindsvg-pwa", - "version": "2.5.2", + "version": "2.6.0", "dependencies": { "@vueuse/core": "^10.11.0", "lindsvg": "^1.5.0", diff --git a/package.json b/package.json index 31a215f..b1a4571 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lindsvg-pwa", "private": true, - "version": "2.5.2", + "version": "2.6.0", "type": "module", "scripts": { "lint": "eslint", diff --git a/src/components/PanelSharing.vue b/src/components/PanelSharing.vue index 4e9b96f..0864e3a 100644 --- a/src/components/PanelSharing.vue +++ b/src/components/PanelSharing.vue @@ -52,9 +52,14 @@ function launchShare() { } let copiedClassName = useCssModule().copied; -async function copyLSVG({target}) { - let text = JSON.stringify(lsvg.value, null, 2); - await navigator.clipboard.writeText(text); +async function copy(target, type) { + let content = type === "svg" ? lSystemStore.svgCode : JSON.stringify(lsvg.value); + let clipboardData = {"text/plain": new Blob([content], {type: "text/plain"})}; + if ((type === "svg") && ("supports" in ClipboardItem) && ClipboardItem.supports(svgBlob.value.type)) { + clipboardData[svgBlob.value.type] = svgBlob.value; + } + let clipboardItem = new ClipboardItem(clipboardData); + await navigator.clipboard.write([clipboardItem]); target.classList.add(copiedClassName); setTimeout(() => target.classList.remove(copiedClassName), 2000); } @@ -96,6 +101,23 @@ async function copyLSVG({target}) { SVG +