diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx index 910bf5cdee..9ac6ef7f4e 100644 --- a/packages/excalidraw/components/App.tsx +++ b/packages/excalidraw/components/App.tsx @@ -756,13 +756,10 @@ class App extends React.Component { // allow host app to control formFactor and desktopUIMode via props this.editorInterface = updateObject(this.editorInterface, { desktopUIMode: - typeof props.desktopUIMode !== "undefined" - ? props.desktopUIMode - : storedDesktopUIMode ?? this.editorInterface.desktopUIMode, - formFactor: - typeof props.formFactor !== "undefined" - ? props.formFactor - : this.editorInterface.formFactor, + props.UIOptions.desktopUIMode ?? + storedDesktopUIMode ?? + this.editorInterface.desktopUIMode, + formFactor: props.UIOptions.formFactor ?? this.editorInterface.formFactor, userAgent: userAgentDescriptor, }); this.stylesPanelMode = deriveStylesPanelMode(this.editorInterface); @@ -2534,7 +2531,7 @@ class App extends React.Component { : MQ_RIGHT_SIDEBAR_MIN_WIDTH; // if host doesn't control formFactor, we'll update it ourselves - if (!this.props.formFactor) { + if (!this.props.UIOptions.formFactor) { const nextEditorInterface = updateObject(this.editorInterface, { formFactor: deriveFormFactor(editorWidth, editorHeight, { isMobile: (width, height) => this.isMobileBreakpoint(width, height), @@ -2547,7 +2544,7 @@ class App extends React.Component { if (didChange) { this.editorInterface = nextEditorInterface; this.reconcileStylesPanelMode(nextEditorInterface); - this.props.onEditorInterfaceChange?.(nextEditorInterface); + this.props.UIOptions.onEditorInterfaceChange?.(nextEditorInterface); } return didChange; } diff --git a/packages/excalidraw/types.ts b/packages/excalidraw/types.ts index d49c4d901f..4bd7fa3181 100644 --- a/packages/excalidraw/types.ts +++ b/packages/excalidraw/types.ts @@ -673,6 +673,17 @@ export type UIOptions = Partial<{ tools: { image: boolean; }; + /** + * Optionally control the editor form factor and desktop UI mode from the host app. + * If not provided, we will take care of it internally. + */ + formFactor?: EditorInterface["formFactor"]; + desktopUIMode?: EditorInterface["desktopUIMode"]; + /** + * Listener called when the editor interface is refreshed and + * form factor is not controlled by host. + */ + onEditorInterfaceChange?: (editorInterface: EditorInterface) => void; /** @deprecated does nothing. Will be removed in 0.15 */ welcomeScreen?: boolean; }>; @@ -691,17 +702,6 @@ export type AppProps = Merge< isCollaborating: boolean; children?: React.ReactNode; aiEnabled: boolean; - /** - * Optionally control the editor form factor and desktop UI mode from the host app. - * If not provided, we will take care of it internally. - */ - formFactor?: EditorInterface["formFactor"]; - desktopUIMode?: EditorInterface["desktopUIMode"]; - /** - * Listener called when the editor interface is refreshed and - * form factor is not controlled by host. - */ - onEditorInterfaceChange?: (editorInterface: EditorInterface) => void; } >;