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);
}
+2 -2
View File
@@ -1,5 +1,5 @@
import { type Editor } from "@graphite/wasm-communication/editor";
import { TriggerVisitLink } from "@graphite/wasm-communication/messages";
import { type Editor } from "@graphite/editor";
import { TriggerVisitLink } from "@graphite/messages";
export function createHyperlinkManager(editor: Editor) {
// Subscribe to process backend event
+2 -2
View File
@@ -1,5 +1,7 @@
import { get } from "svelte/store";
import { type Editor } from "@graphite/editor";
import { TriggerPaste } from "@graphite/messages";
import { type DialogState } from "@graphite/state-providers/dialog";
import { type DocumentState } from "@graphite/state-providers/document";
import { type FullscreenState } from "@graphite/state-providers/fullscreen";
@@ -9,8 +11,6 @@ import { platformIsMac } from "@graphite/utility-functions/platform";
import { extractPixelData } from "@graphite/utility-functions/rasterization";
import { stripIndents } from "@graphite/utility-functions/strip-indents";
import { updateBoundsOfViewports } from "@graphite/utility-functions/viewports";
import { type Editor } from "@graphite/wasm-communication/editor";
import { TriggerPaste } from "@graphite/wasm-communication/messages";
type EventName = keyof HTMLElementEventMap | keyof WindowEventHandlersEventMap | "modifyinputfield";
type EventListenerTarget = {
+2 -2
View File
@@ -1,5 +1,5 @@
import { type Editor } from "@graphite/wasm-communication/editor";
import { TriggerAboutGraphiteLocalizedCommitDate } from "@graphite/wasm-communication/messages";
import { type Editor } from "@graphite/editor";
import { TriggerAboutGraphiteLocalizedCommitDate } from "@graphite/messages";
export function createLocalizationManager(editor: Editor) {
// Subscribe to process backend event
+2 -2
View File
@@ -1,8 +1,8 @@
import { type Editor } from "@graphite/editor";
import { DisplayDialogPanic } from "@graphite/messages";
import { type DialogState } from "@graphite/state-providers/dialog";
import { browserVersion, operatingSystem } from "@graphite/utility-functions/platform";
import { stripIndents } from "@graphite/utility-functions/strip-indents";
import { type Editor } from "@graphite/wasm-communication/editor";
import { DisplayDialogPanic } from "@graphite/wasm-communication/messages";
export function createPanicManager(editor: Editor, dialogState: DialogState) {
// Code panic dialog and console error
+2 -2
View File
@@ -1,9 +1,9 @@
import { createStore, del, get, set, update } from "idb-keyval";
import { get as getFromStore } from "svelte/store";
import { type Editor } from "@graphite/editor";
import { TriggerIndexedDbWriteDocument, TriggerIndexedDbRemoveDocument, TriggerSavePreferences, TriggerLoadAutoSaveDocuments, TriggerLoadPreferences } from "@graphite/messages";
import { type PortfolioState } from "@graphite/state-providers/portfolio";
import { type Editor } from "@graphite/wasm-communication/editor";
import { TriggerIndexedDbWriteDocument, TriggerIndexedDbRemoveDocument, TriggerSavePreferences, TriggerLoadAutoSaveDocuments, TriggerLoadPreferences } from "@graphite/wasm-communication/messages";
const graphiteStore = createStore("graphite", "store");