From 9e52c30ce86d7f7e61ffdb5ecad2523e179f620e Mon Sep 17 00:00:00 2001 From: David Luzar Date: Wed, 22 Mar 2023 18:33:37 +0100 Subject: [PATCH 1/3] fix: use `ideographic` textBaseline to improve layout shift when editing text (#6384) --- src/renderer/renderElement.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/renderer/renderElement.ts b/src/renderer/renderElement.ts index 0861315cce..66d2096cfe 100644 --- a/src/renderer/renderElement.ts +++ b/src/renderer/renderElement.ts @@ -34,6 +34,7 @@ import { AppState, BinaryFiles, Zoom } from "../types"; import { getDefaultAppState } from "../appState"; import { BOUND_TEXT_PADDING, + FONT_FAMILY, MAX_DECIMALS_FOR_SVG_EXPORT, MIME_TYPES, SVG_NS, @@ -286,7 +287,13 @@ const drawElementOnCanvas = ( : element.textAlign === "right" ? element.width : 0; - context.textBaseline = "bottom"; + + // FIXME temporary hack + context.textBaseline = + element.fontFamily === FONT_FAMILY.Virgil || + element.fontFamily === FONT_FAMILY.Cascadia + ? "ideographic" + : "bottom"; const lineHeightPx = getLineHeightInPx( element.fontSize, From 25bb6738ea8619021b27e072fa7707e1b6356c7b Mon Sep 17 00:00:00 2001 From: Type Horror Date: Sat, 25 Mar 2023 15:26:58 -0700 Subject: [PATCH 2/3] 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 a37843c76d..08e8079071 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

-