Remove blob URL dead code and clean up more frontend code (#2199)

This commit is contained in:
Keavon Chambers
2025-01-14 13:08:47 -08:00
committed by GitHub
parent 1e62af88cd
commit 9ad6c31483
56 changed files with 107 additions and 247 deletions
+2 -20
View File
@@ -1,6 +1,5 @@
import { imageToPNG } from "@graphite/utility-functions/rasterization";
import { type Editor } from "@graphite/wasm-communication/editor";
import { TriggerTextCopy } from "@graphite/wasm-communication/messages";
import { type Editor } from "@graphite/editor";
import { TriggerTextCopy } from "@graphite/messages";
export function createClipboardManager(editor: Editor) {
// Subscribe to process backend event
@@ -9,20 +8,3 @@ export function createClipboardManager(editor: Editor) {
navigator.clipboard?.writeText?.(triggerTextCopy.copyText);
});
}
export async function copyToClipboardFileURL(url: string) {
const response = await fetch(url);
const blob = await response.blob();
// TODO: Remove this if/when we end up returning PNG directly from the backend
const pngBlob = await imageToPNG(blob);
const clipboardItem: Record<string, Blob> = {};
clipboardItem[pngBlob.type] = pngBlob;
const data = [new ClipboardItem(clipboardItem)];
// Note: if this image has transparency, it will be lost and appear as black due to limitations of the way browsers handle copying transparent images
// This even happens if you just open a regular transparent PNG file in a browser tab, right click > copy, and paste it somewhere (the transparency will show up as black)
// This is true, at least, on Windows (it's worth checking on other OSs though)
navigator.clipboard.write(data);
}