From 25bb6738ea8619021b27e072fa7707e1b6356c7b Mon Sep 17 00:00:00 2001 From: Type Horror Date: Sat, 25 Mar 2023 15:26:58 -0700 Subject: [PATCH] feat: Add fitToContent and animate to scrollToContent (#6319) Co-authored-by: Brice Leroy Co-authored-by: dwelle --- .../@excalidraw/excalidraw/api/props/ref.mdx | 66 ++++-- src/actions/actionCanvas.tsx | 2 +- src/components/App.tsx | 115 +++++++++-- src/data/restore.ts | 4 +- src/packages/excalidraw/CHANGELOG.md | 2 + src/tests/fitToContent.test.tsx | 189 ++++++++++++++++++ src/utils.ts | 73 +++++++ 7 files changed, 413 insertions(+), 38 deletions(-) create mode 100644 src/tests/fitToContent.test.tsx diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/props/ref.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/props/ref.mdx index a37843c7..08e80790 100644 --- a/dev-docs/docs/@excalidraw/excalidraw/api/props/ref.mdx +++ b/dev-docs/docs/@excalidraw/excalidraw/api/props/ref.mdx @@ -1,6 +1,19 @@ # ref +
-createRef | useRef | callbackRef | 
{ current: { readyPromise: resolvablePromise } } + + createRef + {" "} + |{" "} + useRef{" "} + |{" "} + + callbackRef + {" "} + |
+ { current: { readyPromise: + resolvablePromise + } }
You can pass a `ref` when you want to access some excalidraw APIs. We expose the below APIs: @@ -139,7 +152,9 @@ function App() { return (

Click to update the scene

- + setExcalidrawAPI(api)} />
); @@ -187,7 +202,8 @@ function App() { return (

Click to update the library items

-