@@ -99,12 +99,10 @@ import {
9999 MINIMUM_ARROW_SIZE ,
100100 DOUBLE_TAP_POSITION_THRESHOLD ,
101101 isMobileOrTablet ,
102- MQ_MAX_MOBILE ,
103- MQ_MIN_TABLET ,
104- MQ_MAX_TABLET ,
105- MQ_MAX_HEIGHT_LANDSCAPE ,
106- MQ_MAX_WIDTH_LANDSCAPE ,
107102 isProdEnv ,
103+ isMobileBreakpoint ,
104+ isTabletBreakpoint ,
105+ getUIMode ,
108106} from "@excalidraw/common" ;
109107
110108import {
@@ -2452,20 +2450,6 @@ class App extends React.Component<AppProps, AppState> {
24522450 }
24532451 } ;
24542452
2455- private isMobileBreakpoint = ( width : number , height : number ) => {
2456- return (
2457- width <= MQ_MAX_MOBILE ||
2458- ( height < MQ_MAX_HEIGHT_LANDSCAPE && width < MQ_MAX_WIDTH_LANDSCAPE )
2459- ) ;
2460- } ;
2461-
2462- private isTabletBreakpoint = ( editorWidth : number , editorHeight : number ) => {
2463- const minSide = Math . min ( editorWidth , editorHeight ) ;
2464- const maxSide = Math . max ( editorWidth , editorHeight ) ;
2465-
2466- return minSide >= MQ_MIN_TABLET && maxSide <= MQ_MAX_TABLET ;
2467- } ;
2468-
24692453 private refreshViewportBreakpoints = ( ) => {
24702454 const container = this . excalidrawContainerRef . current ;
24712455 if ( ! container ) {
@@ -2479,7 +2463,7 @@ class App extends React.Component<AppProps, AppState> {
24792463
24802464 const nextViewportState = updateObject ( prevViewportState , {
24812465 isLandscape : editorWidth > editorHeight ,
2482- isMobile : this . isMobileBreakpoint ( editorWidth , editorHeight ) ,
2466+ isMobile : isMobileBreakpoint ( editorWidth , editorHeight ) ,
24832467 } ) ;
24842468
24852469 if ( prevViewportState !== nextViewportState ) {
@@ -2505,28 +2489,22 @@ class App extends React.Component<AppProps, AppState> {
25052489
25062490 const prevEditorState = this . device . editor ;
25072491
2492+ const uiMode =
2493+ this . props . getUIMode ?.( { width : editorWidth , height : editorHeight } ) ??
2494+ getUIMode ( { width : editorWidth , height : editorHeight } ) ;
2495+
25082496 const nextEditorState = updateObject ( prevEditorState , {
2509- isMobile : this . isMobileBreakpoint ( editorWidth , editorHeight ) ,
2497+ isMobile : uiMode === "mobile" ,
25102498 canFitSidebar : editorWidth > sidebarBreakpoint ,
25112499 } ) ;
25122500
2513- const stylesPanelMode =
2514- // NOTE: we could also remove the isMobileOrTablet check here and
2515- // always switch to compact mode when the editor is narrow (e.g. < MQ_MIN_WIDTH_DESKTOP)
2516- // but not too narrow (> MQ_MAX_WIDTH_MOBILE)
2517- this . isTabletBreakpoint ( editorWidth , editorHeight ) && isMobileOrTablet ( )
2518- ? "compact"
2519- : this . isMobileBreakpoint ( editorWidth , editorHeight )
2520- ? "mobile"
2521- : "full" ;
2522-
25232501 // also check if we need to update the app state
25242502 this . setState ( ( prevState ) => ( {
2525- stylesPanelMode,
2503+ stylesPanelMode : uiMode ,
25262504 // reset to box selection mode if the UI changes to full
25272505 // where you'd not be able to change the mode yourself currently
25282506 preferredSelectionTool :
2529- stylesPanelMode === "full"
2507+ uiMode === "full"
25302508 ? {
25312509 type : "selection" ,
25322510 initialized : true ,
0 commit comments