From 466c9bc796196ade8d852116abe057038c329bcb Mon Sep 17 00:00:00 2001 From: Tims777 Date: Mon, 23 Sep 2024 16:48:34 +0200 Subject: [PATCH] Remove Excalidraw+ integrations --- excalidraw-app/App.tsx | 112 --------------- excalidraw-app/app_constants.ts | 4 - excalidraw-app/components/AppFooter.tsx | 8 +- excalidraw-app/components/AppMainMenu.tsx | 25 +--- .../components/AppWelcomeScreen.tsx | 39 +---- .../components/ExcalidrawPlusAppLink.tsx | 19 --- .../components/ExportToExcalidrawPlus.tsx | 134 ------------------ 7 files changed, 3 insertions(+), 338 deletions(-) delete mode 100644 excalidraw-app/components/ExcalidrawPlusAppLink.tsx delete mode 100644 excalidraw-app/components/ExportToExcalidrawPlus.tsx diff --git a/excalidraw-app/App.tsx b/excalidraw-app/App.tsx index 9b7eadff..438f86a3 100644 --- a/excalidraw-app/App.tsx +++ b/excalidraw-app/App.tsx @@ -45,7 +45,6 @@ import { } from "../packages/excalidraw/utils"; import { FIREBASE_STORAGE_PREFIXES, - isExcalidrawPlusSignedUser, STORAGE_KEYS, SYNC_BROWSER_TABS_TIMEOUT, } from "./app_constants"; @@ -68,10 +67,6 @@ import { import CustomStats from "./CustomStats"; import type { RestoredDataState } from "../packages/excalidraw/data/restore"; import { restore, restoreAppState } from "../packages/excalidraw/data/restore"; -import { - ExportToExcalidrawPlus, - exportToExcalidrawPlus, -} from "./components/ExportToExcalidrawPlus"; import { updateStaleImageStatuses } from "./data/FileManager"; import { newElementWith } from "../packages/excalidraw/element/mutateElement"; import { isInitializedImageElement } from "../packages/excalidraw/element/typeChecks"; @@ -111,9 +106,7 @@ import { GithubIcon, XBrandIcon, DiscordIcon, - ExcalLogo, usersIcon, - exportToPlus, share, youtubeIcon, } from "../packages/excalidraw/components/icons"; @@ -741,45 +734,6 @@ const ExcalidrawWrapper = () => { ); } - const ExcalidrawPlusCommand = { - label: "Excalidraw+", - category: DEFAULT_CATEGORIES.links, - predicate: true, - icon:
{ExcalLogo}
, - keywords: ["plus", "cloud", "server"], - perform: () => { - window.open( - `${ - import.meta.env.VITE_APP_PLUS_LP - }/plus?utm_source=excalidraw&utm_medium=app&utm_content=command_palette`, - "_blank", - ); - }, - }; - const ExcalidrawPlusAppCommand = { - label: "Sign up", - category: DEFAULT_CATEGORIES.links, - predicate: true, - icon:
{ExcalLogo}
, - keywords: [ - "excalidraw", - "plus", - "cloud", - "server", - "signin", - "login", - "signup", - ], - perform: () => { - window.open( - `${ - import.meta.env.VITE_APP_PLUS_APP - }?utm_source=excalidraw&utm_medium=app&utm_content=command_palette`, - "_blank", - ); - }, - }; - return (
{ toggleTheme: true, export: { onExportToBackend, - renderCustomUI: excalidrawAPI - ? (elements, appState, files) => { - return ( - { - excalidrawAPI?.updateScene({ - appState: { - errorMessage: error.message, - }, - }); - }} - onSuccess={() => { - excalidrawAPI.updateScene({ - appState: { openDialog: null }, - }); - }} - /> - ); - } - : undefined, }, }, }} @@ -863,22 +793,6 @@ const ExcalidrawWrapper = () => { - {excalidrawAPI && ( - { - exportToExcalidrawPlus( - excalidrawAPI.getSceneElements(), - excalidrawAPI.getAppState(), - excalidrawAPI.getFiles(), - excalidrawAPI.getName(), - ); - }} - > - {t("overwriteConfirm.action.excalidrawPlus.description")} - - )} excalidrawAPI?.refresh()} /> {excalidrawAPI && } @@ -1061,32 +975,6 @@ const ExcalidrawWrapper = () => { ); }, }, - ...(isExcalidrawPlusSignedUser - ? [ - { - ...ExcalidrawPlusAppCommand, - label: "Sign in / Go to Excalidraw+", - }, - ] - : [ExcalidrawPlusCommand, ExcalidrawPlusAppCommand]), - - { - label: t("overwriteConfirm.action.excalidrawPlus.button"), - category: DEFAULT_CATEGORIES.export, - icon: exportToPlus, - predicate: true, - keywords: ["plus", "export", "save", "backup"], - perform: () => { - if (excalidrawAPI) { - exportToExcalidrawPlus( - excalidrawAPI.getSceneElements(), - excalidrawAPI.getAppState(), - excalidrawAPI.getFiles(), - excalidrawAPI.getName(), - ); - } - }, - }, { ...CommandPalette.defaultItems.toggleTheme, perform: () => { diff --git a/excalidraw-app/app_constants.ts b/excalidraw-app/app_constants.ts index 1dc6c6f4..c73c5ee8 100644 --- a/excalidraw-app/app_constants.ts +++ b/excalidraw-app/app_constants.ts @@ -53,7 +53,3 @@ export const STORAGE_KEYS = { export const COOKIES = { AUTH_STATE_COOKIE: "excplus-auth", } as const; - -export const isExcalidrawPlusSignedUser = document.cookie.includes( - COOKIES.AUTH_STATE_COOKIE, -); diff --git a/excalidraw-app/components/AppFooter.tsx b/excalidraw-app/components/AppFooter.tsx index ea8152a2..d74321bd 100644 --- a/excalidraw-app/components/AppFooter.tsx +++ b/excalidraw-app/components/AppFooter.tsx @@ -1,8 +1,6 @@ import React from "react"; import { Footer } from "../../packages/excalidraw/index"; import { EncryptedIcon } from "./EncryptedIcon"; -import { ExcalidrawPlusAppLink } from "./ExcalidrawPlusAppLink"; -import { isExcalidrawPlusSignedUser } from "../app_constants"; import { DebugFooter, isVisualDebuggerEnabled } from "./DebugCanvas"; export const AppFooter = React.memo( @@ -17,11 +15,7 @@ export const AppFooter = React.memo( }} > {isVisualDebuggerEnabled() && } - {isExcalidrawPlusSignedUser ? ( - - ) : ( - - )} +
); diff --git a/excalidraw-app/components/AppMainMenu.tsx b/excalidraw-app/components/AppMainMenu.tsx index fd8d779a..a5e64a4c 100644 --- a/excalidraw-app/components/AppMainMenu.tsx +++ b/excalidraw-app/components/AppMainMenu.tsx @@ -1,12 +1,7 @@ import React from "react"; -import { - loginIcon, - ExcalLogo, - eyeIcon, -} from "../../packages/excalidraw/components/icons"; +import { eyeIcon } from "../../packages/excalidraw/components/icons"; import type { Theme } from "../../packages/excalidraw/element/types"; import { MainMenu } from "../../packages/excalidraw/index"; -import { isExcalidrawPlusSignedUser } from "../app_constants"; import { LanguageList } from "../app-language/LanguageList"; import { saveDebugState } from "./DebugCanvas"; @@ -35,25 +30,7 @@ export const AppMainMenu: React.FC<{ - - Excalidraw+ - - - {isExcalidrawPlusSignedUser ? "Sign in" : "Sign up"} - {import.meta.env.DEV && ( any; isCollabEnabled: boolean; }> = React.memo((props) => { const { t } = useI18n(); - let headingContent; - - if (isExcalidrawPlusSignedUser) { - headingContent = t("welcomeScreen.app.center_heading_plus") - .split(/(Excalidraw\+)/) - .map((bit, idx) => { - if (bit === "Excalidraw+") { - return ( - - Excalidraw+ - - ); - } - return bit; - }); - } else { - headingContent = t("welcomeScreen.app.center_heading"); - } + const headingContent = t("welcomeScreen.app.center_heading"); return ( @@ -55,17 +29,6 @@ export const AppWelcomeScreen: React.FC<{ onSelect={() => props.onCollabDialogOpen()} /> )} - {!isExcalidrawPlusSignedUser && ( - - Sign up - - )} diff --git a/excalidraw-app/components/ExcalidrawPlusAppLink.tsx b/excalidraw-app/components/ExcalidrawPlusAppLink.tsx deleted file mode 100644 index 76be9a8f..00000000 --- a/excalidraw-app/components/ExcalidrawPlusAppLink.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { isExcalidrawPlusSignedUser } from "../app_constants"; - -export const ExcalidrawPlusAppLink = () => { - if (!isExcalidrawPlusSignedUser) { - return null; - } - return ( - - Go to Excalidraw+ - - ); -}; diff --git a/excalidraw-app/components/ExportToExcalidrawPlus.tsx b/excalidraw-app/components/ExportToExcalidrawPlus.tsx deleted file mode 100644 index 1ba82a0c..00000000 --- a/excalidraw-app/components/ExportToExcalidrawPlus.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import React from "react"; -import { Card } from "../../packages/excalidraw/components/Card"; -import { ToolButton } from "../../packages/excalidraw/components/ToolButton"; -import { serializeAsJSON } from "../../packages/excalidraw/data/json"; -import { loadFirebaseStorage, saveFilesToFirebase } from "../data/firebase"; -import type { - FileId, - NonDeletedExcalidrawElement, -} from "../../packages/excalidraw/element/types"; -import type { - AppState, - BinaryFileData, - BinaryFiles, -} from "../../packages/excalidraw/types"; -import { nanoid } from "nanoid"; -import { useI18n } from "../../packages/excalidraw/i18n"; -import { - encryptData, - generateEncryptionKey, -} from "../../packages/excalidraw/data/encryption"; -import { isInitializedImageElement } from "../../packages/excalidraw/element/typeChecks"; -import { FILE_UPLOAD_MAX_BYTES } from "../app_constants"; -import { encodeFilesForUpload } from "../data/FileManager"; -import { MIME_TYPES } from "../../packages/excalidraw/constants"; -import { trackEvent } from "../../packages/excalidraw/analytics"; -import { getFrame } from "../../packages/excalidraw/utils"; -import { ExcalidrawLogo } from "../../packages/excalidraw/components/ExcalidrawLogo"; - -export const exportToExcalidrawPlus = async ( - elements: readonly NonDeletedExcalidrawElement[], - appState: Partial, - files: BinaryFiles, - name: string, -) => { - const firebase = await loadFirebaseStorage(); - - const id = `${nanoid(12)}`; - - const encryptionKey = (await generateEncryptionKey())!; - const encryptedData = await encryptData( - encryptionKey, - serializeAsJSON(elements, appState, files, "database"), - ); - - const blob = new Blob( - [encryptedData.iv, new Uint8Array(encryptedData.encryptedBuffer)], - { - type: MIME_TYPES.binary, - }, - ); - - await firebase - .storage() - .ref(`/migrations/scenes/${id}`) - .put(blob, { - customMetadata: { - data: JSON.stringify({ version: 2, name }), - created: Date.now().toString(), - }, - }); - - const filesMap = new Map(); - for (const element of elements) { - if (isInitializedImageElement(element) && files[element.fileId]) { - filesMap.set(element.fileId, files[element.fileId]); - } - } - - if (filesMap.size) { - const filesToUpload = await encodeFilesForUpload({ - files: filesMap, - encryptionKey, - maxBytes: FILE_UPLOAD_MAX_BYTES, - }); - - await saveFilesToFirebase({ - prefix: `/migrations/files/scenes/${id}`, - files: filesToUpload, - }); - } - - window.open( - `${ - import.meta.env.VITE_APP_PLUS_APP - }/import?excalidraw=${id},${encryptionKey}`, - ); -}; - -export const ExportToExcalidrawPlus: React.FC<{ - elements: readonly NonDeletedExcalidrawElement[]; - appState: Partial; - files: BinaryFiles; - name: string; - onError: (error: Error) => void; - onSuccess: () => void; -}> = ({ elements, appState, files, name, onError, onSuccess }) => { - const { t } = useI18n(); - return ( - -
- -
-

Excalidraw+

-
- {t("exportDialog.excalidrawplus_description")} -
- { - try { - trackEvent("export", "eplus", `ui (${getFrame()})`); - await exportToExcalidrawPlus(elements, appState, files, name); - onSuccess(); - } catch (error: any) { - console.error(error); - if (error.name !== "AbortError") { - onError(new Error(t("exportDialog.excalidrawplus_exportError"))); - } - } - }} - /> -
- ); -};