From ffbd4a5dc8e39c0185464fce1b634992bdcb7bc1 Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Fri, 9 May 2025 16:00:49 +1000 Subject: [PATCH] lint --- excalidraw-app/App.tsx | 31 +++++++++---------- packages/excalidraw/components/App.tsx | 11 ++++--- .../excalidraw/scene/scrollConstraints.ts | 6 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/excalidraw-app/App.tsx b/excalidraw-app/App.tsx index b9db59c65..7615038ac 100644 --- a/excalidraw-app/App.tsx +++ b/excalidraw-app/App.tsx @@ -51,16 +51,22 @@ import { import { isElementLink } from "@excalidraw/element/elementLink"; import { restore, restoreAppState } from "@excalidraw/excalidraw/data/restore"; import { newElementWith } from "@excalidraw/element/mutateElement"; -import { - isFrameLikeElement, - isInitializedImageElement, -} from "@excalidraw/element/typeChecks"; +import { isInitializedImageElement } from "@excalidraw/element/typeChecks"; import clsx from "clsx"; import { parseLibraryTokensFromUrl, useHandleLibrary, } from "@excalidraw/excalidraw/data/library"; +import { getSelectedElements } from "@excalidraw/element/selection"; + +import { + decodeConstraints, + encodeConstraints, +} from "@excalidraw/excalidraw/scene/scrollConstraints"; + +import { useApp } from "@excalidraw/excalidraw/components/App"; + import type { RemoteExcalidrawElement } from "@excalidraw/excalidraw/data/reconcile"; import type { RestoredDataState } from "@excalidraw/excalidraw/data/restore"; import type { @@ -144,11 +150,6 @@ import { ExcalidrawPlusIframeExport } from "./ExcalidrawPlusIframeExport"; import "./index.scss"; import type { CollabAPI } from "./collab/Collab"; -import { getSelectedElements } from "@excalidraw/element/selection"; -import { - decodeConstraints, - encodeConstraints, -} from "@excalidraw/excalidraw/scene/scrollConstraints"; polyfill(); @@ -167,9 +168,8 @@ const ConstraintsSettings = ({ const [constraints, setConstraints] = useState(initialConstraints); - const frames = excalidrawAPI - .getSceneElements() - .filter((e) => isFrameLikeElement(e)); + const app = useApp(); + const frames = app.scene.getNonDeletedFramesLikes(); const [activeFrameId, setActiveFrameId] = useState(null); useEffect(() => { @@ -180,7 +180,7 @@ const ConstraintsSettings = ({ constraints.enabled ? excalidrawAPI.setScrollConstraints(constraints) : excalidrawAPI.setScrollConstraints(null); - }, [constraints]); + }, [constraints, excalidrawAPI]); useEffect(() => { const frame = frames.find((frame) => frame.id === activeFrameId); @@ -196,7 +196,7 @@ const ConstraintsSettings = ({ lockZoom: s.lockZoom, })); } - }, [activeFrameId]); + }, [activeFrameId, frames]); const [selection, setSelection] = useState([]); useEffect(() => { @@ -471,8 +471,6 @@ const initializeScene = async (opts: { ); } - console.log({ shareableLink }); - const externalUrlMatch = window.location.hash.match(/^#url=(.*)$/); const localDataState = importFromLocalStorage(); @@ -498,7 +496,6 @@ const initializeScene = async (opts: { shareableLink[1], localDataState, ); - console.log(">>>>", scene); } scene.scrollToContent = true; if (!roomLinkData) { diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx index 843caff7f..4441f607a 100644 --- a/packages/excalidraw/components/App.tsx +++ b/packages/excalidraw/components/App.tsx @@ -464,6 +464,12 @@ import { isMaybeMermaidDefinition } from "../mermaid"; import { LassoTrail } from "../lasso"; +import { + constrainScrollState, + calculateConstrainedScrollCenter, + areCanvasTranslatesClose, +} from "../scene/scrollConstraints"; + import { activeConfirmDialogAtom } from "./ActiveConfirmDialog"; import BraveMeasureTextError from "./BraveMeasureTextError"; import { ContextMenu, CONTEXT_MENU_SEPARATOR } from "./ContextMenu"; @@ -528,11 +534,6 @@ import type { } from "../types"; import type { RoughCanvas } from "roughjs/bin/canvas"; import type { Action, ActionResult } from "../actions/types"; -import { - constrainScrollState, - calculateConstrainedScrollCenter, - areCanvasTranslatesClose, -} from "../scene/scrollConstraints"; const AppContext = React.createContext(null!); const AppPropsContext = React.createContext(null!); diff --git a/packages/excalidraw/scene/scrollConstraints.ts b/packages/excalidraw/scene/scrollConstraints.ts index 157dbfa1f..ea53f62a7 100644 --- a/packages/excalidraw/scene/scrollConstraints.ts +++ b/packages/excalidraw/scene/scrollConstraints.ts @@ -1,10 +1,12 @@ import { isShallowEqual } from "@excalidraw/common"; -import { + +import { getNormalizedZoom } from "./normalize"; + +import type { AnimateTranslateCanvasValues, AppState, ScrollConstraints, } from "../types"; -import { getNormalizedZoom } from "./normalize"; /** * Calculates the scroll center coordinates and the optimal zoom level to fit the constrained scrollable area within the viewport.