prevent pasting svg copied from excalidraw (#1288)

* prevent pasting svg copied from excalidraw

* remove unnecessary template
This commit is contained in:
David Luzar 2020-04-06 23:02:17 +02:00 committed by GitHub
parent e9b4700bba
commit 729aeacc47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -1,6 +1,7 @@
import { ExcalidrawElement } from "./element/types";
import { getSelectedElements } from "./scene";
import { AppState } from "./types";
import { SVG_EXPORT_TAG } from "./scene/export";
let CLIPBOARD = "";
let PREFER_APP_CLIPBOARD = false;
@ -39,6 +40,10 @@ export async function copyToAppClipboard(
export function getAppClipboard(): {
elements?: readonly ExcalidrawElement[];
} {
if (!CLIPBOARD) {
return {};
}
try {
const clipboardElements = JSON.parse(CLIPBOARD);
@ -68,7 +73,7 @@ export async function getClipboardContent(
: probablySupportsClipboardReadText &&
(await navigator.clipboard.readText());
if (text && !PREFER_APP_CLIPBOARD) {
if (text && !PREFER_APP_CLIPBOARD && !text.includes(SVG_EXPORT_TAG)) {
return { text };
}
} catch (error) {