@@ -100,12 +100,10 @@ import {
100100 MINIMUM_ARROW_SIZE ,
101101 DOUBLE_TAP_POSITION_THRESHOLD ,
102102 isMobileOrTablet ,
103- MQ_MAX_MOBILE ,
104- MQ_MIN_TABLET ,
105- MQ_MAX_TABLET ,
106- MQ_MAX_HEIGHT_LANDSCAPE ,
107- MQ_MAX_WIDTH_LANDSCAPE ,
108103 isProdEnv ,
104+ isMobileBreakpoint ,
105+ isTabletBreakpoint ,
106+ getUIMode ,
109107} from "@excalidraw/common" ;
110108
111109import {
@@ -2451,20 +2449,6 @@ class App extends React.Component<AppProps, AppState> {
24512449 }
24522450 } ;
24532451
2454- private isMobileBreakpoint = ( width : number , height : number ) => {
2455- return (
2456- width <= MQ_MAX_MOBILE ||
2457- ( height < MQ_MAX_HEIGHT_LANDSCAPE && width < MQ_MAX_WIDTH_LANDSCAPE )
2458- ) ;
2459- } ;
2460-
2461- private isTabletBreakpoint = ( editorWidth : number , editorHeight : number ) => {
2462- const minSide = Math . min ( editorWidth , editorHeight ) ;
2463- const maxSide = Math . max ( editorWidth , editorHeight ) ;
2464-
2465- return minSide >= MQ_MIN_TABLET && maxSide <= MQ_MAX_TABLET ;
2466- } ;
2467-
24682452 private refreshViewportBreakpoints = ( ) => {
24692453 const container = this . excalidrawContainerRef . current ;
24702454 if ( ! container ) {
@@ -2478,7 +2462,7 @@ class App extends React.Component<AppProps, AppState> {
24782462
24792463 const nextViewportState = updateObject ( prevViewportState , {
24802464 isLandscape : editorWidth > editorHeight ,
2481- isMobile : this . isMobileBreakpoint ( editorWidth , editorHeight ) ,
2465+ isMobile : isMobileBreakpoint ( editorWidth , editorHeight ) ,
24822466 } ) ;
24832467
24842468 if ( prevViewportState !== nextViewportState ) {
@@ -2504,28 +2488,22 @@ class App extends React.Component<AppProps, AppState> {
25042488
25052489 const prevEditorState = this . device . editor ;
25062490
2491+ const uiMode =
2492+ this . props . getUIMode ?.( { width : editorWidth , height : editorHeight } ) ??
2493+ getUIMode ( { width : editorWidth , height : editorHeight } ) ;
2494+
25072495 const nextEditorState = updateObject ( prevEditorState , {
2508- isMobile : this . isMobileBreakpoint ( editorWidth , editorHeight ) ,
2496+ isMobile : uiMode === "mobile" ,
25092497 canFitSidebar : editorWidth > sidebarBreakpoint ,
25102498 } ) ;
25112499
2512- const stylesPanelMode =
2513- // NOTE: we could also remove the isMobileOrTablet check here and
2514- // always switch to compact mode when the editor is narrow (e.g. < MQ_MIN_WIDTH_DESKTOP)
2515- // but not too narrow (> MQ_MAX_WIDTH_MOBILE)
2516- this . isTabletBreakpoint ( editorWidth , editorHeight ) && isMobileOrTablet ( )
2517- ? "compact"
2518- : this . isMobileBreakpoint ( editorWidth , editorHeight )
2519- ? "mobile"
2520- : "full" ;
2521-
25222500 // also check if we need to update the app state
25232501 this . setState ( ( prevState ) => ( {
2524- stylesPanelMode,
2502+ stylesPanelMode : uiMode ,
25252503 // reset to box selection mode if the UI changes to full
25262504 // where you'd not be able to change the mode yourself currently
25272505 preferredSelectionTool :
2528- stylesPanelMode === "full"
2506+ uiMode === "full"
25292507 ? {
25302508 type : "selection" ,
25312509 initialized : true ,
0 commit comments