forward scrollConstraints prop from Excalidraw to App + fixed example app

This commit is contained in:
barnabasmolnar
2026-04-08 00:04:20 +02:00
parent fe3ba884f6
commit 6021adab73
3 changed files with 4 additions and 1 deletions
@@ -178,7 +178,7 @@ export default function ExampleApp({
const newElement = cloneElement( const newElement = cloneElement(
Excalidraw, Excalidraw,
{ {
excalidrawAPI: (api: ExcalidrawImperativeAPI) => setExcalidrawAPI(api), onExcalidrawAPI: (api: ExcalidrawImperativeAPI | null) => setExcalidrawAPI(api),
initialData: initialStatePromiseRef.current.promise, initialData: initialStatePromiseRef.current.promise,
onChange: ( onChange: (
elements: NonDeletedExcalidrawElement[], elements: NonDeletedExcalidrawElement[],
+1
View File
@@ -2967,6 +2967,7 @@ class App extends React.Component<AppProps, AppState> {
if (this.props.scrollConstraints) { if (this.props.scrollConstraints) {
restoredAppState = { restoredAppState = {
...restoredAppState, ...restoredAppState,
scrollConstraints: this.props.scrollConstraints,
...calculateConstrainedScrollCenter(this.state, restoredAppState), ...calculateConstrainedScrollCenter(this.state, restoredAppState),
}; };
} else if (initialData?.scrollToContent) { } else if (initialData?.scrollToContent) {
+2
View File
@@ -98,6 +98,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
aiEnabled, aiEnabled,
showDeprecatedFonts, showDeprecatedFonts,
renderScrollbars, renderScrollbars,
scrollConstraints,
} = props; } = props;
const canvasActions = props.UIOptions?.canvasActions; const canvasActions = props.UIOptions?.canvasActions;
@@ -208,6 +209,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
aiEnabled={aiEnabled !== false} aiEnabled={aiEnabled !== false}
showDeprecatedFonts={showDeprecatedFonts} showDeprecatedFonts={showDeprecatedFonts}
renderScrollbars={renderScrollbars} renderScrollbars={renderScrollbars}
scrollConstraints={scrollConstraints}
> >
{children} {children}
</App> </App>