put new props inside UIOptions

This commit is contained in:
Ryan Di
2025-10-15 12:04:30 +11:00
parent 76b5f9a3f7
commit 0003cb741c
2 changed files with 17 additions and 20 deletions

View File

@@ -756,13 +756,10 @@ class App extends React.Component<AppProps, AppState> {
// 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<AppProps, AppState> {
: 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<AppProps, AppState> {
if (didChange) {
this.editorInterface = nextEditorInterface;
this.reconcileStylesPanelMode(nextEditorInterface);
this.props.onEditorInterfaceChange?.(nextEditorInterface);
this.props.UIOptions.onEditorInterfaceChange?.(nextEditorInterface);
}
return didChange;
}

View File

@@ -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;
}
>;